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)
73
77#define AARUF_STATUS_OK 0
78#define AARUF_STATUS_SECTOR_NOT_DUMPED 1
79#define AARUF_STATUS_SECTOR_WITH_ERRORS 2
80#define AARUF_STATUS_SECTOR_DELETED 3
81
83
92static inline const char *aaruformat_error_string(int code)
93{
94 switch(code)
95 {
96 /* Errors */
98 return "Not an AaruFormat image";
100 return "File too small";
102 return "Incompatible image version";
104 return "Cannot read index";
106 return "Sector out of bounds";
108 return "Cannot read header";
110 return "Cannot read block";
112 return "Unsupported compression";
114 return "Not enough memory";
116 return "Buffer too small";
118 return "Media tag not present";
120 return "Incorrect media type";
122 return "Track not found";
124 return "Internal unreachable code reached";
126 return "Invalid track format";
128 return "Sector tag not present";
130 return "Cannot decompress block";
132 return "Invalid block CRC";
134 return "Cannot create file";
136 return "Invalid application name length";
138 return "Cannot write header";
139 case AARUF_READ_ONLY:
140 return "Read-only context";
142 return "Cannot write block header";
144 return "Cannot write block data";
146 return "Cannot set DDT entry";
147
148 /* Status */
149 case AARUF_STATUS_OK:
150 return "OK";
152 return "Sector not dumped";
154 return "Sector with errors";
156 return "Sector deleted";
157 }
158 return "Unknown error/status";
159}
160
161#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:77
#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:80
#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:78
#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:79
#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:92
#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