FreeCalypso > hg > freecalypso-sw
comparison ffstools/tiffs-rd/cat.c @ 241:c95efd27fb2e
tiffs catino implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 27 Jan 2014 02:59:45 +0000 |
parents | acedd4c88d2e |
children |
comparison
equal
deleted
inserted
replaced
240:acedd4c88d2e | 241:c95efd27fb2e |
---|---|
166 cat_chunk(&chi); | 166 cat_chunk(&chi); |
167 iterate_seg_file(headino, segment_cat_callback, 0L, 0, 0); | 167 iterate_seg_file(headino, segment_cat_callback, 0L, 0, 0); |
168 cat_finish(); | 168 cat_finish(); |
169 exit(0); | 169 exit(0); |
170 } | 170 } |
171 | |
172 cmd_catino(argc, argv) | |
173 char **argv; | |
174 { | |
175 extern int optind; | |
176 int c, headino; | |
177 struct inode_info *inf; | |
178 struct chunkinfo chi; | |
179 | |
180 optind = 0; | |
181 while ((c = getopt(argc, argv, "hv")) != EOF) | |
182 switch (c) { | |
183 case 'h': | |
184 cat_mode = 2; | |
185 continue; | |
186 case 'v': | |
187 cat_mode = 1; | |
188 continue; | |
189 default: | |
190 usage: fprintf(stderr, "usage: catino [-v|-h] ino\n"); | |
191 exit(1); | |
192 } | |
193 if (argc != optind + 1) | |
194 goto usage; | |
195 headino = strtoul(argv[optind], 0, 16); | |
196 | |
197 read_ffs_image(); | |
198 find_inode_block(); | |
199 alloc_inode_table(); | |
200 if (!validate_inode(headino)) { | |
201 fprintf(stderr, "catino: specified inode number is invalid\n"); | |
202 exit(1); | |
203 } | |
204 inf = inode_info[headino]; | |
205 switch (inf->type) { | |
206 case 0x00: | |
207 case 0xE1: | |
208 case 0xF1: | |
209 case 0xF3: | |
210 break; | |
211 case 0xF2: | |
212 fprintf(stderr, "error: the requested object is a directory\n"); | |
213 exit(1); | |
214 default: | |
215 fprintf(stderr, "error: unexpected object type %02X\n", | |
216 inf->type); | |
217 exit(1); | |
218 } | |
219 if (!inf->len) { | |
220 fprintf(stderr, "error: requested inode has been reclaimed\n"); | |
221 exit(1); | |
222 } | |
223 if (!validate_obj_name(headino, 0)) { | |
224 fprintf(stderr, | |
225 "error: no valid name at the beginning of the requested seghead chunk\n"); | |
226 exit(1); | |
227 } | |
228 size_head_chunk(inf, &chi); | |
229 cat_chunk(&chi); | |
230 iterate_seg_file(headino, segment_cat_callback, 0L, !inf->type, 0); | |
231 cat_finish(); | |
232 exit(0); | |
233 } |