libaaruformat 1.0 Aaru Data Preservation Suite - Format Library

Loading...
Searching...
No Matches
errors.h
Go to the documentation of this file.
1/*
2 * This file is part of the Aaru Data Preservation Suite.
3 * Copyright (c) 2019-2025 Natalia Portillo.
4 *
5 * This library is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; either version 2.1 of the
8 * License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef LIBAARUFORMAT_ERRORS_H
20#define LIBAARUFORMAT_ERRORS_H
21
37
40#define AARUF_ERROR_NOT_AARUFORMAT (-1)
41#define AARUF_ERROR_FILE_TOO_SMALL (-2)
42#define AARUF_ERROR_INCOMPATIBLE_VERSION (-3)
43#define AARUF_ERROR_CANNOT_READ_INDEX (-4)
44#define AARUF_ERROR_SECTOR_OUT_OF_BOUNDS (-5)
45#define AARUF_ERROR_CANNOT_READ_HEADER (-6)
46#define AARUF_ERROR_CANNOT_READ_BLOCK (-7)
47#define AARUF_ERROR_UNSUPPORTED_COMPRESSION (-8)
48#define AARUF_ERROR_NOT_ENOUGH_MEMORY (-9)
49#define AARUF_ERROR_BUFFER_TOO_SMALL (-10)
50#define AARUF_ERROR_MEDIA_TAG_NOT_PRESENT (-11)
51#define AARUF_ERROR_INCORRECT_MEDIA_TYPE (-12)
52#define AARUF_ERROR_TRACK_NOT_FOUND (-13)
53#define AARUF_ERROR_REACHED_UNREACHABLE_CODE (-14)
54#define AARUF_ERROR_INVALID_TRACK_FORMAT (-15)
55#define AARUF_ERROR_SECTOR_TAG_NOT_PRESENT (-16)
56#define AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK (-17)
57#define AARUF_ERROR_INVALID_BLOCK_CRC (-18)
58#define AARUF_ERROR_CANNOT_CREATE_FILE (-19)
59#define AARUF_ERROR_INVALID_APP_NAME_LENGTH (-20)
60#define AARUF_ERROR_CANNOT_WRITE_HEADER (-21)
61#define AARUF_READ_ONLY (-22)
62#define AARUF_ERROR_CANNOT_WRITE_BLOCK_HEADER (-23)
63#define AARUF_ERROR_CANNOT_WRITE_BLOCK_DATA (-24)
64#define AARUF_ERROR_CANNOT_SET_DDT_ENTRY (-25)
65#define AARUF_ERROR_INCORRECT_DATA_SIZE (-26)
66#define AARUF_ERROR_INVALID_TAG (-27)
67#define AARUF_ERROR_TAPE_FILE_NOT_FOUND (-28)
68#define AARUF_ERROR_TAPE_PARTITION_NOT_FOUND (-29)
69#define AARUF_ERROR_METADATA_NOT_PRESENT (-30)
71
75#define AARUF_STATUS_OK 0
76#define AARUF_STATUS_SECTOR_NOT_DUMPED 1
77#define AARUF_STATUS_SECTOR_WITH_ERRORS 2
78#define AARUF_STATUS_SECTOR_DELETED 3
79
81
90 static inline const char *aaruformat_error_string(int code)
91{
92 switch(code)
93 {
94 /* Errors */
95 case AARUF_ERROR_NOT_AARUFORMAT:
96 return "Not an AaruFormat image";
97 case AARUF_ERROR_FILE_TOO_SMALL:
98 return "File too small";
99 case AARUF_ERROR_INCOMPATIBLE_VERSION:
100 return "Incompatible image version";
101 case AARUF_ERROR_CANNOT_READ_INDEX:
102 return "Cannot read index";
103 case AARUF_ERROR_SECTOR_OUT_OF_BOUNDS:
104 return "Sector out of bounds";
105 case AARUF_ERROR_CANNOT_READ_HEADER:
106 return "Cannot read header";
107 case AARUF_ERROR_CANNOT_READ_BLOCK:
108 return "Cannot read block";
109 case AARUF_ERROR_UNSUPPORTED_COMPRESSION:
110 return "Unsupported compression";
111 case AARUF_ERROR_NOT_ENOUGH_MEMORY:
112 return "Not enough memory";
113 case AARUF_ERROR_BUFFER_TOO_SMALL:
114 return "Buffer too small";
115 case AARUF_ERROR_MEDIA_TAG_NOT_PRESENT:
116 return "Media tag not present";
117 case AARUF_ERROR_INCORRECT_MEDIA_TYPE:
118 return "Incorrect media type";
119 case AARUF_ERROR_TRACK_NOT_FOUND:
120 return "Track not found";
121 case AARUF_ERROR_REACHED_UNREACHABLE_CODE:
122 return "Internal unreachable code reached";
123 case AARUF_ERROR_INVALID_TRACK_FORMAT:
124 return "Invalid track format";
125 case AARUF_ERROR_SECTOR_TAG_NOT_PRESENT:
126 return "Sector tag not present";
127 case AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK:
128 return "Cannot decompress block";
129 case AARUF_ERROR_INVALID_BLOCK_CRC:
130 return "Invalid block CRC";
131 case AARUF_ERROR_CANNOT_CREATE_FILE:
132 return "Cannot create file";
133 case AARUF_ERROR_INVALID_APP_NAME_LENGTH:
134 return "Invalid application name length";
135 case AARUF_ERROR_CANNOT_WRITE_HEADER:
136 return "Cannot write header";
137 case AARUF_READ_ONLY:
138 return "Read-only context";
139 case AARUF_ERROR_CANNOT_WRITE_BLOCK_HEADER:
140 return "Cannot write block header";
141 case AARUF_ERROR_CANNOT_WRITE_BLOCK_DATA:
142 return "Cannot write block data";
143 case AARUF_ERROR_CANNOT_SET_DDT_ENTRY:
144 return "Cannot set DDT entry";
145
146 /* Status */
147 case AARUF_STATUS_OK:
148 return "OK";
149 case AARUF_STATUS_SECTOR_NOT_DUMPED:
150 return "Sector not dumped";
151 case AARUF_STATUS_SECTOR_WITH_ERRORS:
152 return "Sector with errors";
153 case AARUF_STATUS_SECTOR_DELETED:
154 return "Sector deleted";
155 }
156 return "Unknown error/status";
157}
158
159#endif // LIBAARUFORMAT_ERRORS_H
AARUF_ERROR_CANNOT_CREATE_FILE
#define AARUF_ERROR_CANNOT_CREATE_FILE
Output file could not be created / opened for write.
Definition errors.h:58
AARUF_ERROR_CANNOT_WRITE_BLOCK_DATA
#define AARUF_ERROR_CANNOT_WRITE_BLOCK_DATA
Failure writing block payload.
Definition errors.h:63
AARUF_STATUS_OK
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
Definition errors.h:75
AARUF_READ_ONLY
#define AARUF_READ_ONLY
Operation requires write mode but context is read-only.
Definition errors.h:61
AARUF_ERROR_INVALID_APP_NAME_LENGTH
#define AARUF_ERROR_INVALID_APP_NAME_LENGTH
Application name field length invalid (sanity limit).
Definition errors.h:59
AARUF_ERROR_INCORRECT_MEDIA_TYPE
#define AARUF_ERROR_INCORRECT_MEDIA_TYPE
Operation incompatible with image media type.
Definition errors.h:51
AARUF_ERROR_TRACK_NOT_FOUND
#define AARUF_ERROR_TRACK_NOT_FOUND
Referenced track number not present.
Definition errors.h:52
AARUF_ERROR_CANNOT_READ_HEADER
#define AARUF_ERROR_CANNOT_READ_HEADER
Failed to read container header.
Definition errors.h:45
AARUF_ERROR_NOT_ENOUGH_MEMORY
#define AARUF_ERROR_NOT_ENOUGH_MEMORY
Memory allocation failure (critical).
Definition errors.h:48
AARUF_ERROR_SECTOR_OUT_OF_BOUNDS
#define AARUF_ERROR_SECTOR_OUT_OF_BOUNDS
Requested logical sector outside media bounds.
Definition errors.h:44
AARUF_ERROR_INVALID_TRACK_FORMAT
#define AARUF_ERROR_INVALID_TRACK_FORMAT
Track metadata internally inconsistent or malformed.
Definition errors.h:54
AARUF_ERROR_INCOMPATIBLE_VERSION
#define AARUF_ERROR_INCOMPATIBLE_VERSION
Image uses a newer incompatible on-disk version.
Definition errors.h:42
AARUF_ERROR_CANNOT_READ_BLOCK
#define AARUF_ERROR_CANNOT_READ_BLOCK
Generic block read failure (seek/read error).
Definition errors.h:46
AARUF_STATUS_SECTOR_DELETED
#define AARUF_STATUS_SECTOR_DELETED
Sector logically marked deleted (e.g. filesystem deleted area).
Definition errors.h:78
AARUF_ERROR_CANNOT_SET_DDT_ENTRY
#define AARUF_ERROR_CANNOT_SET_DDT_ENTRY
Failed to encode/store a DDT entry (overflow or IO).
Definition errors.h:64
AARUF_ERROR_SECTOR_TAG_NOT_PRESENT
#define AARUF_ERROR_SECTOR_TAG_NOT_PRESENT
Requested sector tag (e.g. subchannel/prefix) not stored.
Definition errors.h:55
AARUF_ERROR_INVALID_BLOCK_CRC
#define AARUF_ERROR_INVALID_BLOCK_CRC
CRC64 mismatch indicating corruption.
Definition errors.h:57
AARUF_STATUS_SECTOR_NOT_DUMPED
#define AARUF_STATUS_SECTOR_NOT_DUMPED
Sector not captured (gap / missing / intentionally skipped).
Definition errors.h:76
AARUF_ERROR_CANNOT_READ_INDEX
#define AARUF_ERROR_CANNOT_READ_INDEX
Index block unreadable / truncated / bad identifier.
Definition errors.h:43
AARUF_ERROR_NOT_AARUFORMAT
#define AARUF_ERROR_NOT_AARUFORMAT
Input file/stream failed magic or structural validation.
Definition errors.h:40
AARUF_STATUS_SECTOR_WITH_ERRORS
#define AARUF_STATUS_SECTOR_WITH_ERRORS
Sector present but with unrecoverable or flagged errors.
Definition errors.h:77
AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK
#define AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK
Decompression routine failed or size mismatch.
Definition errors.h:56
AARUF_ERROR_FILE_TOO_SMALL
#define AARUF_ERROR_FILE_TOO_SMALL
File size insufficient for mandatory header / structures.
Definition errors.h:41
AARUF_ERROR_MEDIA_TAG_NOT_PRESENT
#define AARUF_ERROR_MEDIA_TAG_NOT_PRESENT
Requested media tag absent.
Definition errors.h:50
AARUF_ERROR_BUFFER_TOO_SMALL
#define AARUF_ERROR_BUFFER_TOO_SMALL
Caller-supplied buffer insufficient for data.
Definition errors.h:49
AARUF_ERROR_UNSUPPORTED_COMPRESSION
#define AARUF_ERROR_UNSUPPORTED_COMPRESSION
Block marked with unsupported compression algorithm.
Definition errors.h:47
aaruformat_error_string
static const char * aaruformat_error_string(int code)
Convert an AaruFormat error or status code to a static human-readable string.
Definition errors.h:90
AARUF_ERROR_CANNOT_WRITE_HEADER
#define AARUF_ERROR_CANNOT_WRITE_HEADER
Failure writing container header.
Definition errors.h:60
AARUF_ERROR_CANNOT_WRITE_BLOCK_HEADER
#define AARUF_ERROR_CANNOT_WRITE_BLOCK_HEADER
Failure writing block header.
Definition errors.h:62
AARUF_ERROR_REACHED_UNREACHABLE_CODE
#define AARUF_ERROR_REACHED_UNREACHABLE_CODE
Internal logic assertion hit unexpected path.
Definition errors.h:53