summaryrefslogtreecommitdiffstats
path: root/fs/fat
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-27 10:40:19 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-27 10:40:19 +0900
commitf35c69b736e4f910d7447346980145212c283570 (patch)
tree824b90cd870e6de07bbba19d761c1c74cf1fb4a7 /fs/fat
parentcd4373984a5903276f52777a6003425e023eaa7e (diff)
parente4aa937ec75df0eea0bee03bffa3303ad36c986b (diff)
downloadop-kernel-dev-f35c69b736e4f910d7447346980145212c283570.zip
op-kernel-dev-f35c69b736e4f910d7447346980145212c283570.tar.gz
Merge 3.10-rc3 into char-misc-next
We want the changes in here. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/fat')
-rw-r--r--fs/fat/inode.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index dfce656..5d4513c 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -1229,6 +1229,19 @@ static int fat_read_root(struct inode *inode)
return 0;
}
+static unsigned long calc_fat_clusters(struct super_block *sb)
+{
+ struct msdos_sb_info *sbi = MSDOS_SB(sb);
+
+ /* Divide first to avoid overflow */
+ if (sbi->fat_bits != 12) {
+ unsigned long ent_per_sec = sb->s_blocksize * 8 / sbi->fat_bits;
+ return ent_per_sec * sbi->fat_length;
+ }
+
+ return sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
+}
+
/*
* Read the super block of an MS-DOS FS.
*/
@@ -1434,7 +1447,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat,
sbi->dirty = b->fat16.state & FAT_STATE_DIRTY;
/* check that FAT table does not overflow */
- fat_clusters = sbi->fat_length * sb->s_blocksize * 8 / sbi->fat_bits;
+ fat_clusters = calc_fat_clusters(sb);
total_clusters = min(total_clusters, fat_clusters - FAT_START_ENT);
if (total_clusters > MAX_FAT(sb)) {
if (!silent)
OpenPOWER on IntegriCloud