FreeCalypso > hg > freecalypso-sw
comparison target-utils/libtiffs/basicfind.c @ 224:2900fe603f8a
beginning of MPFFS->TIFFS naming convention change
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 12 Jan 2014 07:59:00 +0000 |
parents | target-utils/libmpffs/basicfind.c@ac310ee73788 |
children |
comparison
equal
deleted
inserted
replaced
223:0848c7f419fd | 224:2900fe603f8a |
---|---|
1 #include <sys/types.h> | |
2 #include "types.h" | |
3 #include "struct.h" | |
4 #include "globals.h" | |
5 #include "macros.h" | |
6 | |
7 extern char *index(); | |
8 | |
9 static | |
10 find_named_child(start, seekname) | |
11 char *seekname; | |
12 { | |
13 int ino; | |
14 struct inode *irec; | |
15 | |
16 for (ino = start; ino != 0xFFFF; ino = irec->sibling) { | |
17 irec = mpffs_active_index + ino; | |
18 if (!irec->type) | |
19 continue; | |
20 if (!strcmp(inode_to_dataptr(irec), seekname)) | |
21 return(ino); | |
22 } | |
23 return(0); | |
24 } | |
25 | |
26 mpffs_pathname_to_inode(pathname) | |
27 char *pathname; | |
28 { | |
29 int ino, stat; | |
30 struct inode *irec; | |
31 char *cur, *next; | |
32 | |
33 stat = mpffs_init(); | |
34 if (stat < 0) | |
35 return(stat); | |
36 cur = pathname; | |
37 if (*cur == '/') | |
38 cur++; | |
39 for (ino = mpffs_root_ino; cur; cur = next) { | |
40 if (!*cur) | |
41 break; | |
42 next = index(cur, '/'); | |
43 if (next == cur) { | |
44 printf("malformed pathname: multiple adjacent slashes\n"); | |
45 return(-1); | |
46 } | |
47 if (next) | |
48 *next++ = '\0'; | |
49 irec = mpffs_active_index + ino; | |
50 if (irec->type != OBJTYPE_DIR) { | |
51 printf("Error: non-terminal non-directory\n"); | |
52 if (next) | |
53 next[-1] = '/'; | |
54 return(-1); | |
55 } | |
56 ino = find_named_child(irec->descend, cur); | |
57 if (next) | |
58 next[-1] = '/'; | |
59 if (!ino) { | |
60 printf("Error: pathname component not found\n"); | |
61 return(-1); | |
62 } | |
63 } | |
64 return(ino); | |
65 } |