3 exFAT file system implementation library.
5 Free exFAT implementation.
6 Copyright (C) 2010-2018 Andrew Nayenko
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 int exfat_errors_fixed;
28 bool exfat_ask_to_fix(const struct exfat* ef)
30 const char* question = "Fix (Y/N)?";
38 case EXFAT_REPAIR_YES:
39 printf("%s %s", question, "Y\n");
41 case EXFAT_REPAIR_ASK:
44 printf("%s ", question);
46 if (fgets(answer, sizeof(answer), stdin))
48 yeah = strcasecmp(answer, "Y\n") == 0;
49 nope = strcasecmp(answer, "N\n") == 0;
57 while (!yeah && !nope);
60 exfat_bug("invalid repair option value: %d", ef->repair);
63 bool exfat_fix_invalid_vbr_checksum(const struct exfat* ef, void* sector,
64 uint32_t vbr_checksum)
67 off_t sector_size = SECTOR_SIZE(*ef->sb);
69 for (i = 0; i < sector_size / sizeof(vbr_checksum); i++)
70 ((le32_t*) sector)[i] = cpu_to_le32(vbr_checksum);
71 if (exfat_pwrite(ef->dev, sector, sector_size, 11 * sector_size) < 0)
73 exfat_error("failed to write correct VBR checksum");