summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonggeun Kim <dg77.kim@samsung.com>2011-12-20 18:34:27 +0000
committerWolfgang Denk <wd@denx.de>2012-01-05 20:10:38 +0100
commit627182ea9d0f157f7280aa650dd4c06461b20c3e (patch)
tree6f2fbb19e130641762cacc0b9d0dc4b82f5ce259
parent5dd95cf93dfffa1d19a1928990852aac9f55b9d9 (diff)
downloadu-boot-imx-627182ea9d0f157f7280aa650dd4c06461b20c3e.zip
u-boot-imx-627182ea9d0f157f7280aa650dd4c06461b20c3e.tar.gz
u-boot-imx-627182ea9d0f157f7280aa650dd4c06461b20c3e.tar.bz2
FAT: update the second FAT when writing a file
After susccessful write to the FAT partition, fsck program may print warning message due to different FAT, provided that the filesystem supports two FATs. This patch makes the second FAT to be same with the first one when writing a file. Signed-off-by: Donggeun Kim <dg77.kim@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
-rw-r--r--fs/fat/fat_write.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index 3542b0b..3bfc1c4 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -112,6 +112,7 @@ static void set_name(dir_entry *dirent, const char *filename)
debug("ext : %s\n", dirent->ext);
}
+static __u8 num_of_fats;
/*
* Write fat buffer into block device
*/
@@ -134,6 +135,15 @@ static int flush_fat_buffer(fsdata *mydata)
return -1;
}
+ if (num_of_fats == 2) {
+ /* Update corresponding second FAT blocks */
+ startblock += mydata->fatlength;
+ if (disk_write(startblock, getsize, bufptr) < 0) {
+ debug("error: writing second FAT blocks\n");
+ return -1;
+ }
+ }
+
return 0;
}
@@ -950,6 +960,7 @@ static int do_fat_write(const char *filename, void *buffer,
cursect = mydata->rootdir_sect
= mydata->fat_sect + mydata->fatlength * bs.fats;
+ num_of_fats = bs.fats;
mydata->sect_size = (bs.sector_size[1] << 8) + bs.sector_size[0];
mydata->clust_size = bs.cluster_size;