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;
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 {
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) {
&& 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);
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: