public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] FAT: update the second FAT when writing a file
@ 2011-12-21  4:34 Donggeun Kim
  2012-01-05 16:20 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Donggeun Kim @ 2011-12-21  4:34 UTC (permalink / raw)
  To: u-boot

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>
---
 fs/fat/fat_write.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index 4f1772f..9e34def 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;
 }
 
@@ -949,6 +959,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;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] FAT: update the second FAT when writing a file
  2011-12-21  4:34 [U-Boot] [PATCH] FAT: update the second FAT when writing a file Donggeun Kim
@ 2012-01-05 16:20 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2012-01-05 16:20 UTC (permalink / raw)
  To: u-boot

Dear Donggeun Kim,

In message <1324442067-6448-1-git-send-email-dg77.kim@samsung.com> you wrote:
> 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>
> ---
>  fs/fat/fat_write.c |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You can't evaluate a man by logic alone.
	-- McCoy, "I, Mudd", stardate 4513.3

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-05 16:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-21  4:34 [U-Boot] [PATCH] FAT: update the second FAT when writing a file Donggeun Kim
2012-01-05 16:20 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox