testdevinfo.c (dosfstools-4.1) | : | testdevinfo.c (dosfstools-4.2) | ||
---|---|---|---|---|
skipping to change at line 34 | skipping to change at line 34 | |||
int main(int argc, char **argv) | int main(int argc, char **argv) | |||
{ | { | |||
struct device_info info; | struct device_info info; | |||
int fd; | int fd; | |||
if (argc != 2) { | if (argc != 2) { | |||
printf("Usage: testdevinfo FILENAME\n"); | printf("Usage: testdevinfo FILENAME\n"); | |||
return 1; | return 1; | |||
} | } | |||
fd = open(argv[1], O_RDONLY); | fd = open(argv[1], O_RDONLY | O_NONBLOCK); | |||
if (fd < 0) { | if (fd < 0) { | |||
perror("open device"); | perror("open device"); | |||
return 1; | return 1; | |||
} | } | |||
device_info_verbose = 100; | device_info_verbose = 100; | |||
get_device_info(fd, &info); | get_device_info(fd, &info); | |||
close(fd); | close(fd); | |||
printf("\nfound information:\n"); | printf("found information:\n"); | |||
printf("device type: "); | printf("device type: "); | |||
switch (info.type) { | switch (info.type) { | |||
case TYPE_UNKNOWN: | case TYPE_UNKNOWN: | |||
printf("unknown\n"); | printf("unknown\n"); | |||
break; | break; | |||
case TYPE_BAD: | case TYPE_BAD: | |||
printf("unusable\n"); | printf("unusable\n"); | |||
break; | break; | |||
skipping to change at line 109 | skipping to change at line 109 | |||
printf("sectors: "); | printf("sectors: "); | |||
if (info.geom_sectors < 0) | if (info.geom_sectors < 0) | |||
printf("unknown\n"); | printf("unknown\n"); | |||
else | else | |||
printf("%d\n", info.geom_sectors); | printf("%d\n", info.geom_sectors); | |||
printf("start: "); | printf("start: "); | |||
if (info.geom_start < 0) | if (info.geom_start < 0) | |||
printf("unknown\n"); | printf("unknown\n"); | |||
else | else | |||
printf("%ld\n", info.geom_start); | printf("%lld\n", info.geom_start); | |||
printf("total disk sectors: "); | ||||
if (info.geom_size < 0) | ||||
printf("unknown\n"); | ||||
else | ||||
printf("%lld\n", info.geom_size); | ||||
printf("sector size: "); | printf("sector size: "); | |||
if (info.sector_size < 0) | if (info.sector_size < 0) | |||
printf("unknown\n"); | printf("unknown\n"); | |||
else | else | |||
printf("%d\n", info.sector_size); | printf("%d\n", info.sector_size); | |||
printf("size: "); | printf("size: "); | |||
if (info.size < 0) | if (info.size < 0) | |||
printf("unknown\n"); | printf("unknown\n"); | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 9 lines changed or added |