From 86b94f842fe3886c96ae7a3201d5cfc04dea6b53 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 29 Dec 2003 23:45:57 -0800 Subject: [PATCH] [PATCH] FAT: misc cleanups/fixes From: OGAWA Hirofumi fatfs misc cleanups/fixes. --- fs/fat/inode.c | 23 ++++++++++++----------- include/linux/msdos_fs_sb.h | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 4e5d0c08517b2..065b12513bf91 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -765,8 +765,9 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, struct buffer_head *bh; struct fat_boot_sector *b; struct msdos_sb_info *sbi; + u16 logical_sector_size; u32 total_sectors, total_clusters, fat_clusters, rootdir_sectors; - int logical_sector_size, debug, cp, first; + int debug, cp, first; unsigned int media; long error; char buf[50]; @@ -831,14 +832,13 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, brelse(bh); goto out_invalid; } - logical_sector_size = - CF_LE_W(get_unaligned((unsigned short *) &b->sector_size)); + logical_sector_size = CF_LE_W(get_unaligned((u16 *)&b->sector_size)); if (!logical_sector_size || (logical_sector_size & (logical_sector_size - 1)) || (logical_sector_size < 512) || (PAGE_CACHE_SIZE < logical_sector_size)) { if (!silent) - printk(KERN_ERR "FAT: bogus logical sector size %d\n", + printk(KERN_ERR "FAT: bogus logical sector size %u\n", logical_sector_size); brelse(bh); goto out_invalid; @@ -847,7 +847,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, if (!sbi->sec_per_clus || (sbi->sec_per_clus & (sbi->sec_per_clus - 1))) { if (!silent) - printk(KERN_ERR "FAT: bogus sectors per cluster %d\n", + printk(KERN_ERR "FAT: bogus sectors per cluster %u\n", sbi->sec_per_clus); brelse(bh); goto out_invalid; @@ -855,7 +855,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, if (logical_sector_size < sb->s_blocksize) { printk(KERN_ERR "FAT: logical sector size too small for device" - " (logical sector size = %d)\n", logical_sector_size); + " (logical sector size = %u)\n", logical_sector_size); brelse(bh); goto out_fail; } @@ -863,7 +863,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, brelse(bh); if (!sb_set_blocksize(sb, logical_sector_size)) { - printk(KERN_ERR "FAT: unable to set blocksize %d\n", + printk(KERN_ERR "FAT: unable to set blocksize %u\n", logical_sector_size); goto out_fail; } @@ -932,10 +932,11 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, sbi->dir_per_block_bits = ffs(sbi->dir_per_block) - 1; sbi->dir_start = sbi->fat_start + sbi->fats * sbi->fat_length; - sbi->dir_entries = - CF_LE_W(get_unaligned((unsigned short *)&b->dir_entries)); + sbi->dir_entries = CF_LE_W(get_unaligned((u16 *)&b->dir_entries)); if (sbi->dir_entries & (sbi->dir_per_block - 1)) { - printk(KERN_ERR "FAT: bogus directroy-entries per block\n"); + if (!silent) + printk(KERN_ERR "FAT: bogus directroy-entries per block" + " (%u)\n", sbi->dir_entries); brelse(bh); goto out_invalid; } @@ -943,7 +944,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, rootdir_sectors = sbi->dir_entries * sizeof(struct msdos_dir_entry) / sb->s_blocksize; sbi->data_start = sbi->dir_start + rootdir_sectors; - total_sectors = CF_LE_W(get_unaligned((unsigned short *)&b->sectors)); + total_sectors = CF_LE_W(get_unaligned((u16 *)&b->sectors)); if (total_sectors == 0) total_sectors = CF_LE_L(b->total_sect); diff --git a/include/linux/msdos_fs_sb.h b/include/linux/msdos_fs_sb.h index 26d64203f0866..c79a172225d32 100644 --- a/include/linux/msdos_fs_sb.h +++ b/include/linux/msdos_fs_sb.h @@ -47,7 +47,7 @@ struct msdos_sb_info { unsigned long data_start; /* first data sector */ unsigned long clusters; /* number of clusters */ unsigned long root_cluster; /* first cluster of the root directory */ - unsigned long fsinfo_sector; /* FAT32 fsinfo offset from start of disk */ + unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */ struct semaphore fat_lock; int prev_free; /* previously allocated cluster number */ int free_clusters; /* -1 if undefined */ -- 2.53.0