FreeCalypso > hg > freecalypso-sw
comparison ffstools/tiffs-rd/object.c @ 234:024042383a26
tiffs IVA: ls reports file sizes
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 26 Jan 2014 11:47:13 +0000 |
parents | ae9ff2d1e3da |
children | 317936902be4 |
comparison
equal
deleted
inserted
replaced
233:ae9ff2d1e3da | 234:024042383a26 |
---|---|
1 /* | 1 /* |
2 * This C module implements object-level analysis. | 2 * This C module implements object-level analysis. |
3 */ | 3 */ |
4 | 4 |
5 #include <sys/types.h> | |
5 #include <ctype.h> | 6 #include <ctype.h> |
6 #include <stdio.h> | 7 #include <stdio.h> |
7 #include <stdlib.h> | 8 #include <stdlib.h> |
8 #include <string.h> | 9 #include <string.h> |
9 #include <strings.h> | 10 #include <strings.h> |
54 return(0); | 55 return(0); |
55 } | 56 } |
56 inf->byte_after_name = p + 1; | 57 inf->byte_after_name = p + 1; |
57 return(1); | 58 return(1); |
58 } | 59 } |
60 | |
61 u8 * | |
62 find_end_of_chunk(inf) | |
63 struct inode_info *inf; | |
64 { | |
65 u8 *p; | |
66 int i; | |
67 | |
68 p = inf->dataptr + inf->len; | |
69 for (i = 1; i <= 16; i++) { | |
70 if (!p[-i]) | |
71 return(p - i); | |
72 if (p[-i] != 0xFF) | |
73 break; | |
74 } | |
75 fprintf(stderr, | |
76 "error: chunk @%x (inode #%x): no valid termination found\n", | |
77 inf->offset, inf->ino); | |
78 return(p); /* bogon, allows the rest to continue */ | |
79 } | |
80 | |
81 size_head_chunk(inf, chi) | |
82 struct inode_info *inf; | |
83 struct chunkinfo *chi; | |
84 { | |
85 chi->start = inf->byte_after_name; | |
86 chi->end = find_end_of_chunk(inf); | |
87 if (chi->start >= chi->end) { | |
88 chi->len = 0; | |
89 return(0); | |
90 } else { | |
91 chi->len = chi->end - chi->start; | |
92 return(1); | |
93 } | |
94 } | |
95 | |
96 size_extra_chunk(inf, chi) | |
97 struct inode_info *inf; | |
98 struct chunkinfo *chi; | |
99 { | |
100 chi->start = inf->dataptr; | |
101 chi->end = find_end_of_chunk(inf); | |
102 chi->len = chi->end - chi->start; | |
103 } | |
104 | |
105 void | |
106 iterate_seg_file(seghead, callback, callback_data, deleted) | |
107 void (*callback)(); | |
108 u_long callback_data; | |
109 { | |
110 int ino; | |
111 struct inode_info *inf; | |
112 | |
113 for (ino = inode_info[seghead]->descend; ino; ino = inf->descend) { | |
114 loop: if (!validate_inode(ino)) { | |
115 fprintf(stderr, | |
116 "error: following seg file hit invalid inode #%x\n", | |
117 ino); | |
118 return; | |
119 } | |
120 inf = inode_info[ino]; | |
121 switch (inf->type) { | |
122 case 0xF4: | |
123 callback(inf, callback_data); | |
124 continue; | |
125 case 0x00: | |
126 if (deleted) { | |
127 if (inf->len) | |
128 callback(inf, callback_data); | |
129 else | |
130 fprintf(stderr, | |
131 "error: presumed deleted segment inode #%x has been reclaimed\n", | |
132 ino); | |
133 continue; | |
134 } | |
135 if (!inf->sibling) { | |
136 fprintf(stderr, | |
137 "error: segment object at inode #%x: marked deleted, but no sibling\n", | |
138 ino); | |
139 return; | |
140 } | |
141 ino = inf->sibling; | |
142 goto loop; | |
143 default: | |
144 fprintf(stderr, | |
145 "error: inode #%x: unexpected type %02X when expecting segment (F4)\n", | |
146 ino, inf->type); | |
147 return; | |
148 } | |
149 } | |
150 } |