diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ee3c59..125a3b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,7 +98,15 @@ add_library(aaruformat SHARED include/aaruformat/consts.h include/aaruformat/enu src/close.c include/aaruformat/errors.h src/read.c include/aaruformat/crc64.h src/cst.c src/ecc_cd.c src/helpers.c src/simd.c include/aaruformat/simd.h src/crc64/crc64.c src/crc64/crc64_clmul.c src/crc64/crc64_vmull.c src/crc64/arm_vmull.c src/crc64/arm_vmull.h src/spamsum.c include/aaruformat/spamsum.h include/aaruformat/flac.h - src/flac.c src/lzma.c src/lru.c include/aaruformat/lru.h include/aaruformat/endian.h src/verify.c) + src/flac.c src/lzma.c src/lru.c include/aaruformat/lru.h include/aaruformat/endian.h src/verify.c + include/aaruformat/structs/header.h + include/aaruformat/structs/ddt.h + include/aaruformat/structs/index.h + include/aaruformat/structs/data.h + include/aaruformat/structs/metadata.h + include/aaruformat/structs/dump.h + include/aaruformat/structs/checksum.h + include/aaruformat/structs/optical.h) include_directories(include include/aaruformat) diff --git a/include/aaruformat/context.h b/include/aaruformat/context.h index 8107f1c..20fb54f 100644 --- a/include/aaruformat/context.h +++ b/include/aaruformat/context.h @@ -117,4 +117,17 @@ typedef struct DumpExtent #pragma pack(pop) +typedef struct Crc64Context { + uint64_t finalSeed; + uint64_t table[256]; + uint64_t hashInt; +} Crc64Context; + +typedef struct CdEccContext { + bool initedEdc; + uint8_t *eccBTable; + uint8_t *eccFTable; + uint32_t *edcTable; +} CdEccContext; + #endif // LIBAARUFORMAT_CONTEXT_H diff --git a/include/aaruformat/structs.h b/include/aaruformat/structs.h index fa80fac..be5dc59 100644 --- a/include/aaruformat/structs.h +++ b/include/aaruformat/structs.h @@ -24,332 +24,19 @@ #ifndef LIBAARUFORMAT_STRUCTS_H #define LIBAARUFORMAT_STRUCTS_H -#pragma pack(push, 1) - #include #include #include #include "enums.h" - -/**Header, at start of file */ -typedef struct AaruHeader -{ - /**Header identifier, */ - uint64_t identifier; - /**UTF-16LE name of the application that created the image */ - uint8_t application[64]; - /**Image format major version. A new major version means a possibly incompatible change of format */ - uint8_t imageMajorVersion; - /**Image format minor version. A new minor version indicates a compatible change of format */ - uint8_t imageMinorVersion; - /**Major version of the application that created the image */ - uint8_t applicationMajorVersion; - /**Minor version of the application that created the image */ - uint8_t applicationMinorVersion; - /**Type of media contained on image */ - uint32_t mediaType; - /**Offset to index */ - uint64_t indexOffset; - /**Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image creation time */ - int64_t creationTime; - /**Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image last written time */ - int64_t lastWrittenTime; -} AaruHeader; - -#define HEADER_APP_NAME_LEN 64 -#define GUID_SIZE 16 - -/**Header, at start of file */ -typedef struct AaruHeaderV2 { - /**Header identifier, see AARU_MAGIC */ - uint64_t identifier; - /**UTF-16LE name of the application that created the image */ - uint8_t application[HEADER_APP_NAME_LEN]; - /**Image format major version. A new major version means a possibly incompatible change of format */ - uint8_t imageMajorVersion; - /**Image format minor version. A new minor version indicates a compatible change of format */ - uint8_t imageMinorVersion; - /**Major version of the application that created the image */ - uint8_t applicationMajorVersion; - /**Minor version of the application that created the image */ - uint8_t applicationMinorVersion; - /**Type of media contained on image */ - uint32_t mediaType; - /**Offset to index */ - uint64_t indexOffset; - /**Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image creation time */ - int64_t creationTime; - /**Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image last written time */ - int64_t lastWrittenTime; - /**Unique identifier that allows children images to recognize and find this image.*/ - uint8_t guid[GUID_SIZE]; - /**Block alignment shift. All blocks in the image are aligned at 2 << blockAlignmentShift bytes */ - uint8_t blockAlignmentShift; - /**Data shift. All data blocks in the image contain 2 << dataShift items at most */ - uint8_t dataShift; - /**Table shift. All deduplication tables in the image use this shift to calculate the position of an item */ - uint8_t tableShift; - /**Features used in this image that if unsupported are still compatible for reading and writing implementations */ - uint64_t featureCompatible; - /**Features used in this image that if unsupported are still compatible for reading implementations but not for writing */ - uint64_t featureCompatibleRo; - /**Featured used in this image that if unsupported prevent reading or writing the image*/ - uint64_t featureIncompatible; -} AaruHeaderV2; - -/**Header for a deduplication table. Table follows it */ -typedef struct DdtHeader -{ - /**Identifier, */ - uint32_t identifier; - /**Type of data pointed by this DDT */ - uint32_t type; - /**Compression algorithm used to compress the DDT */ - uint16_t compression; - /**Each entry is ((uint8_t offset in file) << shift) + (sector offset in block) */ - uint8_t shift; - /**How many entries are in the table */ - uint64_t entries; - /**Compressed length for the DDT */ - uint64_t cmpLength; - /**Uncompressed length for the DDT */ - uint64_t length; - /**CRC64-ECMA of the compressed DDT */ - uint64_t cmpCrc64; - /**CRC64-ECMA of the uncompressed DDT */ - uint64_t crc64; -} DdtHeader; - -/**Header for the index, followed by entries */ -typedef struct IndexHeader -{ - /**Identifier, */ - uint32_t identifier; - /**How many entries follow this header */ - uint16_t entries; - /**CRC64-ECMA of the index */ - uint64_t crc64; -} IndexHeader; - -/**Index entry */ -typedef struct IndexEntry -{ - /**Type of item pointed by this entry */ - uint32_t blockType; - /**Type of data contained by the block pointed by this entry */ - uint16_t dataType; - /**Offset in file where item is stored */ - uint64_t offset; -} IndexEntry; - -/**Block header, precedes block data */ -typedef struct BlockHeader -{ - /**Identifier, */ - uint32_t identifier; - /**Type of data contained by this block */ - uint32_t type; - /**Compression algorithm used to compress the block */ - uint16_t compression; - /**Size in uint8_ts of each sector contained in this block */ - uint32_t sectorSize; - /**Compressed length for the block */ - uint32_t cmpLength; - /**Uncompressed length for the block */ - uint32_t length; - /**CRC64-ECMA of the compressed block */ - uint64_t cmpCrc64; - /**CRC64-ECMA of the uncompressed block */ - uint64_t crc64; -} BlockHeader; - -/**Geometry block, contains physical geometry information */ -typedef struct GeometryBlockHeader -{ - /**Identifier, */ - uint32_t identifier; - uint32_t cylinders; - uint32_t heads; - uint32_t sectorsPerTrack; -} GeometryBlockHeader; - -/**Metadata block, contains metadata */ -typedef struct MetadataBlockHeader -{ - /**Identifier, */ - uint32_t identifier; - /**Size in uint8_ts of this whole metadata block */ - uint32_t blockSize; - /**Sequence of media set this media beint64_ts to */ - int32_t mediaSequence; - /**Total number of media on the media set this media beint64_ts to */ - int32_t lastMediaSequence; - /**Offset to start of creator string from start of this block */ - uint32_t creatorOffset; - /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ - uint32_t creatorLength; - /**Offset to start of creator string from start of this block */ - uint32_t commentsOffset; - /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ - uint32_t commentsLength; - /**Offset to start of creator string from start of this block */ - uint32_t mediaTitleOffset; - /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ - uint32_t mediaTitleLength; - /**Offset to start of creator string from start of this block */ - uint32_t mediaManufacturerOffset; - /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ - uint32_t mediaManufacturerLength; - /**Offset to start of creator string from start of this block */ - uint32_t mediaModelOffset; - /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ - uint32_t mediaModelLength; - /**Offset to start of creator string from start of this block */ - uint32_t mediaSerialNumberOffset; - /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ - uint32_t mediaSerialNumberLength; - /**Offset to start of creator string from start of this block */ - uint32_t mediaBarcodeOffset; - /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ - uint32_t mediaBarcodeLength; - /**Offset to start of creator string from start of this block */ - uint32_t mediaPartNumberOffset; - /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ - uint32_t mediaPartNumberLength; - /**Offset to start of creator string from start of this block */ - uint32_t driveManufacturerOffset; - /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ - uint32_t driveManufacturerLength; - /**Offset to start of creator string from start of this block */ - uint32_t driveModelOffset; - /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ - uint32_t driveModelLength; - /**Offset to start of creator string from start of this block */ - uint32_t driveSerialNumberOffset; - /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ - uint32_t driveSerialNumberLength; - /**Offset to start of creator string from start of this block */ - uint32_t driveFirmwareRevisionOffset; - /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ - uint32_t driveFirmwareRevisionLength; -} MetadataBlockHeader; - -/**Contains list of optical disc tracks */ -typedef struct TracksHeader -{ - /**Identifier, */ - uint32_t identifier; - /**How many entries follow this header */ - uint16_t entries; - /**CRC64-ECMA of the block */ - uint64_t crc64; -} TracksHeader; - -/**Optical disc track */ -typedef struct TrackEntry -{ - /**Track sequence */ - uint8_t sequence; - /**Track type */ - uint8_t type; - /**Track starting LBA */ - int64_t start; - /**Track last LBA */ - int64_t end; - /**Track pregap in sectors */ - int64_t pregap; - /**Track session */ - uint8_t session; - /**Track's ISRC in ASCII */ - uint8_t isrc[13]; - /**Track flags */ - uint8_t flags; -} TrackEntry; - -/**Geometry block, contains physical geometry information */ -typedef struct CicmMetadataBlock -{ - /**Identifier, */ - uint32_t identifier; - uint32_t length; -} CicmMetadataBlock; - -/**Dump hardware block, contains a list of hardware used to dump the media on this image */ -typedef struct DumpHardwareHeader -{ - /**Identifier, */ - uint32_t identifier; - /**How many entries follow this header */ - uint16_t entries; - /**Size of the whole block, not including this header, in uint8_ts */ - uint32_t length; - /**CRC64-ECMA of the block */ - uint64_t crc64; -} DumpHardwareHeader; - -/**Dump hardware entry, contains length of strings that follow, in the same order as the length, this structure */ -typedef struct DumpHardwareEntry -{ - /**Length of UTF-8 manufacturer string */ - uint32_t manufacturerLength; - /**Length of UTF-8 model string */ - uint32_t modelLength; - /**Length of UTF-8 revision string */ - uint32_t revisionLength; - /**Length of UTF-8 firmware version string */ - uint32_t firmwareLength; - /**Length of UTF-8 serial string */ - uint32_t serialLength; - /**Length of UTF-8 software name string */ - uint32_t softwareNameLength; - /**Length of UTF-8 software version string */ - uint32_t softwareVersionLength; - /**Length of UTF-8 software operating system string */ - uint32_t softwareOperatingSystemLength; - /**How many extents are after the strings */ - uint32_t extents; -} DumpHardwareEntry; - -/** - * Checksum block, contains a checksum of all user data sectors (except for optical discs that is 2352 uint8_ts raw - * sector if available - * */ -typedef struct ChecksumHeader -{ - /**Identifier, */ - uint32_t identifier; - /**Length in uint8_ts of the block */ - uint32_t length; - /**How many checksums follow */ - uint8_t entries; -} ChecksumHeader; - -/**Checksum entry, followed by checksum data itself */ -typedef struct ChecksumEntry -{ - /**Checksum algorithm */ - uint8_t type; - /**Length in uint8_ts of checksum that follows this structure */ - uint32_t length; -} ChecksumEntry; - -typedef struct Crc64Context -{ - uint64_t finalSeed; - uint64_t table[256]; - uint64_t hashInt; -} Crc64Context; - -typedef struct CdEccContext -{ - bool initedEdc; - uint8_t *eccBTable; - uint8_t *eccFTable; - uint32_t *edcTable; -} CdEccContext; - -#pragma pack(pop) +#include "structs/checksum.h" +#include "structs/data.h" +#include "structs/ddt.h" +#include "structs/dump.h" +#include "structs/header.h" +#include "structs/index.h" +#include "structs/metadata.h" +#include "structs/optical.h" #endif // LIBAARUFORMAT_STRUCTS_H diff --git a/include/aaruformat/structs/checksum.h b/include/aaruformat/structs/checksum.h new file mode 100644 index 0000000..43d6753 --- /dev/null +++ b/include/aaruformat/structs/checksum.h @@ -0,0 +1,47 @@ +/* + * This file is part of the Aaru Data Preservation Suite. + * Copyright (c) 2019-2025 Natalia Portillo. + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef LIBAARUFORMAT_CHECKSUM_H +#define LIBAARUFORMAT_CHECKSUM_H + +#pragma pack(push, 1) + +/** + * Checksum block, contains a checksum of all user data sectors (except for optical discs that is 2352 uint8_ts raw + * sector if available + * */ +typedef struct ChecksumHeader { + /**Identifier, */ + uint32_t identifier; + /**Length in uint8_ts of the block */ + uint32_t length; + /**How many checksums follow */ + uint8_t entries; +} ChecksumHeader; + +/**Checksum entry, followed by checksum data itself */ +typedef struct ChecksumEntry { + /**Checksum algorithm */ + uint8_t type; + /**Length in uint8_ts of checksum that follows this structure */ + uint32_t length; +} ChecksumEntry; + +#pragma pack(pop) + +#endif //LIBAARUFORMAT_CHECKSUM_H diff --git a/include/aaruformat/structs/data.h b/include/aaruformat/structs/data.h new file mode 100644 index 0000000..279a191 --- /dev/null +++ b/include/aaruformat/structs/data.h @@ -0,0 +1,55 @@ +/* + * This file is part of the Aaru Data Preservation Suite. + * Copyright (c) 2019-2025 Natalia Portillo. + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef LIBAARUFORMAT_DATA_H +#define LIBAARUFORMAT_DATA_H + +#pragma pack(push, 1) + +/**Block header, precedes block data */ +typedef struct BlockHeader { + /**Identifier, */ + uint32_t identifier; + /**Type of data contained by this block */ + uint32_t type; + /**Compression algorithm used to compress the block */ + uint16_t compression; + /**Size in uint8_ts of each sector contained in this block */ + uint32_t sectorSize; + /**Compressed length for the block */ + uint32_t cmpLength; + /**Uncompressed length for the block */ + uint32_t length; + /**CRC64-ECMA of the compressed block */ + uint64_t cmpCrc64; + /**CRC64-ECMA of the uncompressed block */ + uint64_t crc64; +} BlockHeader; + +/**Geometry block, contains physical geometry information */ +typedef struct GeometryBlockHeader { + /**Identifier, */ + uint32_t identifier; + uint32_t cylinders; + uint32_t heads; + uint32_t sectorsPerTrack; +} GeometryBlockHeader; + +#pragma pack(pop) + +#endif //LIBAARUFORMAT_DATA_H diff --git a/include/aaruformat/structs/ddt.h b/include/aaruformat/structs/ddt.h new file mode 100644 index 0000000..d07fb98 --- /dev/null +++ b/include/aaruformat/structs/ddt.h @@ -0,0 +1,48 @@ +/* + * This file is part of the Aaru Data Preservation Suite. + * Copyright (c) 2019-2025 Natalia Portillo. + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef LIBAARUFORMAT_DDT_H +#define LIBAARUFORMAT_DDT_H + +#pragma pack(push, 1) + +/**Header for a deduplication table. Table follows it */ +typedef struct DdtHeader { + /**Identifier, */ + uint32_t identifier; + /**Type of data pointed by this DDT */ + uint32_t type; + /**Compression algorithm used to compress the DDT */ + uint16_t compression; + /**Each entry is ((uint8_t offset in file) << shift) + (sector offset in block) */ + uint8_t shift; + /**How many entries are in the table */ + uint64_t entries; + /**Compressed length for the DDT */ + uint64_t cmpLength; + /**Uncompressed length for the DDT */ + uint64_t length; + /**CRC64-ECMA of the compressed DDT */ + uint64_t cmpCrc64; + /**CRC64-ECMA of the uncompressed DDT */ + uint64_t crc64; +} DdtHeader; + +#pragma pack(pop) + +#endif //LIBAARUFORMAT_DDT_H diff --git a/include/aaruformat/structs/dump.h b/include/aaruformat/structs/dump.h new file mode 100644 index 0000000..51f7745 --- /dev/null +++ b/include/aaruformat/structs/dump.h @@ -0,0 +1,60 @@ +/* + * This file is part of the Aaru Data Preservation Suite. + * Copyright (c) 2019-2025 Natalia Portillo. + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef LIBAARUFORMAT_DUMP_H +#define LIBAARUFORMAT_DUMP_H + +#pragma pack(push, 1) + +/**Dump hardware block, contains a list of hardware used to dump the media on this image */ +typedef struct DumpHardwareHeader { + /**Identifier, */ + uint32_t identifier; + /**How many entries follow this header */ + uint16_t entries; + /**Size of the whole block, not including this header, in uint8_ts */ + uint32_t length; + /**CRC64-ECMA of the block */ + uint64_t crc64; +} DumpHardwareHeader; + +/**Dump hardware entry, contains length of strings that follow, in the same order as the length, this structure */ +typedef struct DumpHardwareEntry { + /**Length of UTF-8 manufacturer string */ + uint32_t manufacturerLength; + /**Length of UTF-8 model string */ + uint32_t modelLength; + /**Length of UTF-8 revision string */ + uint32_t revisionLength; + /**Length of UTF-8 firmware version string */ + uint32_t firmwareLength; + /**Length of UTF-8 serial string */ + uint32_t serialLength; + /**Length of UTF-8 software name string */ + uint32_t softwareNameLength; + /**Length of UTF-8 software version string */ + uint32_t softwareVersionLength; + /**Length of UTF-8 software operating system string */ + uint32_t softwareOperatingSystemLength; + /**How many extents are after the strings */ + uint32_t extents; +} DumpHardwareEntry; + +#pragma pack(pop) + +#endif //LIBAARUFORMAT_DUMP_H diff --git a/include/aaruformat/structs/header.h b/include/aaruformat/structs/header.h new file mode 100644 index 0000000..71d7132 --- /dev/null +++ b/include/aaruformat/structs/header.h @@ -0,0 +1,91 @@ +/* + * This file is part of the Aaru Data Preservation Suite. + * Copyright (c) 2019-2025 Natalia Portillo. + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef LIBAARUFORMAT_HEADER_H +#define LIBAARUFORMAT_HEADER_H + +#define AARU_HEADER_APP_NAME_LEN 64 +#define GUID_SIZE 16 + +#pragma pack(push, 1) + +/**Header, at start of file */ +typedef struct AaruHeader { + /**Header identifier, */ + uint64_t identifier; + /**UTF-16LE name of the application that created the image */ + uint8_t application[AARU_HEADER_APP_NAME_LEN]; + /**Image format major version. A new major version means a possibly incompatible change of format */ + uint8_t imageMajorVersion; + /**Image format minor version. A new minor version indicates a compatible change of format */ + uint8_t imageMinorVersion; + /**Major version of the application that created the image */ + uint8_t applicationMajorVersion; + /**Minor version of the application that created the image */ + uint8_t applicationMinorVersion; + /**Type of media contained on image */ + uint32_t mediaType; + /**Offset to index */ + uint64_t indexOffset; + /**Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image creation time */ + int64_t creationTime; + /**Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image last written time */ + int64_t lastWrittenTime; +} AaruHeader; + +/**Header, at start of file */ +typedef struct AaruHeaderV2 { + /**Header identifier, see AARU_MAGIC */ + uint64_t identifier; + /**UTF-16LE name of the application that created the image */ + uint8_t application[AARU_HEADER_APP_NAME_LEN]; + /**Image format major version. A new major version means a possibly incompatible change of format */ + uint8_t imageMajorVersion; + /**Image format minor version. A new minor version indicates a compatible change of format */ + uint8_t imageMinorVersion; + /**Major version of the application that created the image */ + uint8_t applicationMajorVersion; + /**Minor version of the application that created the image */ + uint8_t applicationMinorVersion; + /**Type of media contained on image */ + uint32_t mediaType; + /**Offset to index */ + uint64_t indexOffset; + /**Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image creation time */ + int64_t creationTime; + /**Windows filetime (100 nanoseconds since 1601/01/01 00:00:00 UTC) of image last written time */ + int64_t lastWrittenTime; + /**Unique identifier that allows children images to recognize and find this image.*/ + uint8_t guid[GUID_SIZE]; + /**Block alignment shift. All blocks in the image are aligned at 2 << blockAlignmentShift bytes */ + uint8_t blockAlignmentShift; + /**Data shift. All data blocks in the image contain 2 << dataShift items at most */ + uint8_t dataShift; + /**Table shift. All deduplication tables in the image use this shift to calculate the position of an item */ + uint8_t tableShift; + /**Features used in this image that if unsupported are still compatible for reading and writing implementations */ + uint64_t featureCompatible; + /**Features used in this image that if unsupported are still compatible for reading implementations but not for writing */ + uint64_t featureCompatibleRo; + /**Featured used in this image that if unsupported prevent reading or writing the image*/ + uint64_t featureIncompatible; +} AaruHeaderV2; + +#pragma pack(pop) + +#endif //LIBAARUFORMAT_HEADER_H diff --git a/include/aaruformat/structs/index.h b/include/aaruformat/structs/index.h new file mode 100644 index 0000000..ca8b4fd --- /dev/null +++ b/include/aaruformat/structs/index.h @@ -0,0 +1,46 @@ +/* + * This file is part of the Aaru Data Preservation Suite. + * Copyright (c) 2019-2025 Natalia Portillo. + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef LIBAARUFORMAT_INDEX_H +#define LIBAARUFORMAT_INDEX_H + +#pragma pack(push, 1) + +/**Header for the index, followed by entries */ +typedef struct IndexHeader { + /**Identifier, */ + uint32_t identifier; + /**How many entries follow this header */ + uint16_t entries; + /**CRC64-ECMA of the index */ + uint64_t crc64; +} IndexHeader; + +/**Index entry */ +typedef struct IndexEntry { + /**Type of item pointed by this entry */ + uint32_t blockType; + /**Type of data contained by the block pointed by this entry */ + uint16_t dataType; + /**Offset in file where item is stored */ + uint64_t offset; +} IndexEntry; + +#pragma pack(pop) + +#endif //LIBAARUFORMAT_INDEX_H diff --git a/include/aaruformat/structs/metadata.h b/include/aaruformat/structs/metadata.h new file mode 100644 index 0000000..9a88fc8 --- /dev/null +++ b/include/aaruformat/structs/metadata.h @@ -0,0 +1,93 @@ +/* + * This file is part of the Aaru Data Preservation Suite. + * Copyright (c) 2019-2025 Natalia Portillo. + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef LIBAARUFORMAT_METADATA_H +#define LIBAARUFORMAT_METADATA_H + +#pragma pack(push, 1) + +/**Metadata block, contains metadata */ +typedef struct MetadataBlockHeader { + /**Identifier, */ + uint32_t identifier; + /**Size in uint8_ts of this whole metadata block */ + uint32_t blockSize; + /**Sequence of media set this media beint64_ts to */ + int32_t mediaSequence; + /**Total number of media on the media set this media beint64_ts to */ + int32_t lastMediaSequence; + /**Offset to start of creator string from start of this block */ + uint32_t creatorOffset; + /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ + uint32_t creatorLength; + /**Offset to start of creator string from start of this block */ + uint32_t commentsOffset; + /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ + uint32_t commentsLength; + /**Offset to start of creator string from start of this block */ + uint32_t mediaTitleOffset; + /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ + uint32_t mediaTitleLength; + /**Offset to start of creator string from start of this block */ + uint32_t mediaManufacturerOffset; + /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ + uint32_t mediaManufacturerLength; + /**Offset to start of creator string from start of this block */ + uint32_t mediaModelOffset; + /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ + uint32_t mediaModelLength; + /**Offset to start of creator string from start of this block */ + uint32_t mediaSerialNumberOffset; + /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ + uint32_t mediaSerialNumberLength; + /**Offset to start of creator string from start of this block */ + uint32_t mediaBarcodeOffset; + /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ + uint32_t mediaBarcodeLength; + /**Offset to start of creator string from start of this block */ + uint32_t mediaPartNumberOffset; + /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ + uint32_t mediaPartNumberLength; + /**Offset to start of creator string from start of this block */ + uint32_t driveManufacturerOffset; + /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ + uint32_t driveManufacturerLength; + /**Offset to start of creator string from start of this block */ + uint32_t driveModelOffset; + /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ + uint32_t driveModelLength; + /**Offset to start of creator string from start of this block */ + uint32_t driveSerialNumberOffset; + /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ + uint32_t driveSerialNumberLength; + /**Offset to start of creator string from start of this block */ + uint32_t driveFirmwareRevisionOffset; + /**Length in uint8_ts of the null-terminated UTF-16LE creator string */ + uint32_t driveFirmwareRevisionLength; +} MetadataBlockHeader; + +/**Geometry block, contains physical geometry information */ +typedef struct CicmMetadataBlock { + /**Identifier, */ + uint32_t identifier; + uint32_t length; +} CicmMetadataBlock; + +#pragma pack(pop) + +#endif //LIBAARUFORMAT_METADATA_H diff --git a/include/aaruformat/structs/optical.h b/include/aaruformat/structs/optical.h new file mode 100644 index 0000000..ee2c9b6 --- /dev/null +++ b/include/aaruformat/structs/optical.h @@ -0,0 +1,56 @@ +/* + * This file is part of the Aaru Data Preservation Suite. + * Copyright (c) 2019-2025 Natalia Portillo. + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * */ + +#ifndef LIBAARUFORMAT_OPTICAL_H +#define LIBAARUFORMAT_OPTICAL_H + +#pragma pack(push, 1) + +/**Contains list of optical disc tracks */ +typedef struct TracksHeader { + /**Identifier, */ + uint32_t identifier; + /**How many entries follow this header */ + uint16_t entries; + /**CRC64-ECMA of the block */ + uint64_t crc64; +} TracksHeader; + +/**Optical disc track */ +typedef struct TrackEntry { + /**Track sequence */ + uint8_t sequence; + /**Track type */ + uint8_t type; + /**Track starting LBA */ + int64_t start; + /**Track last LBA */ + int64_t end; + /**Track pregap in sectors */ + int64_t pregap; + /**Track session */ + uint8_t session; + /**Track's ISRC in ASCII */ + uint8_t isrc[13]; + /**Track flags */ + uint8_t flags; +} TrackEntry; + +#pragma pack(pop) + +#endif //LIBAARUFORMAT_OPTICAL_H