comparison ffstools/tiffs-rd/tree.c @ 238:0b13839f782c

tiffs IVA: lsino (non-specific) implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 26 Jan 2014 23:32:42 +0000
parents 317936902be4
children 190121a34b3b
comparison
equal deleted inserted replaced
237:317936902be4 238:0b13839f782c
163 exit(1); 163 exit(1);
164 } 164 }
165 } 165 }
166 return(ino); 166 return(ino);
167 } 167 }
168
169 /*
170 * treewalk_all() walks the entire inode tree from the root down, without
171 * regard to object types, including deleted objects and even reclaimed ones.
172 * The output is the filling of the parent and nparents fields in the inode
173 * info array.
174 */
175
176 static void
177 treewalk_all_node(parent)
178 {
179 int child;
180 struct inode_info *inf;
181
182 for (child = inode_info[parent]->descend; child; child = inf->sibling) {
183 if (!validate_inode(child)) {
184 fprintf(stderr,
185 "error: walk of complete tree hit invalid inode #%x\n",
186 child);
187 return;
188 }
189 inf = inode_info[child];
190 inf->parent = parent;
191 inf->nparents++;
192 if (inf->nparents >= inode_limit) {
193 fprintf(stderr,
194 "error: detected loop in inode tree at #%x, child of #%x\n",
195 child, parent);
196 return;
197 }
198 treewalk_all_node(child);
199 }
200 }
201
202 treewalk_all()
203 {
204 treewalk_all_node(root_inode);
205 }
206
207 pathname_of_inode(ino, pnbuf)
208 char *pnbuf;
209 {
210 int level;
211 char *revpath[MAX_DIR_NEST+1];
212 struct inode_info *inf;
213 char *op;
214
215 for (level = 0; ino != root_inode; ino = inf->parent) {
216 if (!validate_obj_name(ino, 0))
217 return(-1);
218 inf = inode_info[ino];
219 if (!inf->parent)
220 return(-1);
221 if (level > MAX_DIR_NEST)
222 return(-1);
223 revpath[level++] = (char *) inf->dataptr;
224 }
225 op = pnbuf;
226 if (!level)
227 *op++ = '/';
228 while (level) {
229 level--;
230 *op++ = '/';
231 strcpy(op, revpath[level]);
232 op = index(op, '\0');
233 }
234 *op = '\0';
235 return(0);
236 }