OSDN Git Service

Repairing: implement invalid node checksum fix.
authorrelan <relan@users.noreply.github.com>
Tue, 14 Mar 2017 05:15:57 +0000 (08:15 +0300)
committerrelan <relan@users.noreply.github.com>
Sat, 15 Sep 2018 04:52:46 +0000 (07:52 +0300)
libexfat/exfat.h
libexfat/node.c
libexfat/repair.c

index d9bbbba..00c903d 100644 (file)
@@ -236,5 +236,7 @@ void exfat_tzset(void);
 bool exfat_ask_to_fix(const struct exfat* ef);
 bool exfat_fix_invalid_vbr_checksum(const struct exfat* ef, void* sector,
                uint32_t vbr_checksum);
+bool exfat_fix_invalid_node_checksum(const struct exfat* ef,
+               struct exfat_node* node);
 
 #endif /* ifndef EXFAT_H_INCLUDED */
index 1ccb1c9..9270ccf 100644 (file)
@@ -223,7 +223,8 @@ static bool check_node(const struct exfat* ef, struct exfat_node* node,
                exfat_get_name(node, buffer);
                exfat_error("'%s' has invalid checksum (%#hx != %#hx)", buffer,
                                le16_to_cpu(actual_checksum), le16_to_cpu(meta1->checksum));
-               ret = false;
+               if (!EXFAT_REPAIR(invalid_node_checksum, ef, node))
+                       ret = false;
        }
 
        /*
index a7222cd..049ebd7 100644 (file)
@@ -76,3 +76,13 @@ bool exfat_fix_invalid_vbr_checksum(const struct exfat* ef, void* sector,
        exfat_errors_fixed++;
        return true;
 }
+
+bool exfat_fix_invalid_node_checksum(const struct exfat* ef,
+               struct exfat_node* node)
+{
+       /* checksum will be rewritten by exfat_flush_node() */
+       node->is_dirty = true;
+
+       exfat_errors_fixed++;
+       return true;
+}