--- fat-epoc/trunk/fat-epoc-2.6.12.diff 2005/11/20 22:16:12 283 +++ fat-epoc/trunk/fat-epoc-2.6.12.diff 2005/11/21 20:34:31 284 @@ -1,6 +1,6 @@ -diff -u2 -r linux-source-2.6.12.unpatched/fs/fat/dir.c linux-source-2.6.12/fs/fat/dir.c +diff -r2 -u linux-source-2.6.12.unpatched/fs/fat/dir.c linux-source-2.6.12/fs/fat/dir.c --- linux-source-2.6.12.unpatched/fs/fat/dir.c 2005-06-17 21:48:29.000000000 +0200 -+++ linux-source-2.6.12/fs/fat/dir.c 2005-11-20 22:36:26.000000000 +0100 ++++ linux-source-2.6.12/fs/fat/dir.c 2005-11-21 21:00:07.000000000 +0100 @@ -221,4 +221,5 @@ loff_t cpos = 0; int chl, i, j, last_u, err; @@ -71,23 +71,23 @@ } +/* Set the first character of the next entry to zero. */ -+void fat_write_zero_entry(struct inode *dir, loff_t curr) ++int fat_write_zero_entry(struct inode *dir, loff_t curr) +{ + struct msdos_dir_entry *de = NULL; + struct buffer_head *bh = NULL; + loff_t pos; -+ int err; ++ int err = 0; + + pos = curr; + if (fat_get_entry(dir,&pos,&bh,&de) < 0) -+ return; ++ return 0; + + de->name[0] = EOD_FLAG; + mark_buffer_dirty(bh); + if (IS_DIRSYNC(dir)) -+ /* We should handle the error condition here! */ + err = sync_dirty_buffer(bh); + brelse(bh); ++ return err; +} + + @@ -111,16 +111,26 @@ + if (last_entry || IS_FREE(de->name)) { if (prev != bh) { get_bh(bh); -@@ -1222,4 +1270,8 @@ - } - -+ /* We need to write an end-of-directory slot */ +@@ -1185,6 +1233,18 @@ + found: + err = 0; ++ + pos -= free_slots * sizeof(*de); + nr_slots -= free_slots; ++ ++ /* We need to write an end-of-directory slot. And we do it first, ++ * because we want to keep the directory in a readble state. ++ * Note that there is no need to remove it on error, as it is beyond ++ * the visible end of directory anyway. ++ */ + if (epoc && !nr_slots && last_entry) -+ fat_write_zero_entry(dir, pos + free_slots * sizeof(*de)); -+ - if (nr_slots) { - int cluster, nr_cluster; -diff -u2 -r linux-source-2.6.12.unpatched/fs/fat/inode.c linux-source-2.6.12/fs/fat/inode.c ++ err = fat_write_zero_entry(dir, pos + free_slots * sizeof(*de)); ++ if (err) ++ goto error; ++ + if (free_slots) { + /* +diff -r2 -u linux-source-2.6.12.unpatched/fs/fat/inode.c linux-source-2.6.12/fs/fat/inode.c --- linux-source-2.6.12.unpatched/fs/fat/inode.c 2005-06-17 21:48:29.000000000 +0200 +++ linux-source-2.6.12/fs/fat/inode.c 2005-11-20 20:45:29.000000000 +0100 @@ -756,4 +756,5 @@ @@ -144,7 +154,7 @@ + /* msdos specific */ -diff -u2 -r linux-source-2.6.12.unpatched/include/linux/msdos_fs.h linux-source-2.6.12/include/linux/msdos_fs.h +diff -r2 -u linux-source-2.6.12.unpatched/include/linux/msdos_fs.h linux-source-2.6.12/include/linux/msdos_fs.h --- linux-source-2.6.12.unpatched/include/linux/msdos_fs.h 2005-06-17 21:48:29.000000000 +0200 +++ linux-source-2.6.12/include/linux/msdos_fs.h 2005-11-20 20:45:29.000000000 +0100 @@ -45,4 +45,5 @@