diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2019-12-09 11:09:35 +0000 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2020-01-20 20:12:41 -0500 |
commit | 419a6e5e82ca0bdba0cc3624d969b65ae49d959b (patch) | |
tree | 2571e9fe0242dc1517f926097e52d17e67b280c6 /fs/adfs/dir_f.c | |
parent | a317120bf7f8306b594ee650ee14f08a0e599602 (diff) | |
download | linux-419a6e5e82ca0bdba0cc3624d969b65ae49d959b.tar.bz2 |
fs/adfs: dir: add generic directory reading
Both directory formats code the mechanics of fetching the directory
buffers using their own implementations. Consolidate these into one
implementation.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/adfs/dir_f.c')
-rw-r--r-- | fs/adfs/dir_f.c | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/fs/adfs/dir_f.c b/fs/adfs/dir_f.c index 3c3b423577d2..027ee714f42b 100644 --- a/fs/adfs/dir_f.c +++ b/fs/adfs/dir_f.c @@ -126,7 +126,7 @@ static int adfs_dir_read(struct super_block *sb, u32 indaddr, unsigned int size, struct adfs_dir *dir) { const unsigned int blocksize_bits = sb->s_blocksize_bits; - int blk; + int ret; /* * Directories which are not a multiple of 2048 bytes @@ -135,24 +135,9 @@ static int adfs_dir_read(struct super_block *sb, u32 indaddr, if (size & 2047) goto bad_dir; - size >>= blocksize_bits; - - for (blk = 0; blk < size; blk++) { - int phys; - - phys = __adfs_block_map(sb, indaddr, blk); - if (!phys) { - adfs_error(sb, "dir %06x has a hole at offset %d", - indaddr, blk); - goto release_buffers; - } - - dir->bh[blk] = sb_bread(sb, phys); - if (!dir->bh[blk]) - goto release_buffers; - - dir->nr_buffers += 1; - } + ret = adfs_dir_read_buffers(sb, indaddr, size, dir); + if (ret) + return ret; memcpy(&dir->dirhead, bufoff(dir->bh, 0), sizeof(dir->dirhead)); memcpy(&dir->dirtail, bufoff(dir->bh, 2007), sizeof(dir->dirtail)); @@ -172,7 +157,6 @@ static int adfs_dir_read(struct super_block *sb, u32 indaddr, bad_dir: adfs_error(sb, "dir %06x is corrupted", indaddr); -release_buffers: adfs_dir_relse(dir); return -EIO; |