annotate pirollback/pathname.c @ 63:023d55d76b28

Pirelli PCB RE: another failed attempt at tracing the keypad connections
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Mon, 02 Dec 2013 08:55:38 +0000
parents 18472a2ccf55
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 #include <sys/types.h>
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 #include <stdio.h>
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 #include <stdlib.h>
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 #include <string.h>
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <strings.h>
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include "types.h"
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include "struct.h"
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include "pathname.h"
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 extern struct inode_info inode[];
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 pathname_of_inode(ino, pnbuf)
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 char *pnbuf;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 {
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 int level, revpath[MAX_DIR_NEST];
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 struct inode_info *inf;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 char *op;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 for (level = 0; ino != 1; ino = inode[ino].parent) {
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 if (!inode[ino].parent)
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 return(-1);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 if (level >= MAX_DIR_NEST)
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 return(-1);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 revpath[level++] = ino;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 }
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 op = pnbuf;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 *op++ = '/';
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 while (level) {
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 level--;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 inf = inode + revpath[level];
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 switch (inf->type) {
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 case 0xE1:
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 case 0xF1:
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 /* good only for the last component */
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 if (!level)
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 break;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 else
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 return(-1);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 case 0xF2:
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 /* good for all components */
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 break;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 default:
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 /* bad */
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 return(-1);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 }
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 strcpy(op, inf->dataptr);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 op += strlen(inf->dataptr);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 if (inf->type == 0xF2)
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 *op++ = '/';
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 }
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 *op = '\0';
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 return(0);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 }