FreeCalypso > hg > freecalypso-reveng
comparison 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 |
comparison
equal
deleted
inserted
replaced
44:074237879eca | 45:18472a2ccf55 |
---|---|
1 #include <sys/types.h> | |
2 #include <stdio.h> | |
3 #include <stdlib.h> | |
4 #include <string.h> | |
5 #include <strings.h> | |
6 #include "types.h" | |
7 #include "struct.h" | |
8 #include "pathname.h" | |
9 | |
10 extern struct inode_info inode[]; | |
11 | |
12 pathname_of_inode(ino, pnbuf) | |
13 char *pnbuf; | |
14 { | |
15 int level, revpath[MAX_DIR_NEST]; | |
16 struct inode_info *inf; | |
17 char *op; | |
18 | |
19 for (level = 0; ino != 1; ino = inode[ino].parent) { | |
20 if (!inode[ino].parent) | |
21 return(-1); | |
22 if (level >= MAX_DIR_NEST) | |
23 return(-1); | |
24 revpath[level++] = ino; | |
25 } | |
26 op = pnbuf; | |
27 *op++ = '/'; | |
28 while (level) { | |
29 level--; | |
30 inf = inode + revpath[level]; | |
31 switch (inf->type) { | |
32 case 0xE1: | |
33 case 0xF1: | |
34 /* good only for the last component */ | |
35 if (!level) | |
36 break; | |
37 else | |
38 return(-1); | |
39 case 0xF2: | |
40 /* good for all components */ | |
41 break; | |
42 default: | |
43 /* bad */ | |
44 return(-1); | |
45 } | |
46 strcpy(op, inf->dataptr); | |
47 op += strlen(inf->dataptr); | |
48 if (inf->type == 0xF2) | |
49 *op++ = '/'; | |
50 } | |
51 *op = '\0'; | |
52 return(0); | |
53 } |