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
90static inline const char *aaruformat_error_string(int code)
91{
92 switch(code)
93 {
94 /* Errors */
96 return "Not an AaruFormat image";
98 return "File too small";
100 return "Incompatible image version";
102 return "Cannot read index";
104 return "Sector out of bounds";
106 return "Cannot read header";
108 return "Cannot read block";
110 return "Unsupported compression";
112 return "Not enough memory";
114 return "Buffer too small";
116 return "Media tag not present";
118 return "Incorrect media type";
120 return "Track not found";
122 return "Internal unreachable code reached";
124 return "Invalid track format";
126 return "Sector tag not present";
128 return "Cannot decompress block";
130 return "Invalid block CRC";
132 return "Cannot create file";
134 return "Invalid application name length";
136 return "Cannot write header";
137 case AARUF_READ_ONLY:
138 return "Read-only context";
140 return "Cannot write block header";
142 return "Cannot write block data";
144 return "Cannot set DDT entry";
145
146 /* Status */
147 case AARUF_STATUS_OK:
148 return "OK";
150 return "Sector not dumped";
152 return "Sector with errors";
154 return "Sector deleted";
155 }
156 return "Unknown error/status";
157}
158
159#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_STATUS_OK
Sector present and read without uncorrectable errors.
Definition errors.h:75
#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_INCORRECT_MEDIA_TYPE
Operation incompatible with image media type.
Definition errors.h:51
#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_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:78
#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:76
#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:77
#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:90
#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