Skip to content

Commit

Permalink
Repairing: implement unknown entry type fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
relan committed Sep 15, 2018
1 parent 53728e5 commit f9c0f1b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions libexfat/exfat.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,7 @@ 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);
bool exfat_fix_unknown_entry(struct exfat* ef, struct exfat_node* dir,
const struct exfat_entry* entry, off_t offset);

#endif /* ifndef EXFAT_H_INCLUDED */
3 changes: 2 additions & 1 deletion libexfat/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,8 @@ static int readdir(struct exfat* ef, struct exfat_node* parent,
break; /* deleted entry, ignore it */

exfat_error("unknown entry type %#hhx", entry.type);
return -EIO;
if (!EXFAT_REPAIR(unknown_entry, ef, parent, &entry, *offset))
return -EIO;
}
*offset += sizeof(entry);
}
Expand Down
14 changes: 14 additions & 0 deletions libexfat/repair.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,17 @@ bool exfat_fix_invalid_node_checksum(const struct exfat* ef,
exfat_errors_fixed++;
return true;
}

bool exfat_fix_unknown_entry(struct exfat* ef, struct exfat_node* dir,
const struct exfat_entry* entry, off_t offset)
{
struct exfat_entry deleted = *entry;

deleted.type &= ~EXFAT_ENTRY_VALID;
if (exfat_generic_pwrite(ef, dir, &deleted, sizeof(struct exfat_entry),
offset) != sizeof(struct exfat_entry))
return false;

exfat_errors_fixed++;
return true;
}

0 comments on commit f9c0f1b

Please sign in to comment.