FreeCalypso > hg > freecalypso-reveng
annotate mpffs/dbgls.c @ 342:6ff231195905
fluid-mnf/serial.[ch]: beginning of Linux port
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 13 Mar 2020 05:39:37 +0000 |
parents | e9c6d6615f32 |
children |
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) { |
38
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
31 loop: ch.entryno = ent; |
33
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 get_index_entry(&ch); |
38
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
33 switch (ch.type) { |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
34 case 0xF4: |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
35 validate_chunk(&ch); |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
36 printf(" #%x chunk addr=0x%x len=0x%x\n", ch.entryno, |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
37 ch.offset, ch.len); |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
38 size_extra_chunk(&ch, &chi); |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
39 printf(" extra chunk: %lu bytes at 0x%lx\n", |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
40 (u_long) chi.len, (u_long)(chi.start-image)); |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
41 break; |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
42 case 0x00: |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
43 printf(" #%x marked as deleted\n", ch.entryno); |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
44 if (ch.sibling == 0xFFFF) { |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
45 printf(" nil sibling pointer!\n"); |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
46 break; |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
47 } |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
48 ent = ch.sibling; |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
49 printf(" relocated to #%x\n", ent); |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
50 goto loop; |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
51 default: |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
52 printf( |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
53 " file continuation object at index %x: unexpected type %02X\n", |
33
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 ent, ch.type); |
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 if (ch.sibling != 0xFFFF) |
38
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
57 printf( |
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
58 " file continuation object (index %x) has a non-nil sibling pointer\n", |
33
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 ent); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 } |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 } |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 void |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 dump_object(obj) |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 struct objinfo *obj; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 { |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 int typechar; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 struct chunkinfo chi; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 switch (obj->type) { |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 case 0xF2: |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 /* directory */ |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 typechar = 'd'; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 break; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 case 0xF1: |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 /* regular file */ |
38
e9c6d6615f32
mpffs-dbgls: reworked for the new understanding of relocated chunks
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
34
diff
changeset
|
77 typechar = 'f'; |
33
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 break; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 case 0xE1: |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 /* special .journal file */ |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 typechar = 'j'; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 break; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 default: |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 /* unknown! */ |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 typechar = 'U'; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 } |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 printf("%c %s\n", typechar, workpath); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 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
|
89 obj->offset, obj->len); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 switch (obj->type) { |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 case 0xF2: |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 /* directory */ |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 return; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 case 0xF1: |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 /* regular file */ |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 size_head_chunk(obj, &chi); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 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
|
98 (u_long)(chi.start-image)); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 dump_extra_chunks(obj->descend); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 return; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 default: |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 if (obj->descend != 0xFFFF) |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 printf(" unexpected descend pointer: %x\n", |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 obj->descend); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 } |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 } |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 dump_dir(firstent, path_prefix) |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 { |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 int ent; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 struct objinfo obj; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 for (ent = firstent; ent != 0xFFFF; ent = obj.sibling) { |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 obj.entryno = ent; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 get_index_entry(&obj); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 if (!obj.type) /* skip deleted objects w/o further validation */ |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 continue; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 validate_chunk(&obj); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 validate_obj_name(&obj); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 if (path_prefix + strlen(obj.dataptr) + 2 > sizeof workpath) { |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 fprintf(stderr, |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 "handling object at index %x, name \"%s\": path buffer overflow\n", |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 obj.entryno, (char *)obj.dataptr); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 exit(1); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 } |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 sprintf(workpath + path_prefix, "/%s", (char *)obj.dataptr); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 dump_object(&obj); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 if (obj.type == 0xF2) |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 dump_dir(obj.descend, strlen(workpath)); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 } |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 } |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 |
34
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
133 save_pathname_arg(pnarg) |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
134 char *pnarg; |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
135 { |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
136 if (*pnarg == '/') |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
137 pnarg++; |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
138 if (strlen(pnarg) + 2 > sizeof workpath) { |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
139 fprintf(stderr, |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
140 "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
|
141 exit(1); |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
142 } |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
143 sprintf(workpath, "/%s", pnarg); |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
144 } |
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 dump_by_pathname(pnarg) |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
147 char *pnarg; |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
148 { |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
149 struct objinfo obj; |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
150 |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
151 save_pathname_arg(pnarg); |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
152 obj.entryno = find_pathname(pnarg); |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
153 get_index_entry(&obj); |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
154 validate_chunk(&obj); |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
155 dump_object(&obj); |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
156 } |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
157 |
33
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 usage() |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 { |
34
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
160 fprintf(stderr, "usage: mpffs-dbgls [options] ffs-image [pathname]\n"); |
33
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
161 exit(1); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
162 } |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
164 main(argc, argv) |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 char **argv; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
166 { |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 extern int optind; |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 parse_cmdline_options(argc, argv); |
34
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
170 argc -= optind; |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
171 argv += optind; |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
172 if (argc < 1 || argc > 2) |
33
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
173 usage(); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 verbose++; |
34
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
175 imgfile = argv[0]; |
33
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
176 preliminaries(); |
34
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
177 if (argc == 1) |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
178 dump_dir(root.descend, 0); |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
179 else |
95f61c3b430a
mpffs-rdutils: pathname search implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
33
diff
changeset
|
180 dump_by_pathname(argv[1]); |
33
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
181 exit(0); |
660b0ea739f3
mpffs-dbgls implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 } |