diff options
author | AKASHI Takahiro <takahiro.akashi@linaro.org> | 2019-05-24 14:10:37 +0900 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-05-28 18:55:09 -0400 |
commit | cd2d727fff7ea4c69db49d7ee63bd791f91acd26 (patch) | |
tree | b80d0b18fd4792b684c0b7bbef4cd0e3611475c6 /fs/fat/fat_write.c | |
parent | 9c709c7b4177d063733070c7256f0b8635996d65 (diff) | |
download | u-boot-cd2d727fff7ea4c69db49d7ee63bd791f91acd26.tar.gz u-boot-cd2d727fff7ea4c69db49d7ee63bd791f91acd26.tar.bz2 u-boot-cd2d727fff7ea4c69db49d7ee63bd791f91acd26.zip |
fs: fat: allocate a new cluster for root directory of fat32
Contrary to fat12/16, fat32 can have root directory at any location
and its size can be expanded.
Without this patch, root directory won't grow properly and so we will
eventually fail to add files under root directory. Please note that this
can happen even if you delete many files as deleted directory entries
are not reclaimed but just marked as "deleted" under the current
implementation.
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Tested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'fs/fat/fat_write.c')
-rw-r--r-- | fs/fat/fat_write.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index 5ea15fab3a..729cf39630 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -247,8 +247,11 @@ fill_dir_slot(fat_itr *itr, const char *l_name) if (itr->remaining == 0) flush_dir(itr); + /* allocate a cluster for more entries */ if (!fat_itr_next(itr)) - if (!itr->dent && !itr->is_root && new_dir_table(itr)) + if (!itr->dent && + (!itr->is_root || itr->fsdata->fatsize == 32) && + new_dir_table(itr)) return -1; } @@ -980,7 +983,10 @@ static dir_entry *find_directory_entry(fat_itr *itr, char *filename) return itr->dent; } - if (!itr->dent && !itr->is_root && new_dir_table(itr)) + /* allocate a cluster for more entries */ + if (!itr->dent && + (!itr->is_root || itr->fsdata->fatsize == 32) && + new_dir_table(itr)) /* indicate that allocating dent failed */ itr->dent = NULL; |