annotate mpffs/xtr.c @ 56:fdfb57a1c5fe

Pirelli PCB tracing: voice band i/f, MCSI and MODEM UART
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 20 Oct 2013 04:49:28 +0000
parents 7ceab8bfacb3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module contains the main function and other code specific to mpffs-xtr
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/file.h>
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <ctype.h>
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdio.h>
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <string.h>
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <strings.h>
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include <stdlib.h>
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include <unistd.h>
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "types.h"
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 #include "struct.h"
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 extern char *imgfile;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 extern struct objinfo root;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 extern int verbose;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 extern u8 *find_end_of_chunk();
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 char workpath[512];
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 name_safe_for_extract(oi)
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 struct objinfo *oi;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 char *s;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 s = (char *)oi->dataptr;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 if (!isalnum(*s) && *s != '_')
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 return(0);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 for (s++; *s; s++)
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 if (!isalnum(*s) && *s != '_' && *s != '.')
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 return(0);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 return(1);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 void
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 dump_head_chunk(fd, ch)
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 struct objinfo *ch;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 u8 *endname, *endchunk;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 endname = (u8 *) index((char *)ch->dataptr, '\0') + 1;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 endchunk = find_end_of_chunk(ch);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 if (endchunk <= endname)
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 return;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 write(fd, endname, endchunk - endname);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 void
40
7ceab8bfacb3 mpffs-cat and mpffs-xtr converted to use the new extra chunk handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 36
diff changeset
52 dump_extra_chunk(ch, opaque)
36
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 struct objinfo *ch;
40
7ceab8bfacb3 mpffs-cat and mpffs-xtr converted to use the new extra chunk handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 36
diff changeset
54 u_long opaque;
36
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 {
40
7ceab8bfacb3 mpffs-cat and mpffs-xtr converted to use the new extra chunk handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 36
diff changeset
56 int fd = (int) opaque;
36
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 u8 *endchunk;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 endchunk = find_end_of_chunk(ch);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 write(fd, ch->dataptr, endchunk - ch->dataptr);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 extract_file(head)
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 struct objinfo *head;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 int fd;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 fd = open(workpath + 1, O_WRONLY|O_CREAT|O_TRUNC, 0666);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 if (fd < 0) {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 perror(workpath + 1);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 exit(1);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 dump_head_chunk(fd, head);
40
7ceab8bfacb3 mpffs-cat and mpffs-xtr converted to use the new extra chunk handling
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 36
diff changeset
74 iterate_extra_chunks(head->descend, dump_extra_chunk, (u_long) fd);
36
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 close(fd);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 dump_dir(firstent, path_prefix)
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 int ent;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 struct objinfo obj;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 for (ent = firstent; ent != 0xFFFF; ent = obj.sibling) {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 obj.entryno = ent;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 get_index_entry(&obj);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 if (!obj.type) /* skip deleted objects w/o further validation */
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 continue;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 validate_chunk(&obj);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 validate_obj_name(&obj);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 if (path_prefix + strlen(obj.dataptr) + 2 > sizeof workpath) {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 fprintf(stderr,
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 "handling object at index %x, name \"%s\": path buffer overflow\n",
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 obj.entryno, (char *)obj.dataptr);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 exit(1);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 sprintf(workpath + path_prefix, "/%s", (char *)obj.dataptr);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 switch (obj.type) {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 case 0xF2:
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 /* directory */
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 if (verbose)
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 printf("dir: %s\n", workpath);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 if (!name_safe_for_extract(&obj)) {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 fprintf(stderr,
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 "warning: directory name contains unsafe characters; subtree skipped\n");
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 continue;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 if (mkdir(workpath + 1, 0777) < 0) {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 perror(workpath + 1);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 exit(1);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 dump_dir(obj.descend, strlen(workpath));
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 continue;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 case 0xF1:
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 /* regular file */
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 if (verbose)
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 printf("file: %s\n", workpath);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 if (!name_safe_for_extract(&obj)) {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 fprintf(stderr,
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 "warning: file name contains unsafe characters; file skipped\n");
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 continue;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 extract_file(&obj);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 continue;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 case 0xE1:
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 /* special .journal file */
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 if (verbose)
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 printf("skipping E1 file: %s\n", workpath);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 continue;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 default:
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 fprintf(stderr,
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131 "warning: %s (index entry #%x): unexpected type %02X; skipping\n",
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 workpath, obj.entryno, obj.type);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 continue;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 usage()
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 fprintf(stderr, "usage: mpffs-xtr [options] ffs-image destdir\n");
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 exit(1);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 main(argc, argv)
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 char **argv;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 extern int optind;
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 parse_cmdline_options(argc, argv);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 if (argc - optind != 2)
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 usage();
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 imgfile = argv[optind];
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 preliminaries();
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 if (chdir(argv[optind+1]) < 0) {
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 perror(argv[optind+1]);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 exit(1);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 }
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 dump_dir(root.descend, 0);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 exit(0);
390be89892c4 mpffs-xtr ported over
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 }