Last active
September 12, 2017 17:30
-
-
Save jklmnn/9219433acddb39ef1289fa82ef00bcc2 to your computer and use it in GitHub Desktop.
Get the working sectors of a block device. Uses the output of bad sectors created by badblocks. Thanks to @nikp123
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char *argv[]) { | |
FILE *fp = fopen(argv[1], "rb"); | |
if(!fp) return 1; | |
int last = 0, bigdiff = 0, num; | |
while(fscanf(fp, "%d", &num) > 0){ | |
if((num - last) > bigdiff) { | |
printf("Overthrow: %#x > %#x (%#x-%#x)\n", num-last, bigdiff, last, num); | |
bigdiff = num - last; | |
} | |
last = num; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment