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
#include <string.h>
#include <inttypes.h>
#include <unistd.h>
+#include <errno.h>
#define exfat_debug(format, ...) do {} while (0)
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));
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)
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]);
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",