add rescued sectors count to output and fsync(..) call after writing to image

master
Harald Wolff 2024-01-13 20:34:08 +01:00
parent ef80204e3e
commit eb6bed5473
1 changed files with 5 additions and 1 deletions

6
main.c
View File

@ -17,6 +17,8 @@ long devSectorCount = -1;
char *map;
int cntReadSectors = 0;
void printUsage();
int loadScratchMap(char *filename, int size, char *map);
@ -124,7 +126,7 @@ int scratch(int dev, int image,int firstSector, int cntSectors, int sectSize){
for (int try = 0; try < 16; try ++){
for (int sect = firstSector; sect < (firstSector + cntSectors); sect++){
long offset = (long)sect * sectSize;
printf("\r#%08i 0x%08lX %i", sect, offset, try);
printf("\r#%08i 0x%08lX %i (%i rescued / %i to go)", sect, offset, try, cntReadSectors, (cntSectors - cntReadSectors));
fflush(stdout);
if (map[sect])
@ -147,7 +149,9 @@ int scratch(int dev, int image,int firstSector, int cntSectors, int sectSize){
printf("\nshort read!\n");
}
write(image, p, nread);
fsync(image);
map[sect] = 0x01;
cntReadSectors++;
}
}
}