annotate pirollback/inopath.c @ 229:84a4f6ef2d28

pirchgdbg: complete enough for first test
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 19 Dec 2017 04:02:32 +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 <stdio.h>
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 #include <stdlib.h>
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 #include "pathname.h"
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 extern char *imgfile;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 extern int last_inode;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 main(argc, argv)
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 char **argv;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 {
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 int ino;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 char *strtoul_endp;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 char pathname[PATHNAME_BUF_SIZE];
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 if (argc != 3) {
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 usage: fprintf(stderr, "usage: %s ffs-image inode\n", argv[0]);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 exit(1);
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 imgfile = argv[1];
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 ino = strtoul(argv[2], &strtoul_endp, 16);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 if (!argv[2][0] || *strtoul_endp)
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 goto usage;
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 read_img_file();
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 read_inodes();
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 if (ino < 1 || ino > last_inode) {
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 fprintf(stderr, "%s: bad inode number specified\n", argv[0]);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 exit(1);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 }
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 walk_tree();
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 check_object_names();
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 if (pathname_of_inode(ino, pathname) < 0) {
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 fprintf(stderr, "unable to get the pathname\n");
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 exit(1);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 }
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 printf("%s\n", pathname);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 exit(0);
18472a2ccf55 pirollback: pathname reconstruction implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 }