comparison ffstools/tiffs-rd/ls.c @ 233:ae9ff2d1e3da

tiffs IVA: basic ls integrated
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 26 Jan 2014 10:54:42 +0000
parents
children 024042383a26
comparison
equal deleted inserted replaced
232:73372cfdaf7f 233:ae9ff2d1e3da
1 /*
2 * This C module implements the ls command.
3 */
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <strings.h>
9 #include "types.h"
10 #include "struct.h"
11 #include "globals.h"
12 #include "pathname.h"
13
14 void
15 ls_callback(pathname, ino, depth)
16 char *pathname;
17 {
18 struct inode_info *inf = inode_info[ino];
19 char type;
20
21 switch (inf->type) {
22 case 0xE1:
23 case 0xF1:
24 type = 'f';
25 break;
26 case 0xF2:
27 type = 'd';
28 break;
29 case 0xF3:
30 type = 'l';
31 break;
32 default:
33 fprintf(stderr,
34 "BUG: bad inode byte %02X reached ls_callback()\n",
35 inf->type);
36 exit(1);
37 }
38 printf("%c %s\n", type, pathname);
39 }
40
41 cmd_ls()
42 {
43 read_ffs_image();
44 find_inode_block();
45 alloc_inode_table();
46 find_root_inode();
47 traverse_visible_tree(ls_callback);
48 exit(0);
49 }