From 69f9cf5a88707116e18be597ca03b55bb3bc6d5f Mon Sep 17 00:00:00 2001 From: Maurizio Lombardi Date: Fri, 24 Feb 2012 22:39:27 +0100 Subject: [PATCH] mkexfat: Allocate a cluster for the root directory entry also, fix bug in the fat_allocate_cluster() function --- uspace/app/mkexfat/mkexfat.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/uspace/app/mkexfat/mkexfat.c b/uspace/app/mkexfat/mkexfat.c index 7eca1cafc..5a86010a3 100644 --- a/uspace/app/mkexfat/mkexfat.c +++ b/uspace/app/mkexfat/mkexfat.c @@ -377,8 +377,8 @@ fat_allocate_clusters(service_id_t service_id, exfat_cfg_t *cfg, uint32_t cur_cls, unsigned long ncls) { int rc; - aoff64_t fat_sec = cur_cls / sizeof(uint32_t) + FAT_SECTOR_START; unsigned const fat_entries = cfg->sector_size / sizeof(uint32_t); + aoff64_t fat_sec = cur_cls / fat_entries + FAT_SECTOR_START; uint32_t *fat; cur_cls %= fat_entries; @@ -610,6 +610,16 @@ int main (int argc, char **argv) return 2; } + next_cls += div_round_up(sizeof(upcase_table), cfg.cluster_size); + cfg.rootdir_cluster = next_cls; + + /* Allocate a cluster for the root directory entry */ + rc = fat_allocate_clusters(service_id, &cfg, next_cls, 1); + if (rc != EOK) { + printf(NAME ": Error, failed to allocate cluster for the root dentry.\n"); + return 2; + } + return 0; } -- 2.11.4.GIT