mkfat: don't allow 0-entry root directory

The root directory should span at least 1 sector.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2019-06-12 18:55:39 +08:00
parent a161ce7b8d
commit 723143e36f

View File

@ -29,6 +29,8 @@ int fat12_mkfs(struct pang_io *io, uint32_t bytes) {
uint32_t fat_size_sectors = ((fat_size - 1) / sector_size) + 1;
uint32_t root_directory_sector_count = cluster_size - (fat_size_sectors + reserved_sectors);
if (!root_directory_sector_count)
root_directory_sector_count = cluster_size;
uint32_t root_directory_entry_count = (sector_size / sizeof(struct fat_directory_entry)) * root_directory_sector_count;
fprintf(stderr, "bytes: %d\n", bytes);