FreeCalypso > hg > freecalypso-sw
comparison ffstools/tiffs-rd/ls.c @ 238:0b13839f782c
tiffs IVA: lsino (non-specific) implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 26 Jan 2014 23:32:42 +0000 |
parents | 317936902be4 |
children | 28ea957a9d8a |
comparison
equal
deleted
inserted
replaced
237:317936902be4 | 238:0b13839f782c |
---|---|
172 } | 172 } |
173 for (; optind < argc; optind++) | 173 for (; optind < argc; optind++) |
174 ls_by_pathname(argv[optind]); | 174 ls_by_pathname(argv[optind]); |
175 exit(0); | 175 exit(0); |
176 } | 176 } |
177 | |
178 lsino_all() | |
179 { | |
180 int ino, last_ino = 0; | |
181 struct inode_info *inf; | |
182 char pathname[PATHNAME_BUF_SIZE], typech; | |
183 int pathstat; | |
184 char descend_str[8], sibling_str[8]; | |
185 | |
186 for (ino = 1; ino < inode_limit; ino++) { | |
187 if (!validate_inode(ino)) | |
188 continue; | |
189 if (ino != last_ino + 1) | |
190 printf("GAP in inode numbers\n"); | |
191 inf = inode_info[ino]; | |
192 pathstat = pathname_of_inode(ino, pathname); | |
193 if (pathstat < 0) | |
194 strcpy(pathname, "-nopath-"); | |
195 switch (inf->type) { | |
196 case 0x00: | |
197 typech = '~'; | |
198 break; | |
199 case 0xE1: | |
200 case 0xF1: | |
201 typech = 'f'; | |
202 break; | |
203 case 0xF2: | |
204 typech = 'd'; | |
205 break; | |
206 case 0xF3: | |
207 typech = 'l'; | |
208 break; | |
209 case 0xF4: | |
210 typech = '.'; | |
211 break; | |
212 default: | |
213 typech = '?'; | |
214 } | |
215 printf("#%04x %c %s\n", ino, typech, pathname); | |
216 if (inf->type && !(inf->type & 0x10)) | |
217 printf("\tread-only object\n"); | |
218 if (ino == root_inode) | |
219 printf("\tactive root\n"); | |
220 else if (inf->nparents < 1) | |
221 printf("\torphan\n"); | |
222 else if (inf->nparents > 1) | |
223 printf("\tparent: #%x (%d)\n", inf->parent, | |
224 inf->nparents); | |
225 else if (pathstat < 0 || verbose2) | |
226 printf("\tparent: #%x\n", inf->parent); | |
227 if (verbose2 > 1) { | |
228 if (inf->descend) | |
229 sprintf(descend_str, "#%x", inf->descend); | |
230 else | |
231 strcpy(descend_str, "null"); | |
232 if (inf->sibling) | |
233 sprintf(sibling_str, "#%x", inf->sibling); | |
234 else | |
235 strcpy(sibling_str, "null"); | |
236 printf("\tchild: %s, sibling: %s\n", | |
237 descend_str, sibling_str); | |
238 } | |
239 if (!inf->len) | |
240 printf("\treclaimed\n"); | |
241 last_ino = ino; | |
242 } | |
243 exit(0); | |
244 } | |
245 | |
246 cmd_lsino(argc, argv) | |
247 char **argv; | |
248 { | |
249 extern int optind; | |
250 int c; | |
251 | |
252 read_ffs_image(); | |
253 find_inode_block(); | |
254 alloc_inode_table(); | |
255 find_root_inode(); | |
256 treewalk_all(); | |
257 | |
258 optind = 0; | |
259 while ((c = getopt(argc, argv, "v")) != EOF) | |
260 switch (c) { | |
261 case 'v': | |
262 verbose2++; | |
263 continue; | |
264 default: | |
265 fprintf(stderr, "usage: lsino [-v[v]] [ino...]\n"); | |
266 exit(1); | |
267 } | |
268 if (optind >= argc) | |
269 return lsino_all(); | |
270 fprintf(stderr, "lsino of specific inodes not implemented yet\n"); | |
271 exit(1); | |
272 } |