Remove building with NOCRYPTO option
[minix.git] / minix / fs / isofs / path.c
blobcd2ad25f1162796266200056329874cb75ff15ca
1 #include "inc.h"
3 static int search_dir(
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 */
7 ) {
8 /*
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.
13 int r, i;
16 * This function search a particular element (in string) in a inode and
17 * return its number.
20 if ((ldir_ptr->i_stat.st_mode & S_IFMT) != S_IFDIR)
21 return ENOTDIR;
23 r = read_directory(ldir_ptr);
24 if (r != OK)
25 return r;
27 if (strcmp(".", string) == 0) {
28 *numb = ldir_ptr->i_stat.st_ino;
29 return OK;
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;
36 return OK;
40 return ENOENT;
43 int fs_lookup(ino_t dir_nr, char *name, struct fsdriver_node *node,
44 int *is_mountpt)
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;
50 ino_t ino_nr;
51 int r;
53 /* Find the starting inode. */
54 if ((dirp = get_inode(dir_nr)) == NULL)
55 return EINVAL;
57 /* Look up the directory entry. */
58 if ((r = search_dir(dirp, name, &ino_nr)) != OK)
59 return r;
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;
75 return OK;