FreeCalypso > hg > freecalypso-reveng
diff pirollback/pathname.c @ 45:18472a2ccf55
pirollback: pathname reconstruction implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sat, 06 Jul 2013 22:06:38 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pirollback/pathname.c Sat Jul 06 22:06:38 2013 +0000 @@ -0,0 +1,53 @@ +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include "types.h" +#include "struct.h" +#include "pathname.h" + +extern struct inode_info inode[]; + +pathname_of_inode(ino, pnbuf) + char *pnbuf; +{ + int level, revpath[MAX_DIR_NEST]; + struct inode_info *inf; + char *op; + + for (level = 0; ino != 1; ino = inode[ino].parent) { + if (!inode[ino].parent) + return(-1); + if (level >= MAX_DIR_NEST) + return(-1); + revpath[level++] = ino; + } + op = pnbuf; + *op++ = '/'; + while (level) { + level--; + inf = inode + revpath[level]; + switch (inf->type) { + case 0xE1: + case 0xF1: + /* good only for the last component */ + if (!level) + break; + else + return(-1); + case 0xF2: + /* good for all components */ + break; + default: + /* bad */ + return(-1); + } + strcpy(op, inf->dataptr); + op += strlen(inf->dataptr); + if (inf->type == 0xF2) + *op++ = '/'; + } + *op = '\0'; + return(0); +}