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/fatent.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/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) | |||
450 | BUG_ON(nr_cluster > (MAX_BUF_PER_PAGE / 2)); /* fixed limit */ | 450 | BUG_ON(nr_cluster > (MAX_BUF_PER_PAGE / 2)); /* fixed limit */ |
451 | 451 | ||
452 | lock_fat(sbi); | 452 | lock_fat(sbi); |
453 | if (sbi->free_clusters != -1 && sbi->free_clusters < nr_cluster) { | 453 | if (sbi->free_clusters != -1 && sbi->free_clus_valid && |
454 | sbi->free_clusters < nr_cluster) { | ||
454 | unlock_fat(sbi); | 455 | unlock_fat(sbi); |
455 | return -ENOSPC; | 456 | return -ENOSPC; |
456 | } | 457 | } |
@@ -504,6 +505,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster) | |||
504 | 505 | ||
505 | /* Couldn't allocate the free entries */ | 506 | /* Couldn't allocate the free entries */ |
506 | sbi->free_clusters = 0; | 507 | sbi->free_clusters = 0; |
508 | sbi->free_clus_valid = 1; | ||
507 | sb->s_dirt = 1; | 509 | sb->s_dirt = 1; |
508 | err = -ENOSPC; | 510 | err = -ENOSPC; |
509 | 511 | ||
@@ -615,7 +617,7 @@ int fat_count_free_clusters(struct super_block *sb) | |||
615 | int err = 0, free; | 617 | int err = 0, free; |
616 | 618 | ||
617 | lock_fat(sbi); | 619 | lock_fat(sbi); |
618 | if (sbi->free_clusters != -1) | 620 | if (sbi->free_clusters != -1 && sbi->free_clus_valid) |
619 | goto out; | 621 | goto out; |
620 | 622 | ||
621 | reada_blocks = FAT_READA_SIZE >> sb->s_blocksize_bits; | 623 | reada_blocks = FAT_READA_SIZE >> sb->s_blocksize_bits; |
@@ -643,6 +645,7 @@ int fat_count_free_clusters(struct super_block *sb) | |||
643 | } while (fat_ent_next(sbi, &fatent)); | 645 | } while (fat_ent_next(sbi, &fatent)); |
644 | } | 646 | } |
645 | sbi->free_clusters = free; | 647 | sbi->free_clusters = free; |
648 | sbi->free_clus_valid = 1; | ||
646 | sb->s_dirt = 1; | 649 | sb->s_dirt = 1; |
647 | fatent_brelse(&fatent); | 650 | fatent_brelse(&fatent); |
648 | out: | 651 | out: |