]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] misc cleanup of fatfs (3/5)
authorHirofumi Ogawa <hirofumi@mail.parknet.co.jp>
Thu, 25 Apr 2002 06:36:55 +0000 (23:36 -0700)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Thu, 25 Apr 2002 06:36:55 +0000 (23:36 -0700)
This patch does misc cleanup.

OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

fs/fat/cache.c
fs/fat/file.c
fs/fat/inode.c

index 5ed926d621fb68ca3439e170672940aefba42c8f..e6edf3ae144f8fd14ba23bad870ac8efa11c6488 100644 (file)
@@ -36,19 +36,20 @@ int fat_bmap(struct inode *inode,int sector)
 
 int __fat_access(struct super_block *sb, int nr, int new_value)
 {
+       struct msdos_sb_info *sbi = MSDOS_SB(sb);
        struct buffer_head *bh, *bh2, *c_bh, *c_bh2;
        unsigned char *p_first, *p_last;
        int copy, first, last, next, b;
 
-       if (MSDOS_SB(sb)->fat_bits == 32) {
+       if (sbi->fat_bits == 32) {
                first = last = nr*4;
-       } else if (MSDOS_SB(sb)->fat_bits == 16) {
+       } else if (sbi->fat_bits == 16) {
                first = last = nr*2;
        } else {
                first = nr*3/2;
                last = first+1;
        }
-       b = MSDOS_SB(sb)->fat_start + (first >> sb->s_blocksize_bits);
+       b = sbi->fat_start + (first >> sb->s_blocksize_bits);
        if (!(bh = fat_bread(sb, b))) {
                printk("FAT: bread(block %d) in fat_access failed\n", b);
                return -EIO;
@@ -63,27 +64,29 @@ int __fat_access(struct super_block *sb, int nr, int new_value)
                        return -EIO;
                }
        }
-       if (MSDOS_SB(sb)->fat_bits == 32) {
+       if (sbi->fat_bits == 32) {
                p_first = p_last = NULL; /* GCC needs that stuff */
                next = CF_LE_L(((__u32 *) bh->b_data)[(first &
                    (sb->s_blocksize - 1)) >> 2]);
                /* Fscking Microsoft marketing department. Their "32" is 28. */
                next &= 0x0fffffff;
-       } else if (MSDOS_SB(sb)->fat_bits == 16) {
+       } else if (sbi->fat_bits == 16) {
                p_first = p_last = NULL; /* GCC needs that stuff */
                next = CF_LE_W(((__u16 *) bh->b_data)[(first &
                    (sb->s_blocksize - 1)) >> 1]);
        } else {
                p_first = &((__u8 *)bh->b_data)[first & (sb->s_blocksize - 1)];
                p_last = &((__u8 *)bh2->b_data)[(first + 1) & (sb->s_blocksize - 1)];
-               if (nr & 1) next = ((*p_first >> 4) | (*p_last << 4)) & 0xfff;
-               else next = (*p_first+(*p_last << 8)) & 0xfff;
+               if (nr & 1)
+                       next = ((*p_first >> 4) | (*p_last << 4)) & 0xfff;
+               else
+                       next = (*p_first+(*p_last << 8)) & 0xfff;
        }
        if (new_value != -1) {
-               if (MSDOS_SB(sb)->fat_bits == 32) {
+               if (sbi->fat_bits == 32) {
                        ((__u32 *)bh->b_data)[(first & (sb->s_blocksize - 1)) >> 2]
                                = CT_LE_L(new_value);
-               } else if (MSDOS_SB(sb)->fat_bits == 16) {
+               } else if (sbi->fat_bits == 16) {
                        ((__u16 *)bh->b_data)[(first & (sb->s_blocksize - 1)) >> 1]
                                = CT_LE_W(new_value);
                } else {
@@ -98,9 +101,9 @@ int __fat_access(struct super_block *sb, int nr, int new_value)
                        fat_mark_buffer_dirty(sb, bh2);
                }
                fat_mark_buffer_dirty(sb, bh);
-               for (copy = 1; copy < MSDOS_SB(sb)->fats; copy++) {
-                       b = MSDOS_SB(sb)->fat_start + (first >> sb->s_blocksize_bits)
-                               + MSDOS_SB(sb)->fat_length * copy;
+               for (copy = 1; copy < sbi->fats; copy++) {
+                       b = sbi->fat_start + (first >> sb->s_blocksize_bits)
+                               + sbi->fat_length * copy;
                        if (!(c_bh = fat_bread(sb, b)))
                                break;
                        if (bh != bh2) {
@@ -223,7 +226,7 @@ void fat_cache_add(struct inode *inode,int f_clu,int d_clu)
                    && walk->start_cluster == first
                    && walk->file_cluster == f_clu) {
                        if (walk->disk_cluster != d_clu) {
-                               printk("FAT cache corruption inode=%ld\n",
+                               printk("FAT: cache corruption inode=%lu\n",
                                        inode->i_ino);
                                spin_unlock(&fat_cache_lock);
                                fat_cache_inval_inode(inode);
@@ -385,13 +388,13 @@ int fat_free(struct inode *inode,int skip)
                        nr = -EIO;
                        goto error;
                }
-               if (MSDOS_SB(inode->i_sb)->free_clusters != -1) {
-                       MSDOS_SB(inode->i_sb)->free_clusters++;
-                       if (MSDOS_SB(inode->i_sb)->fat_bits == 32) {
-                               fat_clusters_flush(inode->i_sb);
+               if (MSDOS_SB(sb)->free_clusters != -1) {
+                       MSDOS_SB(sb)->free_clusters++;
+                       if (MSDOS_SB(sb)->fat_bits == 32) {
+                               fat_clusters_flush(sb);
                        }
                }
-               inode->i_blocks -= (1 << MSDOS_SB(inode->i_sb)->cluster_bits) / 512;
+               inode->i_blocks -= (1 << MSDOS_SB(sb)->cluster_bits) >> 9 ;
        }
        nr = 0;
 error:
index fa4c71a6b27f4d33d92d67514e60767254a37020..63b952358492daf8d1278e35cd061bf577973ed9 100644 (file)
@@ -49,7 +49,7 @@ int fat_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_r
        if (phys < 0)
                return phys;
        if (phys) {
-               map_bh(bh_result, inode->i_sb, phys);
+               map_bh(bh_result, sb, phys);
                return 0;
        }
        if (!create)
@@ -58,7 +58,7 @@ int fat_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_r
                BUG();
                return -EIO;
        }
-       if (!(iblock % MSDOS_SB(inode->i_sb)->cluster_size)) {
+       if (!(iblock % MSDOS_SB(sb)->cluster_size)) {
                int error;
 
                error = fat_add_cluster(inode);
@@ -72,7 +72,7 @@ int fat_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_r
        if (!phys)
                BUG();
        bh_result->b_state |= (1UL << BH_New);
-       map_bh(bh_result, inode->i_sb, phys);
+       map_bh(bh_result, sb, phys);
        return 0;
 }
 
index 58a0c272f043c3fa74c8091c1cebcf767cbd75ec..7aa58346230c298080e0a1d817a917934f44cea3 100644 (file)
@@ -383,7 +383,7 @@ static int fat_calc_dir_size(struct inode *inode)
                        return -EIO;
                }
                if (inode->i_size > FAT_MAX_DIR_SIZE) {
-                       fat_fs_panic(sb, "Directory %ld: "
+                       fat_fs_panic(sb, "Directory %lu: "
                                     "exceeded the maximum size of directory",
                                     inode->i_ino);
                        inode->i_size = FAT_MAX_DIR_SIZE;
@@ -984,7 +984,7 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
                    /* includes .., compensating for "self" */
 #ifdef DEBUG
                if (!inode->i_nlink) {
-                       printk("directory %d: i_nlink == 0\n",inode->i_ino);
+                       printk("directory %lu: i_nlink == 0\n",inode->i_ino);
                        inode->i_nlink = 1;
                }
 #endif