annotate ffstools/tiffs-rd/basics.c @ 232:73372cfdaf7f

tiffs IVA: object name validation implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 26 Jan 2014 08:42:59 +0000
parents 5ceacdbd4490
children 43642cf7c98c
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 }
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 if (st.st_size < total_ffs_size) {
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 fprintf(stderr,
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 "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
38 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
39 exit(1);
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 }
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 image = mmap(NULL, total_ffs_size, PROT_READ, MAP_PRIVATE, fd, 0);
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42 if (image == MAP_FAILED) {
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 perror("mmap");
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 }
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 }
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 cmd_blkhdr()
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 {
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 int blk;
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 u8 *blkhdr;
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 read_ffs_image();
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 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
55 printf("Block %3d: ", blk);
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 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
57 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
58 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
59 continue;
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 }
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
61 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
62 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
63 }
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 exit(0);
24ed817dd25d tiffs IVA: reads image via mmap and displays block headers
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 }
230
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
66
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
67 find_inode_block()
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
68 {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
69 int i, abcnt;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
70 u8 *ptr;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
71
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
72 if (index_blk_num >= 0) {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
73 if (index_blk_num >= total_blocks) {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
74 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
75 "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
76 exit(1);
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 ptr = image + index_blk_num * eraseblk_size;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
79 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
80 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
81 "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
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 if (ptr[8] != 0xAB) {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
85 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
86 "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
87 exit(1);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
88 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
89 inode_block = ptr;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
90 return(0);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
91 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
92 abcnt = 0;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
93 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
94 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
95 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
96 "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
97 i, ptr - image);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
98 continue;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
99 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
100 switch (ptr[8]) {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
101 case 0xAB:
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
102 if (verbose)
231
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 230
diff changeset
103 fprintf(stderr,
230
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
104 "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
105 i, ptr - image);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
106 index_blk_num = i;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
107 inode_block = ptr;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
108 abcnt++;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
109 continue;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
110 case 0xBD:
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
111 case 0xBF:
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
112 continue;
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
113 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
114 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
115 "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
116 ptr[8], ptr - image);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
117 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
118 if (!inode_block) {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
119 fprintf(stderr,
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
120 "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
121 imgfile);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
122 exit(1);
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 (abcnt > 1) {
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: 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
127 exit(1);
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
128 }
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
129 return(0);
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
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
132 cmd_fsinfo()
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
133 {
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
134 read_ffs_image();
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
135 find_inode_block();
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
136 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
137 alloc_inode_table();
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 230
diff changeset
138 find_root_inode();
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 230
diff changeset
139 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
140 if (validate_obj_name(root_inode, 1)) {
73372cfdaf7f tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 231
diff changeset
141 printf("Root inode (format) name: %s\n",
73372cfdaf7f tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 231
diff changeset
142 inode_info[root_inode]->dataptr);
73372cfdaf7f tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 231
diff changeset
143 exit(0);
73372cfdaf7f tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 231
diff changeset
144 } else {
73372cfdaf7f tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 231
diff changeset
145 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
146 exit(1);
73372cfdaf7f tiffs IVA: object name validation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 231
diff changeset
147 }
230
ffaa033e7643 tiffs IVA: find_inode_block() integrated
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 229
diff changeset
148 }