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 Public
22 #include <linux/ext2_fs.h>
26 struct lookup_struct {
36 static int lookup_proc(struct ext2_dir_entry *dirent,
42 struct lookup_struct *ls = (struct lookup_struct *) private;
44 if (ls->len != dirent->name_len)
46 if (strncmp(ls->name, dirent->name, dirent->name_len))
48 *ls->inode = dirent->inode;
54 errcode_t ext2fs_lookup(ext2_filsys fs, ino_t dir, const char *name,
55 int namelen, char *buf, ino_t *inode)
58 struct lookup_struct ls;
60 EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
67 retval = ext2fs_dir_iterate(fs, dir, 0, buf, lookup_proc, &ls);
71 return (ls.found) ? 0 : ENOENT;