4 struct inode
*ldir_ptr
, /* dir record parent */
5 char string
[NAME_MAX
], /* component to search for */
6 ino_t
*numb
/* pointer to new dir record */
9 * The search_dir function performs the operation of searching for the
10 * component ``string" in ldir_ptr. It returns the response and the
11 * number of the inode in numb.
16 * This function search a particular element (in string) in a inode and
20 if ((ldir_ptr
->i_stat
.st_mode
& S_IFMT
) != S_IFDIR
)
23 r
= read_directory(ldir_ptr
);
27 if (strcmp(".", string
) == 0) {
28 *numb
= ldir_ptr
->i_stat
.st_ino
;
32 /* Walk the directory listing. */
33 for (i
= 0; i
< ldir_ptr
->dir_size
; i
++) {
34 if (strcmp(string
, ldir_ptr
->dir_contents
[i
].name
) == 0) {
35 *numb
= ldir_ptr
->dir_contents
[i
].i_node
->i_stat
.st_ino
;
43 int fs_lookup(ino_t dir_nr
, char *name
, struct fsdriver_node
*node
,
46 /* Given a directory and a component of a path, look up the component
47 * in the directory, find the inode, open it, and return its details.
49 struct inode
*dirp
, *rip
;
53 /* Find the starting inode. */
54 if ((dirp
= get_inode(dir_nr
)) == NULL
)
57 /* Look up the directory entry. */
58 if ((r
= search_dir(dirp
, name
, &ino_nr
)) != OK
)
61 /* The component has been found in the directory. Get the inode. */
62 if ((rip
= open_inode(ino_nr
)) == NULL
)
63 return EIO
; /* FIXME: this could have multiple causes */
65 /* Return its details to the caller. */
66 node
->fn_ino_nr
= rip
->i_stat
.st_ino
;
67 node
->fn_mode
= rip
->i_stat
.st_mode
;
68 node
->fn_size
= rip
->i_stat
.st_size
;
69 node
->fn_uid
= rip
->i_stat
.st_uid
;
70 node
->fn_gid
= rip
->i_stat
.st_gid
;
71 node
->fn_dev
= rip
->i_stat
.st_rdev
;
73 *is_mountpt
= rip
->i_mountpoint
;