Repurpose two unused header fields to store biggest image sector size.

This commit is contained in:
2025-12-30 20:13:39 +00:00
parent c09b251c59
commit 7f0dea2755
5 changed files with 7 additions and 8 deletions

View File

@@ -117,8 +117,7 @@ typedef struct AaruHeaderV2
int64_t lastWrittenTime; ///< Last modification FILETIME (100 ns since 1601-01-01 UTC).
uint8_t guid[GUID_SIZE]; ///< 128-bit image GUID (binary, not text); stable across children.
uint8_t blockAlignmentShift; ///< log2 block alignment (block size alignment = 2^blockAlignmentShift bytes).
uint8_t dataShift; ///< log2 sectors/items per block-index increment in DDT entries (2^dataShift).
uint8_t tableShift; ///< log2 sectors spanned by each primary DDT entry (0 = single-level).
uint16_t biggestSectorSize; ///< size of biggest sector in the image (in bytes).
uint64_t featureCompatible; ///< Feature bits: unimplemented bits are ignorable (still R/W safe).
uint64_t featureCompatibleRo; ///< Feature bits: unimplemented -> degrade to read-only access.
uint64_t featureIncompatible; ///< Feature bits: any unimplemented -> abort (cannot open safely).

View File

@@ -16,6 +16,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
@@ -146,6 +147,8 @@ AARU_EXPORT int32_t AARU_CALL aaruf_write_sector(void *context, uint64_t sector_
return AARUF_ERROR_SECTOR_OUT_OF_BOUNDS;
}
if(length > ctx->header.biggestSectorSize) ctx->header.biggestSectorSize = (uint16_t)length;
if(!ctx->rewinded)
{
if(sector_address <= ctx->last_written_block)

View File

@@ -784,8 +784,7 @@ typedef struct
{
GUID guid;
byte blockAlignmentShift;
byte dataShift;
byte tableShift;
uint16 biggestSectorSize;
FeaturesCompatible featureCompatible;
uint64 featureCompatibleRo;
uint64 featureIncompatible;

View File

@@ -811,8 +811,7 @@ struct AaruHeader
{
type::GUID guid;
u8 blockAlignmentShift;
u8 dataShift;
u8 tableShift;
u16 biggestSectorSize;
u64 featureCompatible;
u64 featureCompatibleRo;
u64 featureIncompatible;

View File

@@ -106,8 +106,7 @@ int upgrade_ddt_to_alpha21(const char *path)
printf(" Index offset: %llu bytes\n", (unsigned long long)header.indexOffset);
printf(" Media type: %u (%s)\n", header.mediaType, media_type_to_string(header.mediaType));
printf(" Block alignment shift: %u\n", header.blockAlignmentShift);
printf(" Data shift: %u\n", header.dataShift);
printf(" Table shift: %u\n", header.tableShift);
printf(" Biggest sector size: %u bytes\n", header.biggestSectorSize);
// Display important warnings
printf("\n");