Skip to content

Commit

Permalink
exfatprogs: if exfat is not found, warn it and exit
Browse files Browse the repository at this point in the history
If exfat is not found, make dump, label, tune
warn it and exit.

Signed-off-by: Hyunchul Lee <[email protected]>
  • Loading branch information
hclee committed Dec 9, 2021
1 parent d58057b commit c0c2025
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dump/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ static int exfat_show_ondisk_all_info(struct exfat_blk_dev *bd)
goto free_ppbr;
}

if (memcmp(ppbr->bpb.oem_name, "EXFAT ", 8) != 0) {
exfat_err("Bad fs_name in boot sector, which does not describe a valid exfat filesystem\n");
ret = -EINVAL;
goto free_ppbr;
}

pbsx = &ppbr->bsx;

if (pbsx->sect_size_bits < EXFAT_MIN_SECT_SIZE_BITS ||
Expand Down
18 changes: 18 additions & 0 deletions lib/libexfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ off_t exfat_get_root_entry_offset(struct exfat_blk_dev *bd)
return -1;
}

if (memcmp(bs->bpb.oem_name, "EXFAT ", 8) != 0) {
exfat_err("Bad fs_name in boot sector, which does not describe a valid exfat filesystem\n");
free(bs);
return -1;
}

sector_size = 1 << bs->bsx.sect_size_bits;
cluster_size = (1 << bs->bsx.sect_per_clus_bits) * sector_size;
root_clu_off = le32_to_cpu(bs->bsx.clu_offset) * sector_size +
Expand Down Expand Up @@ -546,6 +552,12 @@ int exfat_show_volume_serial(int fd)
goto free_ppbr;
}

if (memcmp(ppbr->bpb.oem_name, "EXFAT ", 8) != 0) {
exfat_err("Bad fs_name in boot sector, which does not describe a valid exfat filesystem\n");
ret = -1;
goto free_ppbr;
}

exfat_info("volume serial : 0x%x\n", ppbr->bsx.vol_serial);

free_ppbr:
Expand Down Expand Up @@ -614,6 +626,12 @@ int exfat_set_volume_serial(struct exfat_blk_dev *bd,
goto free_ppbr;
}

if (memcmp(ppbr->bpb.oem_name, "EXFAT ", 8) != 0) {
exfat_err("Bad fs_name in boot sector, which does not describe a valid exfat filesystem\n");
ret = -1;
goto free_ppbr;
}

bd->sector_size = 1 << ppbr->bsx.sect_size_bits;
ppbr->bsx.vol_serial = ui->volume_serial;

Expand Down

0 comments on commit c0c2025

Please sign in to comment.