mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Add rewind tracking to aaruformatContext and initialize in create.c
This commit is contained in:
@@ -209,6 +209,9 @@ typedef struct aaruformatContext
|
|||||||
UT_array *indexEntries; ///< Flattened index entries (UT_array of IndexEntry).
|
UT_array *indexEntries; ///< Flattened index entries (UT_array of IndexEntry).
|
||||||
hash_map_t *sectorHashMap; ///< Deduplication hash map (fingerprint->entry mapping).
|
hash_map_t *sectorHashMap; ///< Deduplication hash map (fingerprint->entry mapping).
|
||||||
bool deduplicate; ///< Storage deduplication active (duplicates coalesce).
|
bool deduplicate; ///< Storage deduplication active (duplicates coalesce).
|
||||||
|
|
||||||
|
bool rewinded; ///< True if stream has been rewound after open (write path).
|
||||||
|
uint64_t last_written_block; ///< Last written block number (write path).
|
||||||
} aaruformatContext;
|
} aaruformatContext;
|
||||||
|
|
||||||
/** \struct DumpHardwareEntriesWithData
|
/** \struct DumpHardwareEntriesWithData
|
||||||
|
|||||||
@@ -307,6 +307,9 @@ void *aaruf_create(const char *filepath, const uint32_t media_type, const uint32
|
|||||||
if(ctx->deduplicate)
|
if(ctx->deduplicate)
|
||||||
ctx->sectorHashMap = create_map(ctx->userDataDdtHeader.blocks * 25 / 100); // 25% of total sectors
|
ctx->sectorHashMap = create_map(ctx->userDataDdtHeader.blocks * 25 / 100); // 25% of total sectors
|
||||||
|
|
||||||
|
ctx->rewinded = false;
|
||||||
|
ctx->last_written_block = 0;
|
||||||
|
|
||||||
// Is writing
|
// Is writing
|
||||||
ctx->isWriting = true;
|
ctx->isWriting = true;
|
||||||
|
|
||||||
|
|||||||
10
src/write.c
10
src/write.c
@@ -146,6 +146,16 @@ int32_t aaruf_write_sector(void *context, uint64_t sector_address, bool negative
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check rewinded for disabling checksums
|
// TODO: Check rewinded for disabling checksums
|
||||||
|
if(!ctx->rewinded)
|
||||||
|
{
|
||||||
|
if(sector_address <= ctx->last_written_block)
|
||||||
|
{
|
||||||
|
TRACE("Rewinded");
|
||||||
|
ctx->rewinded = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ctx->last_written_block = sector_address;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: If optical disc check track
|
// TODO: If optical disc check track
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user