cache.c (c1b054d03f5b31c33eaa0b267c629b118eaf3790) | cache.c (e5174baaea7585760f02eef23b225847d209a8db) |
---|---|
1/* 2 * linux/fs/fat/cache.c 3 * 4 * Written 1992,1993 by Werner Almesberger 5 * 6 * Mar 1999. AV. Changed cache, so that it uses the starting cluster instead 7 * of inode number. 8 * May 1999. AV. Fixed the bogosity with FAT32 (read "FAT28"). Fscking lusers. --- 281 unchanged lines hidden (view full) --- 290 else if (ret == FAT_ENT_EOF) { 291 fat_fs_panic(sb, "%s: request beyond EOF (i_pos %lld)", 292 __FUNCTION__, MSDOS_I(inode)->i_pos); 293 return -EIO; 294 } 295 return dclus; 296} 297 | 1/* 2 * linux/fs/fat/cache.c 3 * 4 * Written 1992,1993 by Werner Almesberger 5 * 6 * Mar 1999. AV. Changed cache, so that it uses the starting cluster instead 7 * of inode number. 8 * May 1999. AV. Fixed the bogosity with FAT32 (read "FAT28"). Fscking lusers. --- 281 unchanged lines hidden (view full) --- 290 else if (ret == FAT_ENT_EOF) { 291 fat_fs_panic(sb, "%s: request beyond EOF (i_pos %lld)", 292 __FUNCTION__, MSDOS_I(inode)->i_pos); 293 return -EIO; 294 } 295 return dclus; 296} 297 |
298int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys) | 298int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys, 299 unsigned long *mapped_blocks) |
299{ 300 struct super_block *sb = inode->i_sb; 301 struct msdos_sb_info *sbi = MSDOS_SB(sb); 302 sector_t last_block; 303 int cluster, offset; 304 305 *phys = 0; | 300{ 301 struct super_block *sb = inode->i_sb; 302 struct msdos_sb_info *sbi = MSDOS_SB(sb); 303 sector_t last_block; 304 int cluster, offset; 305 306 *phys = 0; |
307 *mapped_blocks = 0; |
|
306 if ((sbi->fat_bits != 32) && (inode->i_ino == MSDOS_ROOT_INO)) { | 308 if ((sbi->fat_bits != 32) && (inode->i_ino == MSDOS_ROOT_INO)) { |
307 if (sector < (sbi->dir_entries >> sbi->dir_per_block_bits)) | 309 if (sector < (sbi->dir_entries >> sbi->dir_per_block_bits)) { |
308 *phys = sector + sbi->dir_start; | 310 *phys = sector + sbi->dir_start; |
311 *mapped_blocks = 1; 312 } |
|
309 return 0; 310 } 311 last_block = (MSDOS_I(inode)->mmu_private + (sb->s_blocksize - 1)) 312 >> sb->s_blocksize_bits; 313 if (sector >= last_block) 314 return 0; 315 316 cluster = sector >> (sbi->cluster_bits - sb->s_blocksize_bits); 317 offset = sector & (sbi->sec_per_clus - 1); 318 cluster = fat_bmap_cluster(inode, cluster); 319 if (cluster < 0) 320 return cluster; | 313 return 0; 314 } 315 last_block = (MSDOS_I(inode)->mmu_private + (sb->s_blocksize - 1)) 316 >> sb->s_blocksize_bits; 317 if (sector >= last_block) 318 return 0; 319 320 cluster = sector >> (sbi->cluster_bits - sb->s_blocksize_bits); 321 offset = sector & (sbi->sec_per_clus - 1); 322 cluster = fat_bmap_cluster(inode, cluster); 323 if (cluster < 0) 324 return cluster; |
321 else if (cluster) | 325 else if (cluster) { |
322 *phys = fat_clus_to_blknr(sbi, cluster) + offset; | 326 *phys = fat_clus_to_blknr(sbi, cluster) + offset; |
327 *mapped_blocks = sbi->sec_per_clus - offset; 328 if (*mapped_blocks > last_block - sector) 329 *mapped_blocks = last_block - sector; 330 } |
|
323 return 0; 324} | 331 return 0; 332} |