FreeCalypso > hg > freecalypso-sw
annotate ffstools/tiffs-rd/ls.c @ 240:acedd4c88d2e
tiffs cat command implemented
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 27 Jan 2014 02:32:46 +0000 |
parents | 28ea957a9d8a |
children | 10afa4d39a7b |
rev | line source |
---|---|
233
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
240
acedd4c88d2e
tiffs cat command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
239
diff
changeset
|
2 * This C module implements the ls and lsino commands. |
233
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 |
234
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
5 #include <sys/types.h> |
233
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdlib.h> |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <string.h> |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <strings.h> |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "types.h" |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "struct.h" |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "globals.h" |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "pathname.h" |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
234
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
15 static void |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
16 segment_size_callback(inf, opaque) |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
17 struct inode_info *inf; |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
18 u_long opaque; |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
19 { |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
20 size_t *accump = (size_t *) opaque; |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
21 struct chunkinfo chi; |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
22 |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
23 size_extra_chunk(inf, &chi); |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
24 *accump += chi.len; |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
25 } |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
26 |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
27 size_t |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
28 get_file_size(seghead_ino, deleted) |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
29 { |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
30 struct chunkinfo chi; |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
31 size_t accum; |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
32 |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
33 size_head_chunk(inode_info[seghead_ino], &chi); |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
34 accum = chi.len; |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
35 iterate_seg_file(seghead_ino, segment_size_callback, (u_long) &accum, |
237
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
36 deleted, 0); |
234
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
37 return(accum); |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
38 } |
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
39 |
236
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
40 static void |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
41 segment_ls_callback(inf, opaque) |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
42 struct inode_info *inf; |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
43 u_long opaque; |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
44 { |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
45 struct chunkinfo chi; |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
46 |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
47 size_extra_chunk(inf, &chi); |
237
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
48 if (verbose2 > 1) |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
49 printf("seg #%04x @%08x length=%lu\n", inf->ino, inf->offset, |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
50 (u_long) chi.len); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
51 else |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
52 printf("seg #%04x length=%lu\n", inf->ino, (u_long) chi.len); |
236
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
53 } |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
54 |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
55 ls_seg_file(seghead_ino, deleted) |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
56 { |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
57 struct inode_info *inf = inode_info[seghead_ino]; |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
58 struct chunkinfo chi; |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
59 |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
60 size_head_chunk(inf, &chi); |
237
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
61 printf("%lu bytes in seghead", (u_long) chi.len); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
62 if (verbose2 > 1) |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
63 printf(", starting at offset %lx", |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
64 (u_long)(inf->byte_after_name - image)); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
65 putchar('\n'); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
66 iterate_seg_file(seghead_ino, segment_ls_callback, 0L, deleted, |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
67 verbose2 > 1); |
236
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
68 } |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
69 |
233
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 void |
237
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
71 ls_tree_callback(pathname, ino, depth) |
233
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 char *pathname; |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 { |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 struct inode_info *inf = inode_info[ino]; |
234
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
75 u_long size; |
235
e17bb8818318
tiffs ls: show read-only file flag
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
234
diff
changeset
|
76 char readonly; |
233
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 |
235
e17bb8818318
tiffs ls: show read-only file flag
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
234
diff
changeset
|
78 if (inf->type & 0x10) |
e17bb8818318
tiffs ls: show read-only file flag
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
234
diff
changeset
|
79 readonly = ' '; |
e17bb8818318
tiffs ls: show read-only file flag
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
234
diff
changeset
|
80 else |
e17bb8818318
tiffs ls: show read-only file flag
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
234
diff
changeset
|
81 readonly = 'r'; |
233
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 switch (inf->type) { |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 case 0xE1: |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 case 0xF1: |
234
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
85 size = get_file_size(ino, 0); |
235
e17bb8818318
tiffs ls: show read-only file flag
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
234
diff
changeset
|
86 printf("f%c %7lu %s\n", readonly, size, pathname); |
236
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
87 if (verbose2) |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
88 ls_seg_file(ino, 0); |
234
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
89 return; |
235
e17bb8818318
tiffs ls: show read-only file flag
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
234
diff
changeset
|
90 case 0xE2: |
233
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 case 0xF2: |
235
e17bb8818318
tiffs ls: show read-only file flag
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
234
diff
changeset
|
92 printf("d%c %s\n", readonly, pathname); |
234
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
93 return; |
235
e17bb8818318
tiffs ls: show read-only file flag
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
234
diff
changeset
|
94 case 0xE3: |
233
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 case 0xF3: |
235
e17bb8818318
tiffs ls: show read-only file flag
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
234
diff
changeset
|
96 printf("l%c %s\n", readonly, pathname); |
234
024042383a26
tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
233
diff
changeset
|
97 return; |
233
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 default: |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 fprintf(stderr, |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 "BUG: bad inode byte %02X reached ls_callback()\n", |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 inf->type); |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 exit(1); |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 } |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 } |
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 |
237
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
106 ls_by_pathname(pathname) |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
107 char *pathname; |
233
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 { |
237
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
109 int ino; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
110 struct inode_info *inf; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
111 char *type; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
112 |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
113 printf("%s\n", pathname); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
114 ino = find_pathname(pathname); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
115 printf("inode #%x\n", ino); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
116 inf = inode_info[ino]; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
117 switch (inf->type) { |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
118 case 0xE1: |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
119 type = "read-only file"; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
120 break; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
121 case 0xF1: |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
122 type = "file"; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
123 break; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
124 case 0xF2: |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
125 type = "directory"; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
126 break; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
127 case 0xF3: |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
128 type = "symlink"; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
129 break; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
130 default: |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
131 type = "???"; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
132 } |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
133 printf("object type %02X (%s)\n", inf->type, type); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
134 if (!validate_obj_name(ino, ino == root_inode)) { |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
135 printf("No valid object name in the chunk!\n"); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
136 exit(1); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
137 } |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
138 printf("object name: %s\n", inf->dataptr); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
139 if (inf->type == 0xF1 || inf->type == 0xE1) { |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
140 printf("total size: %lu bytes\n", |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
141 (u_long) get_file_size(ino, 0)); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
142 if (verbose2) |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
143 ls_seg_file(ino, 0); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
144 } |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
145 putchar('\n'); |
233
ae9ff2d1e3da
tiffs IVA: basic ls integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 } |
236
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
147 |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
148 cmd_ls(argc, argv) |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
149 char **argv; |
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
150 { |
237
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
151 extern int optind; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
152 int c; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
153 |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
154 read_ffs_image(); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
155 find_inode_block(); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
156 alloc_inode_table(); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
157 find_root_inode(); |
236
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
158 |
237
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
159 optind = 0; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
160 while ((c = getopt(argc, argv, "v")) != EOF) |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
161 switch (c) { |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
162 case 'v': |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
163 verbose2++; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
164 continue; |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
165 default: |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
166 fprintf(stderr, "usage: ls [-v[v]] [pathname...]\n"); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
167 exit(1); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
168 } |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
169 if (optind >= argc) { |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
170 traverse_visible_tree(ls_tree_callback); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
171 exit(0); |
236
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
172 } |
237
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
173 for (; optind < argc; optind++) |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
174 ls_by_pathname(argv[optind]); |
317936902be4
tiffs IVA: regular ls fully implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
236
diff
changeset
|
175 exit(0); |
236
254de9560ef3
tiffs ls -v implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
235
diff
changeset
|
176 } |
238
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
177 |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
178 lsino_all() |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
179 { |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
180 int ino, last_ino = 0; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
181 struct inode_info *inf; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
182 char pathname[PATHNAME_BUF_SIZE], typech; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
183 int pathstat; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
184 char descend_str[8], sibling_str[8]; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
185 |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
186 for (ino = 1; ino < inode_limit; ino++) { |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
187 if (!validate_inode(ino)) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
188 continue; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
189 if (ino != last_ino + 1) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
190 printf("GAP in inode numbers\n"); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
191 inf = inode_info[ino]; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
192 pathstat = pathname_of_inode(ino, pathname); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
193 if (pathstat < 0) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
194 strcpy(pathname, "-nopath-"); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
195 switch (inf->type) { |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
196 case 0x00: |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
197 typech = '~'; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
198 break; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
199 case 0xE1: |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
200 case 0xF1: |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
201 typech = 'f'; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
202 break; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
203 case 0xF2: |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
204 typech = 'd'; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
205 break; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
206 case 0xF3: |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
207 typech = 'l'; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
208 break; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
209 case 0xF4: |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
210 typech = '.'; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
211 break; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
212 default: |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
213 typech = '?'; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
214 } |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
215 printf("#%04x %c %s\n", ino, typech, pathname); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
216 if (inf->type && !(inf->type & 0x10)) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
217 printf("\tread-only object\n"); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
218 if (ino == root_inode) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
219 printf("\tactive root\n"); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
220 else if (inf->nparents < 1) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
221 printf("\torphan\n"); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
222 else if (inf->nparents > 1) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
223 printf("\tparent: #%x (%d)\n", inf->parent, |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
224 inf->nparents); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
225 else if (pathstat < 0 || verbose2) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
226 printf("\tparent: #%x\n", inf->parent); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
227 if (verbose2 > 1) { |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
228 if (inf->descend) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
229 sprintf(descend_str, "#%x", inf->descend); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
230 else |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
231 strcpy(descend_str, "null"); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
232 if (inf->sibling) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
233 sprintf(sibling_str, "#%x", inf->sibling); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
234 else |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
235 strcpy(sibling_str, "null"); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
236 printf("\tchild: %s, sibling: %s\n", |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
237 descend_str, sibling_str); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
238 } |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
239 if (!inf->len) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
240 printf("\treclaimed\n"); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
241 last_ino = ino; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
242 } |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
243 exit(0); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
244 } |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
245 |
239
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
246 void |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
247 lsino_one(ino, assume_file) |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
248 { |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
249 struct inode_info *inf; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
250 char pathname[PATHNAME_BUF_SIZE], *type; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
251 |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
252 if (!validate_inode(ino)) { |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
253 fprintf(stderr, "lsino: specified inode number is invalid\n"); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
254 exit(1); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
255 } |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
256 printf("inode #%x\n", ino); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
257 inf = inode_info[ino]; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
258 if (pathname_of_inode(ino, pathname) >= 0) |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
259 printf("Pathname: %s\n", pathname); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
260 else |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
261 printf("No pathname found\n"); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
262 inf = inode_info[ino]; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
263 switch (inf->type) { |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
264 case 0x00: |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
265 type = "deleted"; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
266 break; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
267 case 0xE1: |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
268 type = "read-only file"; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
269 break; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
270 case 0xF1: |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
271 type = "file"; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
272 break; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
273 case 0xF2: |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
274 type = "directory"; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
275 break; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
276 case 0xF3: |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
277 type = "symlink"; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
278 break; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
279 default: |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
280 type = "???"; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
281 } |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
282 printf("object type %02X (%s)\n", inf->type, type); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
283 if (!inf->len) { |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
284 printf("This inode has been reclaimed\n\n"); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
285 return; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
286 } |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
287 if (validate_obj_name(ino, 1)) |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
288 printf("object name: %s\n", inf->dataptr); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
289 else { |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
290 printf("No valid object name in the chunk\n\n"); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
291 return; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
292 } |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
293 if (inf->type == 0xF1 || inf->type == 0xE1 || |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
294 !inf->type && assume_file) { |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
295 printf("total size: %lu bytes\n", |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
296 (u_long) get_file_size(ino, !inf->type)); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
297 if (verbose2) |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
298 ls_seg_file(ino, !inf->type); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
299 } |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
300 putchar('\n'); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
301 } |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
302 |
238
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
303 cmd_lsino(argc, argv) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
304 char **argv; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
305 { |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
306 extern int optind; |
239
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
307 int c, assume_file = 0, ino; |
238
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
308 |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
309 read_ffs_image(); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
310 find_inode_block(); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
311 alloc_inode_table(); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
312 find_root_inode(); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
313 treewalk_all(); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
314 |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
315 optind = 0; |
239
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
316 while ((c = getopt(argc, argv, "fv")) != EOF) |
238
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
317 switch (c) { |
239
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
318 case 'f': |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
319 assume_file++; |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
320 continue; |
238
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
321 case 'v': |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
322 verbose2++; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
323 continue; |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
324 default: |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
325 fprintf(stderr, "usage: lsino [-v[v]] [ino...]\n"); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
326 exit(1); |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
327 } |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
328 if (optind >= argc) |
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
329 return lsino_all(); |
239
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
330 for (; optind < argc; optind++) { |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
331 ino = strtoul(argv[optind], 0, 16); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
332 lsino_one(ino, assume_file); |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
333 } |
28ea957a9d8a
tiffs lsino of specific inodes implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
238
diff
changeset
|
334 exit(0); |
238
0b13839f782c
tiffs IVA: lsino (non-specific) implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
237
diff
changeset
|
335 } |