Add sector status parameter to read sector functions

This commit is contained in:
2025-10-11 12:42:32 +01:00
parent e78ecff7fa
commit dde81f6773
7 changed files with 75 additions and 51 deletions

View File

@@ -40,6 +40,8 @@ int cli_compare(const char *path1, const char *path2, bool use_long)
int result = 0;
int32_t read_result1 = 0;
int32_t read_result2 = 0;
uint8_t sector_status1 = 0;
uint8_t sector_status2 = 0;
printf("Opening first image: %s\n", path1);
ctx1 = aaruf_open(path1);
@@ -115,13 +117,13 @@ int cli_compare(const char *path1, const char *path2, bool use_long)
if(use_long)
{
read_result1 = aaruf_read_sector_long(ctx1, sector, false, buffer1, &buffer1_length);
read_result2 = aaruf_read_sector_long(ctx2, sector, false, buffer2, &buffer2_length);
read_result1 = aaruf_read_sector_long(ctx1, sector, false, buffer1, &buffer1_length, &sector_status1);
read_result2 = aaruf_read_sector_long(ctx2, sector, false, buffer2, &buffer2_length, &sector_status2);
}
else
{
read_result1 = aaruf_read_sector(ctx1, sector, false, buffer1, &buffer1_length);
read_result2 = aaruf_read_sector(ctx2, sector, false, buffer2, &buffer2_length);
read_result1 = aaruf_read_sector(ctx1, sector, false, buffer1, &buffer1_length, &sector_status1);
read_result2 = aaruf_read_sector(ctx2, sector, false, buffer2, &buffer2_length, &sector_status2);
}
// Handle read errors or missing sectors
@@ -139,6 +141,11 @@ int cli_compare(const char *path1, const char *path2, bool use_long)
// One sector is available, the other is not - they're different
sectors_different = true;
}
else if(sector_status1 != sector_status2)
{
// Both sectors are available but have different status codes
sectors_different = true;
}
else if(sector1_available && sector2_available &&
(buffer1_length != buffer2_length || memcmp(buffer1, buffer2, buffer1_length) != 0))
{