annotate ffstools/tiffs-rd/tree.c @ 237:317936902be4

tiffs IVA: regular ls fully implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 26 Jan 2014 21:12:15 +0000
parents 024042383a26
children 0b13839f782c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
233
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This C module implements operations on the tree level.
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
234
024042383a26 tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 233
diff changeset
5 #include <sys/types.h>
233
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdlib.h>
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <string.h>
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <strings.h>
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "types.h"
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "struct.h"
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "globals.h"
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "pathname.h"
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 static void
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 visible_walk_dir(pathbuf_start, pathbuf_ptr, dirino, depth, callback)
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 char *pathbuf_start, *pathbuf_ptr;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 void (*callback)();
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 {
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 int ndepth = depth + 1;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 int child;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 struct inode_info *inf;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 if (depth > MAX_DIR_NEST) {
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 fprintf(stderr,
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 "error: max dir nesting exceeded at inode #%x\n",
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 dirino);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 return;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 }
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 for (child = inode_info[dirino]->descend; child; child = inf->sibling) {
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 if (!validate_inode(child)) {
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 fprintf(stderr,
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 "error: walk of visible tree hit invalid inode #%x\n",
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 child);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 return;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 }
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 inf = inode_info[child];
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 switch (inf->type) {
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 case 0x00:
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 /* walking the *visible* tree: skip deleted objects */
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 continue;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 case 0xF4:
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 fprintf(stderr,
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 "warning: directory #%x has child #%x of type segment (F4), skipping\n",
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 dirino, child);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 continue;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 }
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 if (!validate_obj_name(child, 0)) {
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 fprintf(stderr,
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 "visible tree walk error: no valid name for inode #%x\n",
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 child);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 continue;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 }
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 sprintf(pathbuf_ptr, "/%s", inf->dataptr);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 callback(pathbuf_start, child, ndepth);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 if (inf->type == 0xF2)
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 visible_walk_dir(pathbuf_start,
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 index(pathbuf_ptr, '\0'), child,
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 ndepth, callback);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 }
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 }
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 traverse_visible_tree(callback)
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 void (*callback)();
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 {
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 char pathbuf[PATHNAME_BUF_SIZE];
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 visible_walk_dir(pathbuf, pathbuf, root_inode, 0, callback);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 }
237
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
70
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
71 /*
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
72 * The following function iterates through the descendants of a directory
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
73 * object looking for a specific directory-member filename.
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
74 *
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
75 * Arguments:
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
76 * - inode # of the parent directory
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
77 * - inode # of the first descendant (descendant pointer from the dir object)
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
78 * - filename to search for
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
79 *
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
80 * Returns: inode # of the sought descendant object if found, 0 otherwise.
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
81 */
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
82 find_dir_member(dirino, first_descend, srchname)
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
83 char *srchname;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
84 {
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
85 int ino;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
86 struct inode_info *inf;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
87
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
88 for (ino = first_descend; ino; ino = inf->sibling) {
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
89 if (!validate_inode(ino)) {
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
90 fprintf(stderr,
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
91 "error: pathname search hit invalid inode #%x\n",
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
92 ino);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
93 exit(1);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
94 }
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
95 inf = inode_info[ino];
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
96 switch (inf->type) {
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
97 case 0x00:
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
98 /* walking the *visible* tree: skip deleted objects */
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
99 continue;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
100 case 0xF4:
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
101 fprintf(stderr,
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
102 "warning: directory #%x has child #%x of type segment (F4), skipping\n",
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
103 dirino, ino);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
104 continue;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
105 }
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
106 if (!validate_obj_name(ino, 0)) {
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
107 fprintf(stderr,
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
108 "visible tree walk error: no valid name for inode #%x\n",
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
109 ino);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
110 continue;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
111 }
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
112 if (!strcmp(inf->dataptr, srchname))
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
113 return(ino);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
114 }
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
115 return(0);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
116 }
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
117
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
118 /*
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
119 * The following function searches for a pathname from the root down.
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
120 * Returns the inode # if found, otherwise exits with an error message
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
121 * indicating which step failed.
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
122 *
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
123 * Warning: the pathname in the argument buffer will be destroyed:
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
124 * 0s put in place of the slashes.
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
125 */
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
126 find_pathname(pathname)
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
127 char *pathname;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
128 {
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
129 char *cur, *next;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
130 int ino;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
131 struct inode_info *inf;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
132
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
133 cur = pathname;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
134 if (*cur == '/')
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
135 cur++;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
136 else {
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
137 fprintf(stderr,
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
138 "bad pathname \"%s\": TIFFS pathnames must be absolute\n",
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
139 pathname);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
140 exit(1);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
141 }
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
142 for (ino = root_inode; cur; cur = next) {
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
143 if (!*cur)
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
144 break;
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
145 next = index(cur, '/');
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
146 if (next == cur) {
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
147 fprintf(stderr,
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
148 "malformed pathname: multiple adjacent slashes\n");
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
149 exit(1);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
150 }
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
151 if (next)
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
152 *next++ = '\0';
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
153 inf = inode_info[ino];
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
154 if (inf->type != 0xF2) {
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
155 fprintf(stderr,
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
156 "pathname search error: encountered a non-directory\n");
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
157 exit(1);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
158 }
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
159 ino = find_dir_member(ino, inf->descend, cur);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
160 if (!ino) {
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
161 fprintf(stderr,
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
162 "pathname search error: component name not found\n");
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
163 exit(1);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
164 }
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
165 }
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
166 return(ino);
317936902be4 tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 234
diff changeset
167 }