FreeCalypso > hg > freecalypso-sw
diff 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 |
line wrap: on
line diff
--- a/ffstools/tiffs-rd/tree.c Sun Jan 26 21:12:15 2014 +0000 +++ b/ffstools/tiffs-rd/tree.c Sun Jan 26 23:32:42 2014 +0000 @@ -165,3 +165,72 @@ } return(ino); } + +/* + * treewalk_all() walks the entire inode tree from the root down, without + * regard to object types, including deleted objects and even reclaimed ones. + * The output is the filling of the parent and nparents fields in the inode + * info array. + */ + +static void +treewalk_all_node(parent) +{ + int child; + struct inode_info *inf; + + for (child = inode_info[parent]->descend; child; child = inf->sibling) { + if (!validate_inode(child)) { + fprintf(stderr, + "error: walk of complete tree hit invalid inode #%x\n", + child); + return; + } + inf = inode_info[child]; + inf->parent = parent; + inf->nparents++; + if (inf->nparents >= inode_limit) { + fprintf(stderr, + "error: detected loop in inode tree at #%x, child of #%x\n", + child, parent); + return; + } + treewalk_all_node(child); + } +} + +treewalk_all() +{ + treewalk_all_node(root_inode); +} + +pathname_of_inode(ino, pnbuf) + char *pnbuf; +{ + int level; + char *revpath[MAX_DIR_NEST+1]; + struct inode_info *inf; + char *op; + + for (level = 0; ino != root_inode; ino = inf->parent) { + if (!validate_obj_name(ino, 0)) + return(-1); + inf = inode_info[ino]; + if (!inf->parent) + return(-1); + if (level > MAX_DIR_NEST) + return(-1); + revpath[level++] = (char *) inf->dataptr; + } + op = pnbuf; + if (!level) + *op++ = '/'; + while (level) { + level--; + *op++ = '/'; + strcpy(op, revpath[level]); + op = index(op, '\0'); + } + *op = '\0'; + return(0); +}