FreeCalypso > hg > freecalypso-sw
view ffstools/tiffs-rd/tree.c @ 234:024042383a26
tiffs IVA: ls reports file sizes
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 26 Jan 2014 11:47:13 +0000 |
parents | ae9ff2d1e3da |
children | 317936902be4 |
line wrap: on
line source
/* * This C module implements operations on the tree level. */ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "types.h" #include "struct.h" #include "globals.h" #include "pathname.h" static void visible_walk_dir(pathbuf_start, pathbuf_ptr, dirino, depth, callback) char *pathbuf_start, *pathbuf_ptr; void (*callback)(); { int ndepth = depth + 1; int child; struct inode_info *inf; if (depth > MAX_DIR_NEST) { fprintf(stderr, "error: max dir nesting exceeded at inode #%x\n", dirino); return; } for (child = inode_info[dirino]->descend; child; child = inf->sibling) { if (!validate_inode(child)) { fprintf(stderr, "error: walk of visible tree hit invalid inode #%x\n", child); return; } inf = inode_info[child]; switch (inf->type) { case 0x00: /* walking the *visible* tree: skip deleted objects */ continue; case 0xF4: fprintf(stderr, "warning: directory #%x has child #%x of type segment (F4), skipping\n", dirino, child); continue; } if (!validate_obj_name(child, 0)) { fprintf(stderr, "visible tree walk error: no valid name for inode #%x\n", child); continue; } sprintf(pathbuf_ptr, "/%s", inf->dataptr); callback(pathbuf_start, child, ndepth); if (inf->type == 0xF2) visible_walk_dir(pathbuf_start, index(pathbuf_ptr, '\0'), child, ndepth, callback); } } traverse_visible_tree(callback) void (*callback)(); { char pathbuf[PATHNAME_BUF_SIZE]; visible_walk_dir(pathbuf, pathbuf, root_inode, 0, callback); }