annotate ffstools/tiffs-rd/basics.c @ 371:8df6f38d2f3a

os_mem_fl.c: os_PartitionInformation() done
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 30 May 2014 19:50:24 +0000
parents 475887e6b396
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 }
253
475887e6b396 tiffs IVA: close the file descriptor after mmap
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 243
diff changeset
52 close(fd);
229
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
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 cmd_blkhdr()
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 {
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 int blk;
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 u8 *blkhdr;
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 read_ffs_image();
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 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
62 printf("Block %3d: ", blk);
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 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
64 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
65 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
66 continue;
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 }
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 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
69 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
70 }
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 exit(0);
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 }
230
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
73
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
74 find_inode_block()
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
75 {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
76 int i, abcnt;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
77 u8 *ptr;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
78
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
79 if (index_blk_num >= 0) {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
80 if (index_blk_num >= total_blocks) {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
81 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
82 "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
83 exit(1);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
84 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
85 ptr = image + index_blk_num * eraseblk_size;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
86 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
87 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
88 "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
89 exit(1);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
90 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
91 if (ptr[8] != 0xAB) {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
92 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
93 "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
94 exit(1);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
95 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
96 inode_block = ptr;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
97 return(0);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
98 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
99 abcnt = 0;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
100 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
101 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
102 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
103 "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
104 i, ptr - image);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
105 continue;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
106 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
107 switch (ptr[8]) {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
108 case 0xAB:
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
109 if (verbose)
231
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 230
diff changeset
110 fprintf(stderr,
230
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
111 "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
112 i, ptr - image);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
113 index_blk_num = i;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
114 inode_block = ptr;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
115 abcnt++;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
116 continue;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
117 case 0xBD:
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
118 case 0xBF:
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
119 continue;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
120 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
121 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
122 "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
123 ptr[8], ptr - image);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
124 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
125 if (!inode_block) {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
126 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
127 "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
128 imgfile);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
129 exit(1);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
130 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
131 if (abcnt > 1) {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
132 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
133 "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
134 exit(1);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
135 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
136 return(0);
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
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
139 cmd_fsinfo()
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
140 {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
141 read_ffs_image();
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
142 find_inode_block();
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
143 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
144 alloc_inode_table();
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 230
diff changeset
145 find_root_inode();
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 230
diff changeset
146 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
147 if (validate_obj_name(root_inode, 1)) {
73372cfdaf7f tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 231
diff changeset
148 printf("Root inode (format) name: %s\n",
73372cfdaf7f tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 231
diff changeset
149 inode_info[root_inode]->dataptr);
73372cfdaf7f tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 231
diff changeset
150 exit(0);
73372cfdaf7f tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 231
diff changeset
151 } else {
73372cfdaf7f tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 231
diff changeset
152 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
153 exit(1);
73372cfdaf7f tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 231
diff changeset
154 }
230
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
155 }