diff options
author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2008-04-28 05:16:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-28 11:58:47 -0400 |
commit | 606e423e43bac0c2f7b85b682eb1ddd2a634586e (patch) | |
tree | 86e7bc56e7e70cf1403aec7fd58d854490b1478f /fs/fat/inode.c | |
parent | 1ae43f826b6cb951fc5b0f9c92372a8d5b63c7f9 (diff) |
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/inode.c')
-rw-r--r-- | fs/fat/inode.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 886f6095a378..1604a8a5c01f 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -537,7 +537,7 @@ static int fat_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
537 | struct msdos_sb_info *sbi = MSDOS_SB(dentry->d_sb); | 537 | struct msdos_sb_info *sbi = MSDOS_SB(dentry->d_sb); |
538 | 538 | ||
539 | /* If the count of free cluster is still unknown, counts it here. */ | 539 | /* If the count of free cluster is still unknown, counts it here. */ |
540 | if (sbi->free_clusters == -1) { | 540 | if (sbi->free_clusters == -1 || !sbi->free_clus_valid) { |
541 | int err = fat_count_free_clusters(dentry->d_sb); | 541 | int err = fat_count_free_clusters(dentry->d_sb); |
542 | if (err) | 542 | if (err) |
543 | return err; | 543 | return err; |
@@ -1274,6 +1274,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1274 | sbi->fat_length = le16_to_cpu(b->fat_length); | 1274 | sbi->fat_length = le16_to_cpu(b->fat_length); |
1275 | sbi->root_cluster = 0; | 1275 | sbi->root_cluster = 0; |
1276 | sbi->free_clusters = -1; /* Don't know yet */ | 1276 | sbi->free_clusters = -1; /* Don't know yet */ |
1277 | sbi->free_clus_valid = 0; | ||
1277 | sbi->prev_free = FAT_START_ENT; | 1278 | sbi->prev_free = FAT_START_ENT; |
1278 | 1279 | ||
1279 | if (!sbi->fat_length && b->fat32_length) { | 1280 | if (!sbi->fat_length && b->fat32_length) { |
@@ -1309,8 +1310,8 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1309 | sbi->fsinfo_sector); | 1310 | sbi->fsinfo_sector); |
1310 | } else { | 1311 | } else { |
1311 | if (sbi->options.usefree) | 1312 | if (sbi->options.usefree) |
1312 | sbi->free_clusters = | 1313 | sbi->free_clus_valid = 1; |
1313 | le32_to_cpu(fsinfo->free_clusters); | 1314 | sbi->free_clusters = le32_to_cpu(fsinfo->free_clusters); |
1314 | sbi->prev_free = le32_to_cpu(fsinfo->next_cluster); | 1315 | sbi->prev_free = le32_to_cpu(fsinfo->next_cluster); |
1315 | } | 1316 | } |
1316 | 1317 | ||