summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2019-01-02 01:41:23 -0800
committerYe Li <ye.li@nxp.com>2019-01-03 19:31:05 -0800
commit9e0a33cacc0a7926d46c0ca184498ae88278816e (patch)
tree484e5cff775d6cba9bd783c79e92d79fc7c95494
parent615283d0ebe7cd23bc32f3d8539a75ab49f71064 (diff)
MLK-20668-2 fat: Fix issue in rootdir table flush for FAT16/12
The FAT16/12 has rootdir area before data area, and the clusters for rootdir are not mantained by FAT table. So we don't need to find empty cluster for next rootdir space, just use next dir cluster. And the FAT table don't need to update for this new dir cluster. Signed-off-by: Ye Li <ye.li@nxp.com> Acked-by: Peng Fan <peng.fan@nxp.com>
-rw-r--r--fs/fat/fat_write.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index 5d22121709..25f6df3820 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -591,14 +591,18 @@ static void flush_dir_table(fsdata *mydata, dir_entry **dentptr)
printf("error: wrinting directory entry\n");
return;
}
- dir_newclust = find_empty_cluster(mydata);
- set_fatent_value(mydata, dir_curclust, dir_newclust);
- if (mydata->fatsize == 32)
+
+ if (mydata->fatsize == 32) {
+ dir_newclust = find_empty_cluster(mydata);
+ set_fatent_value(mydata, dir_curclust, dir_newclust);
set_fatent_value(mydata, dir_newclust, 0xffffff8);
- else if (mydata->fatsize == 16)
- set_fatent_value(mydata, dir_newclust, 0xfff8);
- else if (mydata->fatsize == 12)
- set_fatent_value(mydata, dir_newclust, 0xff8);
+ } else {
+ dir_newclust = dir_curclust + 1;
+ if (dir_newclust > 1) {
+ printf("error: fail to get empty clust for directory entry\n");
+ return;
+ }
+ }
dir_curclust = dir_newclust;