X-Git-Url: https://git.sven.stormbind.net/?a=blobdiff_plain;f=fsck%2Fmain.c;h=399f4320957e6838d0d628d7b4561e4bc7cd73fb;hb=c27cb6376c1313a11e5cc52a8b4f3c9f2c93863b;hp=6a42092ed2068a2bbfc2dd6b5a71b59d5789a177;hpb=b747352475991e7b96183fa1014937efd3e47187;p=sven%2Ffuse-exfat.git diff --git a/fsck/main.c b/fsck/main.c index 6a42092..399f432 100644 --- a/fsck/main.c +++ b/fsck/main.c @@ -3,7 +3,7 @@ exFAT file system checker. Free exFAT implementation. - Copyright (C) 2011-2018 Andrew Nayenko + Copyright (C) 2011-2023 Andrew Nayenko This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ #include #include #include +#include #define exfat_debug(format, ...) do {} while (0) @@ -123,12 +124,17 @@ static void dirck(struct exfat* ef, const char* path) free(entry_path); } -static void fsck(struct exfat* ef, const char* spec, const char* options) +static bool fsck(struct exfat* ef, const char* spec, const char* options) { - if (exfat_mount(ef, spec, options) != 0) + int rc; + + rc = exfat_mount(ef, spec, options); + if (rc == -ENODEV) + return false; /* failed to open the device, checking haven't started */ + if (rc != 0) { fputs("File system checking stopped. ", stdout); - return; + return true; } exfat_print_info(ef->sb, exfat_count_free_clusters(ef)); @@ -139,6 +145,7 @@ static void fsck(struct exfat* ef, const char* spec, const char* options) printf("Totally %"PRIu64" directories and %"PRIu64" files.\n", directories_count, files_count); fputs("File system checking finished. ", stdout); + return true; } static void usage(const char* prog) @@ -175,7 +182,7 @@ int main(int argc, char* argv[]) options = "repair=0,ro"; break; case 'V': - puts("Copyright (C) 2011-2018 Andrew Nayenko"); + puts("Copyright (C) 2011-2023 Andrew Nayenko"); return 0; default: usage(argv[0]); @@ -187,7 +194,8 @@ int main(int argc, char* argv[]) spec = argv[optind]; printf("Checking file system on %s.\n", spec); - fsck(&ef, spec, options); + if (!fsck(&ef, spec, options)) + return 1; if (exfat_errors != 0) { printf("ERRORS FOUND: %d, FIXED: %d.\n",