aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2010-10-16 19:37:00 -0400
committerJan Kara <jack@suse.cz>2011-01-06 05:52:15 -0500
commit5026e90b86684bc878e4db0a8cd043fed769719c (patch)
treedca74ba7e855871158d8a58f3472503b4a5ec9ab /fs/ext3
parentf0cad89f5e8ef8b6d0c065115565524137e44f0b (diff)
ext3: Use search_dirblock() in ext3_dx_find_entry()
Use the search_dirblock() in ext3_dx_find_entry(). It makes the code easier to read, and it takes advantage of common code. It also saves 100 bytes or so of text space. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Cc: Brad Spengler <spender@grsecurity.net> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext3')
-rw-r--r--fs/ext3/namei.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index d093cbbe38b7..9cc0b2c9664f 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -975,12 +975,9 @@ static struct buffer_head * ext3_dx_find_entry(struct inode *dir,
975 struct super_block *sb = dir->i_sb; 975 struct super_block *sb = dir->i_sb;
976 struct dx_hash_info hinfo; 976 struct dx_hash_info hinfo;
977 struct dx_frame frames[2], *frame; 977 struct dx_frame frames[2], *frame;
978 struct ext3_dir_entry_2 *de, *top;
979 struct buffer_head *bh; 978 struct buffer_head *bh;
980 unsigned long block; 979 unsigned long block;
981 int retval; 980 int retval;
982 int namelen = entry->len;
983 const u8 *name = entry->name;
984 981
985 if (!(frame = dx_probe(entry, dir, &hinfo, frames, err))) 982 if (!(frame = dx_probe(entry, dir, &hinfo, frames, err)))
986 return NULL; 983 return NULL;
@@ -988,26 +985,20 @@ static struct buffer_head * ext3_dx_find_entry(struct inode *dir,
988 block = dx_get_block(frame->at); 985 block = dx_get_block(frame->at);
989 if (!(bh = ext3_bread (NULL,dir, block, 0, err))) 986 if (!(bh = ext3_bread (NULL,dir, block, 0, err)))
990 goto errout; 987 goto errout;
991 de = (struct ext3_dir_entry_2 *) bh->b_data;
992 top = (struct ext3_dir_entry_2 *) ((char *) de + sb->s_blocksize -
993 EXT3_DIR_REC_LEN(0));
994 for (; de < top; de = ext3_next_entry(de)) {
995 int off = (block << EXT3_BLOCK_SIZE_BITS(sb))
996 + ((char *) de - bh->b_data);
997
998 if (!ext3_check_dir_entry(__func__, dir, de, bh, off)) {
999 brelse(bh);
1000 *err = ERR_BAD_DX_DIR;
1001 goto errout;
1002 }
1003 988
1004 if (ext3_match(namelen, name, de)) { 989 retval = search_dirblock(bh, dir, entry,
1005 *res_dir = de; 990 block << EXT3_BLOCK_SIZE_BITS(sb),
1006 dx_release(frames); 991 res_dir);
1007 return bh; 992 if (retval == 1) {
1008 } 993 dx_release(frames);
994 return bh;
1009 } 995 }
1010 brelse (bh); 996 brelse(bh);
997 if (retval == -1) {
998 *err = ERR_BAD_DX_DIR;
999 goto errout;
1000 }
1001
1011 /* Check to see if we should continue to search */ 1002 /* Check to see if we should continue to search */
1012 retval = ext3_htree_next_block(dir, hinfo.hash, frame, 1003 retval = ext3_htree_next_block(dir, hinfo.hash, frame,
1013 frames, NULL); 1004 frames, NULL);