diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2008-04-28 02:16:27 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-28 08:58:47 -0700 |
commit | 606e423e43bac0c2f7b85b682eb1ddd2a634586e (patch) | |
tree | 86e7bc56e7e70cf1403aec7fd58d854490b1478f /fs/fat/fatent.c | |
parent | 1ae43f826b6cb951fc5b0f9c92372a8d5b63c7f9 (diff) | |
download | linux-606e423e43bac0c2f7b85b682eb1ddd2a634586e.tar.gz linux-606e423e43bac0c2f7b85b682eb1ddd2a634586e.tar.bz2 linux-606e423e43bac0c2f7b85b682eb1ddd2a634586e.zip |
fat: Update free_clusters even if it is untrusted
Currently, free_clusters is not updated until it is trusted, because
Windows doesn't update it correctly.
But if user is using FAT driver of Linux, it updates free_clusters
correctly. Instead, this updates it even if it's untrusted, so if
free_clustes is correct, now keep correct value.
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/fat/fatent.c')
-rw-r--r-- | fs/fat/fatent.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c index 5fb366992b73..c7c8ab2209e1 100644 --- a/fs/fat/fatent.c +++ b/fs/fat/fatent.c @@ -450,7 +450,8 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster) BUG_ON(nr_cluster > (MAX_BUF_PER_PAGE / 2)); /* fixed limit */ lock_fat(sbi); - if (sbi->free_clusters != -1 && sbi->free_clusters < nr_cluster) { + if (sbi->free_clusters != -1 && sbi->free_clus_valid && + sbi->free_clusters < nr_cluster) { unlock_fat(sbi); return -ENOSPC; } @@ -504,6 +505,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster) /* Couldn't allocate the free entries */ sbi->free_clusters = 0; + sbi->free_clus_valid = 1; sb->s_dirt = 1; err = -ENOSPC; @@ -615,7 +617,7 @@ int fat_count_free_clusters(struct super_block *sb) int err = 0, free; lock_fat(sbi); - if (sbi->free_clusters != -1) + if (sbi->free_clusters != -1 && sbi->free_clus_valid) goto out; reada_blocks = FAT_READA_SIZE >> sb->s_blocksize_bits; @@ -643,6 +645,7 @@ int fat_count_free_clusters(struct super_block *sb) } while (fat_ent_next(sbi, &fatent)); } sbi->free_clusters = free; + sbi->free_clus_valid = 1; sb->s_dirt = 1; fatent_brelse(&fatent); out: |