FreeCalypso > hg > freecalypso-sw
annotate ffstools/tiffs-rd/basics.c @ 246:872d92404b6a
ffstools: pirffs wrapper
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 27 Jan 2014 05:08:09 +0000 |
parents | 43642cf7c98c |
children | 475887e6b396 |
rev | line source |
---|---|
229
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * This C module implements the "basics" of TIFFS image analysis. |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <sys/file.h> |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <sys/stat.h> |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <sys/mman.h> |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <stdio.h> |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include <stdlib.h> |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include <unistd.h> |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include <string.h> |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include <strings.h> |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 #include "types.h" |
232
73372cfdaf7f
tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
231
diff
changeset
|
15 #include "struct.h" |
231
5ceacdbd4490
tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
230
diff
changeset
|
16 #include "globals.h" |
229
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 u8 tiffs_header[6] = {'F', 'f', 's', '#', 0x10, 0x02}; |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 read_ffs_image() |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 { |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 int fd; |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 struct stat st; |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 fd = open(imgfile, O_RDONLY); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 if (fd < 0) { |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 perror(imgfile); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 exit(1); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 } |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 fstat(fd, &st); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 if (!S_ISREG(st.st_mode)) { |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 fprintf(stderr, "error: %s is not a regular file\n", imgfile); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 exit(1); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 } |
243
43642cf7c98c
tiffs: added global option for offset of FFS within the file (new -o)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
232
diff
changeset
|
35 if (st.st_size < imgfile_offset) { |
43642cf7c98c
tiffs: added global option for offset of FFS within the file (new -o)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
232
diff
changeset
|
36 fprintf(stderr, |
43642cf7c98c
tiffs: added global option for offset of FFS within the file (new -o)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
232
diff
changeset
|
37 "error: offset given with -o exceeds the size of the file\n"); |
43642cf7c98c
tiffs: added global option for offset of FFS within the file (new -o)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
232
diff
changeset
|
38 exit(1); |
43642cf7c98c
tiffs: added global option for offset of FFS within the file (new -o)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
232
diff
changeset
|
39 } |
43642cf7c98c
tiffs: added global option for offset of FFS within the file (new -o)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
232
diff
changeset
|
40 if (st.st_size - imgfile_offset < total_ffs_size) { |
229
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 fprintf(stderr, |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 "error: %s is shorter than FFS size of 0x%lx bytes\n", |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 imgfile, (u_long)total_ffs_size); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 exit(1); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 } |
243
43642cf7c98c
tiffs: added global option for offset of FFS within the file (new -o)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
232
diff
changeset
|
46 image = mmap(NULL, total_ffs_size, PROT_READ, MAP_PRIVATE, fd, |
43642cf7c98c
tiffs: added global option for offset of FFS within the file (new -o)
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
232
diff
changeset
|
47 imgfile_offset); |
229
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 if (image == MAP_FAILED) { |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 perror("mmap"); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 exit(1); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 } |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 } |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 cmd_blkhdr() |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 { |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 int blk; |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 u8 *blkhdr; |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 read_ffs_image(); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 for (blk = 0; blk < total_blocks; blk++) { |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 printf("Block %3d: ", blk); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 blkhdr = image + blk * eraseblk_size; |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 if (bcmp(blkhdr, tiffs_header, sizeof tiffs_header)) { |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 printf("No TIFFS header\n"); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 continue; |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 } |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 printf("age %02X%02X, type/status %02X\n", |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 blkhdr[7], blkhdr[6], blkhdr[8]); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 } |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 exit(0); |
24ed817dd25d
tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 } |
230
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
72 |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
73 find_inode_block() |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
74 { |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
75 int i, abcnt; |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
76 u8 *ptr; |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
77 |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
78 if (index_blk_num >= 0) { |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
79 if (index_blk_num >= total_blocks) { |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
80 fprintf(stderr, |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
81 "invalid block # given with the -a option\n"); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
82 exit(1); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
83 } |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
84 ptr = image + index_blk_num * eraseblk_size; |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
85 if (bcmp(ptr, tiffs_header, sizeof tiffs_header)) { |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
86 fprintf(stderr, |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
87 "error: block specified with -a has no TIFFS header\n"); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
88 exit(1); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
89 } |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
90 if (ptr[8] != 0xAB) { |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
91 fprintf(stderr, |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
92 "error: block specified with -a is not an AB block\n"); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
93 exit(1); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
94 } |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
95 inode_block = ptr; |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
96 return(0); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
97 } |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
98 abcnt = 0; |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
99 for (ptr = image, i = 0; i < total_blocks; i++, ptr += eraseblk_size) { |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
100 if (bcmp(ptr, tiffs_header, sizeof tiffs_header)) { |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
101 fprintf(stderr, |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
102 "warning: no TIFFS signature in erase block #%d (offset %x)\n", |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
103 i, ptr - image); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
104 continue; |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
105 } |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
106 switch (ptr[8]) { |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
107 case 0xAB: |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
108 if (verbose) |
231
5ceacdbd4490
tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
230
diff
changeset
|
109 fprintf(stderr, |
230
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
110 "Found AB index in erase block #%d (offset %x)\n", |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
111 i, ptr - image); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
112 index_blk_num = i; |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
113 inode_block = ptr; |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
114 abcnt++; |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
115 continue; |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
116 case 0xBD: |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
117 case 0xBF: |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
118 continue; |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
119 } |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
120 fprintf(stderr, |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
121 "warning: unexpected block type/status %02X at offset %x\n", |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
122 ptr[8], ptr - image); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
123 } |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
124 if (!inode_block) { |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
125 fprintf(stderr, |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
126 "error: could not find an active inode block in %s\n", |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
127 imgfile); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
128 exit(1); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
129 } |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
130 if (abcnt > 1) { |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
131 fprintf(stderr, |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
132 "error: found more than one AB block; use -a\n"); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
133 exit(1); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
134 } |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
135 return(0); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
136 } |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
137 |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
138 cmd_fsinfo() |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
139 { |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
140 read_ffs_image(); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
141 find_inode_block(); |
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
142 printf("Active inode block (AB) is block #%d\n", index_blk_num); |
231
5ceacdbd4490
tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
230
diff
changeset
|
143 alloc_inode_table(); |
5ceacdbd4490
tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
230
diff
changeset
|
144 find_root_inode(); |
5ceacdbd4490
tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
230
diff
changeset
|
145 printf("Root inode is #%x\n", root_inode); |
232
73372cfdaf7f
tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
231
diff
changeset
|
146 if (validate_obj_name(root_inode, 1)) { |
73372cfdaf7f
tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
231
diff
changeset
|
147 printf("Root inode (format) name: %s\n", |
73372cfdaf7f
tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
231
diff
changeset
|
148 inode_info[root_inode]->dataptr); |
73372cfdaf7f
tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
231
diff
changeset
|
149 exit(0); |
73372cfdaf7f
tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
231
diff
changeset
|
150 } else { |
73372cfdaf7f
tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
231
diff
changeset
|
151 printf("No valid name found in the root inode!\n"); |
73372cfdaf7f
tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
231
diff
changeset
|
152 exit(1); |
73372cfdaf7f
tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
231
diff
changeset
|
153 } |
230
ffaa033e7643
tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
229
diff
changeset
|
154 } |