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-2026 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)
70#define AARUF_ERROR_INVALID_SECTOR_LENGTH (-31)
71#define AARUF_ERROR_FLUX_DATA_NOT_FOUND (-32)
72#define AARUF_ERROR_INCOMPATIBLE_FEATURES (-33)
73#define AARUF_ERROR_CANNOT_ENCRYPT_SECTOR (-34)
74#define AARUF_ERROR_CANNOT_DECRYPT_SECTOR (-35)
75#define AARUF_ERROR_MISSING_ENCRYPTION_KEY (-36)
76#define AARUF_ERROR_USER_DATA_NOT_PRESENT (-37)
78
82#define AARUF_STATUS_OK 0
83#define AARUF_STATUS_SECTOR_NOT_DUMPED 1
84#define AARUF_STATUS_SECTOR_WITH_ERRORS 2
85#define AARUF_STATUS_SECTOR_DELETED 3
86
88
97static inline const char *aaruformat_error_string(int code)
98{
99 switch(code)
100 {
101 /* Errors */
103 return "Not an AaruFormat image";
105 return "File too small";
107 return "Incompatible image version";
109 return "Cannot read index";
111 return "Sector out of bounds";
113 return "Cannot read header";
115 return "Cannot read block";
117 return "Unsupported compression";
119 return "Not enough memory";
121 return "Buffer too small";
123 return "Media tag not present";
125 return "Incorrect media type";
127 return "Track not found";
129 return "Internal unreachable code reached";
131 return "Invalid track format";
133 return "Sector tag not present";
135 return "Cannot decompress block";
137 return "Invalid block CRC";
139 return "Cannot create file";
141 return "Invalid application name length";
143 return "Cannot write header";
144 case AARUF_READ_ONLY:
145 return "Read-only context";
147 return "Cannot write block header";
149 return "Cannot write block data";
151 return "Cannot set DDT entry";
153 return "Image requires unsupported features";
155 return "Cannot encrypt sector";
157 return "Cannot decrypt sector";
159 return "Missing encryption key";
161 return "User data not present (flux-only image)";
162
163 /* Status */
164 case AARUF_STATUS_OK:
165 return "OK";
167 return "Sector not dumped";
169 return "Sector with errors";
171 return "Sector deleted";
172 }
173 return "Unknown error/status";
174}
175
176#endif // LIBAARUFORMAT_ERRORS_H
#define AARUF_ERROR_CANNOT_CREATE_FILE
Output file could not be created / opened for write.
Definition errors.h:58
#define AARUF_ERROR_CANNOT_WRITE_BLOCK_DATA
Failure writing block payload.
Definition errors.h:63
#define AARUF_ERROR_CANNOT_ENCRYPT_SECTOR
AES sector encryption failed.
Definition errors.h:73
#define AARUF_STATUS_OK
Sector present and read without uncorrectable errors.
Definition errors.h:82
#define AARUF_READ_ONLY
Operation requires write mode but context is read-only.
Definition errors.h:61
#define AARUF_ERROR_INVALID_APP_NAME_LENGTH
Application name field length invalid (sanity limit).
Definition errors.h:59
#define AARUF_ERROR_INCOMPATIBLE_FEATURES
Image requires features not supported by this library.
Definition errors.h:72
#define AARUF_ERROR_INCORRECT_MEDIA_TYPE
Operation incompatible with image media type.
Definition errors.h:51
#define AARUF_ERROR_USER_DATA_NOT_PRESENT
Image has no user-data DDT (e.g. flux-only image); sector data is unavailable.
Definition errors.h:76
#define AARUF_ERROR_TRACK_NOT_FOUND
Referenced track number not present.
Definition errors.h:52
#define AARUF_ERROR_CANNOT_READ_HEADER
Failed to read container header.
Definition errors.h:45
#define AARUF_ERROR_NOT_ENOUGH_MEMORY
Memory allocation failure (critical).
Definition errors.h:48
#define AARUF_ERROR_SECTOR_OUT_OF_BOUNDS
Requested logical sector outside media bounds.
Definition errors.h:44
#define AARUF_ERROR_CANNOT_DECRYPT_SECTOR
AES sector decryption failed.
Definition errors.h:74
#define AARUF_ERROR_MISSING_ENCRYPTION_KEY
Required encryption key not present in media tags.
Definition errors.h:75
#define AARUF_ERROR_INVALID_TRACK_FORMAT
Track metadata internally inconsistent or malformed.
Definition errors.h:54
#define AARUF_ERROR_INCOMPATIBLE_VERSION
Image uses a newer incompatible on-disk version.
Definition errors.h:42
#define AARUF_ERROR_CANNOT_READ_BLOCK
Generic block read failure (seek/read error).
Definition errors.h:46
#define AARUF_STATUS_SECTOR_DELETED
Sector logically marked deleted (e.g. filesystem deleted area).
Definition errors.h:85
#define AARUF_ERROR_CANNOT_SET_DDT_ENTRY
Failed to encode/store a DDT entry (overflow or IO).
Definition errors.h:64
#define AARUF_ERROR_SECTOR_TAG_NOT_PRESENT
Requested sector tag (e.g. subchannel/prefix) not stored.
Definition errors.h:55
#define AARUF_ERROR_INVALID_BLOCK_CRC
CRC64 mismatch indicating corruption.
Definition errors.h:57
#define AARUF_STATUS_SECTOR_NOT_DUMPED
Sector not captured (gap / missing / intentionally skipped).
Definition errors.h:83
#define AARUF_ERROR_CANNOT_READ_INDEX
Index block unreadable / truncated / bad identifier.
Definition errors.h:43
#define AARUF_ERROR_NOT_AARUFORMAT
Input file/stream failed magic or structural validation.
Definition errors.h:40
#define AARUF_STATUS_SECTOR_WITH_ERRORS
Sector present but with unrecoverable or flagged errors.
Definition errors.h:84
#define AARUF_ERROR_CANNOT_DECOMPRESS_BLOCK
Decompression routine failed or size mismatch.
Definition errors.h:56
#define AARUF_ERROR_FILE_TOO_SMALL
File size insufficient for mandatory header / structures.
Definition errors.h:41
#define AARUF_ERROR_MEDIA_TAG_NOT_PRESENT
Requested media tag absent.
Definition errors.h:50
#define AARUF_ERROR_BUFFER_TOO_SMALL
Caller-supplied buffer insufficient for data.
Definition errors.h:49
#define AARUF_ERROR_UNSUPPORTED_COMPRESSION
Block marked with unsupported compression algorithm.
Definition errors.h:47
static const char * aaruformat_error_string(int code)
Convert an AaruFormat error or status code to a static human-readable string.
Definition errors.h:97
#define AARUF_ERROR_CANNOT_WRITE_HEADER
Failure writing container header.
Definition errors.h:60
#define AARUF_ERROR_CANNOT_WRITE_BLOCK_HEADER
Failure writing block header.
Definition errors.h:62
#define AARUF_ERROR_REACHED_UNREACHABLE_CODE
Internal logic assertion hit unexpected path.
Definition errors.h:53