FreeCalypso > hg > freecalypso-sw
comparison ffstools/tiffs-rd/tree.c @ 233:ae9ff2d1e3da
tiffs IVA: basic ls integrated
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 26 Jan 2014 10:54:42 +0000 |
parents | |
children | 024042383a26 |
comparison
equal
deleted
inserted
replaced
232:73372cfdaf7f | 233:ae9ff2d1e3da |
---|---|
1 /* | |
2 * This C module implements operations on the tree level. | |
3 */ | |
4 | |
5 #include <stdio.h> | |
6 #include <stdlib.h> | |
7 #include <string.h> | |
8 #include <strings.h> | |
9 #include "types.h" | |
10 #include "struct.h" | |
11 #include "globals.h" | |
12 #include "pathname.h" | |
13 | |
14 static void | |
15 visible_walk_dir(pathbuf_start, pathbuf_ptr, dirino, depth, callback) | |
16 char *pathbuf_start, *pathbuf_ptr; | |
17 void (*callback)(); | |
18 { | |
19 int ndepth = depth + 1; | |
20 int child; | |
21 struct inode_info *inf; | |
22 | |
23 if (depth > MAX_DIR_NEST) { | |
24 fprintf(stderr, | |
25 "error: max dir nesting exceeded at inode #%x\n", | |
26 dirino); | |
27 return; | |
28 } | |
29 for (child = inode_info[dirino]->descend; child; child = inf->sibling) { | |
30 if (!validate_inode(child)) { | |
31 fprintf(stderr, | |
32 "error: walk of visible tree hit invalid inode #%x\n", | |
33 child); | |
34 return; | |
35 } | |
36 inf = inode_info[child]; | |
37 switch (inf->type) { | |
38 case 0x00: | |
39 /* walking the *visible* tree: skip deleted objects */ | |
40 continue; | |
41 case 0xF4: | |
42 fprintf(stderr, | |
43 "warning: directory #%x has child #%x of type segment (F4), skipping\n", | |
44 dirino, child); | |
45 continue; | |
46 } | |
47 if (!validate_obj_name(child, 0)) { | |
48 fprintf(stderr, | |
49 "visible tree walk error: no valid name for inode #%x\n", | |
50 child); | |
51 continue; | |
52 } | |
53 sprintf(pathbuf_ptr, "/%s", inf->dataptr); | |
54 callback(pathbuf_start, child, ndepth); | |
55 if (inf->type == 0xF2) | |
56 visible_walk_dir(pathbuf_start, | |
57 index(pathbuf_ptr, '\0'), child, | |
58 ndepth, callback); | |
59 } | |
60 } | |
61 | |
62 traverse_visible_tree(callback) | |
63 void (*callback)(); | |
64 { | |
65 char pathbuf[PATHNAME_BUF_SIZE]; | |
66 | |
67 visible_walk_dir(pathbuf, pathbuf, root_inode, 0, callback); | |
68 } |