annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
233
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This C module implements the ls command.
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <stdio.h>
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdlib.h>
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <string.h>
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <strings.h>
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include "types.h"
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include "struct.h"
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "globals.h"
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "pathname.h"
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 void
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 ls_callback(pathname, ino, depth)
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 char *pathname;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17 {
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 struct inode_info *inf = inode_info[ino];
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 char type;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 switch (inf->type) {
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 case 0xE1:
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 case 0xF1:
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 type = 'f';
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 break;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 case 0xF2:
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27 type = 'd';
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 break;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 case 0xF3:
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 type = 'l';
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 break;
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 default:
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 fprintf(stderr,
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 "BUG: bad inode byte %02X reached ls_callback()\n",
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 inf->type);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 exit(1);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 }
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 printf("%c %s\n", type, pathname);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 }
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 cmd_ls()
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 {
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 read_ffs_image();
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 find_inode_block();
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 alloc_inode_table();
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 find_root_inode();
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47 traverse_visible_tree(ls_callback);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 exit(0);
ae9ff2d1e3da tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 }