2 * lookup.c --- ext2fs directory lookup operations
4 * Copyright (C) 1993, 1994, 1994, 1995 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Library
8 * General Public License, version 2.
22 struct lookup_struct {
32 static int lookup_proc(struct ext2_dir_entry *dirent,
33 int offset EXT2FS_ATTR((unused)),
34 int blocksize EXT2FS_ATTR((unused)),
35 char *buf EXT2FS_ATTR((unused)),
38 struct lookup_struct *ls = (struct lookup_struct *) priv_data;
40 if (ls->len != ext2fs_dirent_name_len(dirent))
42 if (strncmp(ls->name, dirent->name, ext2fs_dirent_name_len(dirent)))
44 *ls->inode = dirent->inode;
50 errcode_t ext2fs_lookup(ext2_filsys fs, ext2_ino_t dir, const char *name,
51 int namelen, char *buf, ext2_ino_t *inode)
54 struct lookup_struct ls;
56 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
63 retval = ext2fs_dir_iterate(fs, dir, 0, buf, lookup_proc, &ls);
67 return (ls.found) ? 0 : EXT2_ET_FILE_NOT_FOUND;