Skip to content

Commit 9318731

Browse files
Russell KingAl Viro
authored andcommitted
fs/adfs: newdir: merge adfs_dir_read() into adfs_f_read()
adfs_dir_read() is only called from adfs_f_read(), so merge it into that function. As new directories are always 2048 bytes in size, (which we rely on elsewhere) we can consolidate some of the code. Signed-off-by: Russell King <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 7a0e404 commit 9318731

File tree

1 file changed

+7
-26
lines changed

1 file changed

+7
-26
lines changed

fs/adfs/dir_f.c

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,16 @@ static int adfs_f_validate(struct adfs_dir *dir)
138138
}
139139

140140
/* Read and check that a directory is valid */
141-
static int adfs_dir_read(struct super_block *sb, u32 indaddr,
142-
unsigned int size, struct adfs_dir *dir)
141+
static int adfs_f_read(struct super_block *sb, u32 indaddr, unsigned int size,
142+
struct adfs_dir *dir)
143143
{
144144
const unsigned int blocksize_bits = sb->s_blocksize_bits;
145145
int ret;
146146

147-
/*
148-
* Directories which are not a multiple of 2048 bytes
149-
* are considered bad v2 [3.6]
150-
*/
151-
if (size & 2047)
152-
goto bad_dir;
147+
if (size && size != ADFS_NEWDIR_SIZE)
148+
return -EIO;
153149

154-
ret = adfs_dir_read_buffers(sb, indaddr, size, dir);
150+
ret = adfs_dir_read_buffers(sb, indaddr, ADFS_NEWDIR_SIZE, dir);
155151
if (ret)
156152
return ret;
157153

@@ -161,6 +157,8 @@ static int adfs_dir_read(struct super_block *sb, u32 indaddr,
161157
if (adfs_f_validate(dir))
162158
goto bad_dir;
163159

160+
dir->parent_id = adfs_readval(dir->newtail->dirparent, 3);
161+
164162
return 0;
165163

166164
bad_dir:
@@ -271,23 +269,6 @@ static int adfs_dir_find_entry(struct adfs_dir *dir, u32 indaddr)
271269
return ret;
272270
}
273271

274-
static int adfs_f_read(struct super_block *sb, u32 indaddr, unsigned int size,
275-
struct adfs_dir *dir)
276-
{
277-
int ret;
278-
279-
if (size != ADFS_NEWDIR_SIZE)
280-
return -EIO;
281-
282-
ret = adfs_dir_read(sb, indaddr, size, dir);
283-
if (ret)
284-
adfs_error(sb, "unable to read directory");
285-
else
286-
dir->parent_id = adfs_readval(dir->newtail->dirparent, 3);
287-
288-
return ret;
289-
}
290-
291272
static int
292273
adfs_f_setpos(struct adfs_dir *dir, unsigned int fpos)
293274
{

0 commit comments

Comments
 (0)