annotate mpffs/dbgls.c @ 34:95f61c3b430a

mpffs-rdutils: pathname search implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 30 Jun 2013 16:20:28 +0000
parents 660b0ea739f3
children e9c6d6615f32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * Whereas mpffs-ls is more user-oriented, mpffs-dbgls is structured a little
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 * different in order to provide a more low-level view of the FFS structure.
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/types.h>
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <ctype.h>
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdio.h>
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <string.h>
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <strings.h>
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include <stdlib.h>
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include <unistd.h>
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "types.h"
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "struct.h"
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 extern char *imgfile;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 extern u8 *image;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 extern struct objinfo root;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 extern int verbose;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 char workpath[512];
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 void
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 dump_extra_chunks(first_extra_chunk)
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 {
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 int ent;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 struct objinfo ch;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 struct chunkinfo chi;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 for (ent = first_extra_chunk; ent != 0xFFFF; ent = ch.descend) {
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 ch.entryno = ent;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 get_index_entry(&ch);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 if (ch.type != 0xF4) {
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 fprintf(stderr,
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 "file continuation object at index %x: type %02X != expected F4\n",
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 ent, ch.type);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 return;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 }
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 validate_chunk(&ch);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 printf(" #%x chunk addr=0x%x len=0x%x\n", ch.entryno,
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 ch.offset, ch.len);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 size_extra_chunk(&ch, &chi);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 printf(" extra chunk: %lu bytes at 0x%lx\n", (u_long) chi.len,
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 (u_long)(chi.start-image));
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 if (ch.sibling != 0xFFFF)
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 fprintf(stderr,
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 "warning: file continuation object (index %x) has a non-nil sibling pointer\n",
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 ent);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 }
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 }
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 void
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 dump_object(obj)
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 struct objinfo *obj;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 {
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 int typechar;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 struct chunkinfo chi;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 switch (obj->type) {
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 case 0xF2:
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 /* directory */
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 typechar = 'd';
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 break;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 case 0xF1:
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 /* regular file */
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 typechar = '-';
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 break;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 case 0xE1:
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 /* special .journal file */
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 typechar = 'j';
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 break;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 default:
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 /* unknown! */
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 typechar = 'U';
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 }
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 printf("%c %s\n", typechar, workpath);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 printf(" #%x chunk addr=0x%x len=0x%x\n", obj->entryno,
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 obj->offset, obj->len);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 switch (obj->type) {
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 case 0xF2:
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 /* directory */
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 return;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 case 0xF1:
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 /* regular file */
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 size_head_chunk(obj, &chi);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 printf(" head chunk: %lu bytes at 0x%lx\n", (u_long) chi.len,
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 (u_long)(chi.start-image));
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 dump_extra_chunks(obj->descend);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 return;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 default:
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 if (obj->descend != 0xFFFF)
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 printf(" unexpected descend pointer: %x\n",
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 obj->descend);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 }
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 }
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 dump_dir(firstent, path_prefix)
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 {
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 int ent;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 struct objinfo obj;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 for (ent = firstent; ent != 0xFFFF; ent = obj.sibling) {
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 obj.entryno = ent;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 get_index_entry(&obj);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 if (!obj.type) /* skip deleted objects w/o further validation */
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 continue;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 validate_chunk(&obj);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 validate_obj_name(&obj);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 if (path_prefix + strlen(obj.dataptr) + 2 > sizeof workpath) {
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 fprintf(stderr,
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 "handling object at index %x, name \"%s\": path buffer overflow\n",
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 obj.entryno, (char *)obj.dataptr);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 exit(1);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 }
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 sprintf(workpath + path_prefix, "/%s", (char *)obj.dataptr);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 dump_object(&obj);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 if (obj.type == 0xF2)
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 dump_dir(obj.descend, strlen(workpath));
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 }
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 }
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121
34
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
122 save_pathname_arg(pnarg)
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
123 char *pnarg;
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
124 {
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
125 if (*pnarg == '/')
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
126 pnarg++;
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
127 if (strlen(pnarg) + 2 > sizeof workpath) {
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
128 fprintf(stderr,
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
129 "error: specified pathname is too long (overflows internal buffer)\n");
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
130 exit(1);
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
131 }
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
132 sprintf(workpath, "/%s", pnarg);
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
133 }
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
134
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
135 dump_by_pathname(pnarg)
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
136 char *pnarg;
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
137 {
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
138 struct objinfo obj;
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
139
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
140 save_pathname_arg(pnarg);
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
141 obj.entryno = find_pathname(pnarg);
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
142 get_index_entry(&obj);
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
143 validate_chunk(&obj);
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
144 dump_object(&obj);
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
145 }
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
146
33
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 usage()
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 {
34
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
149 fprintf(stderr, "usage: mpffs-dbgls [options] ffs-image [pathname]\n");
33
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 exit(1);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 }
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 main(argc, argv)
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 char **argv;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 {
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 extern int optind;
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 parse_cmdline_options(argc, argv);
34
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
159 argc -= optind;
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
160 argv += optind;
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
161 if (argc < 1 || argc > 2)
33
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 usage();
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
163 verbose++;
34
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
164 imgfile = argv[0];
33
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
165 preliminaries();
34
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
166 if (argc == 1)
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
167 dump_dir(root.descend, 0);
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
168 else
95f61c3b430a mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 33
diff changeset
169 dump_by_pathname(argv[1]);
33
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
170 exit(0);
660b0ea739f3 mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
171 }