Commit 54f6d887 authored by Hirofumi Ogawa's avatar Hirofumi Ogawa Committed by Linus Torvalds

[PATCH] use new fat_get_cluster (8/11)

This uses the new fat_get_cluster() in fat_bmap_cluster().  Another part
removes an unneeded error check of fat_get_entry() by using
fat_get_cluster().
parent 3e0e362b
......@@ -332,28 +332,20 @@ int fat_get_cluster(struct inode *inode, int cluster, int *fclus, int *dclus)
static int fat_bmap_cluster(struct inode *inode, int cluster)
{
struct super_block *sb = inode->i_sb;
int nr,count;
int ret, fclus, dclus;
if (!(nr = MSDOS_I(inode)->i_start)) return 0;
if (!cluster) return nr;
count = 0;
for (fat_cache_lookup(inode, cluster, &count, &nr);
count < cluster;
count++) {
nr = fat_access(sb, nr, -1);
if (nr == FAT_ENT_EOF) {
fat_fs_panic(sb, "%s: request beyond EOF (ino %lu)",
__FUNCTION__, inode->i_ino);
return -EIO;
} else if (nr == FAT_ENT_FREE) {
fat_fs_panic(sb, "%s: invalid cluster chain (ino %lu)",
__FUNCTION__, inode->i_ino);
if (MSDOS_I(inode)->i_start == 0)
return 0;
ret = fat_get_cluster(inode, cluster, &fclus, &dclus);
if (ret < 0)
return ret;
else if (ret == FAT_ENT_EOF) {
fat_fs_panic(sb, "%s: request beyond EOF (i_pos %llu)",
__FUNCTION__, MSDOS_I(inode)->i_pos);
return -EIO;
} else if (nr < 0)
return nr;
}
fat_cache_add(inode, cluster, nr);
return nr;
return dclus;
}
int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys)
......
......@@ -330,15 +330,7 @@ static int fat_get_short_entry(struct inode *dir, loff_t *pos,
struct buffer_head **bh,
struct msdos_dir_entry **de, loff_t *i_pos)
{
struct super_block *sb = dir->i_sb;
while (fat_get_entry(dir, pos, bh, de, i_pos) >= 0) {
if (*pos >= FAT_MAX_DIR_SIZE) {
fat_fs_panic(sb, "Directory %llu: "
"exceeded the maximum size of directory",
MSDOS_I(dir)->i_pos);
return -EIO;
}
/* free entry or long name entry or volume label */
if (!IS_FREE((*de)->name) && !((*de)->attr & ATTR_VOLUME))
return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment