annotate ffstools/tiffs-rd/inode.c @ 867:c4da570dca83

int_osx_receive_prim() in gsm-fw/gpf/osx/osx.c: there was an error in the reconstruction of this function from disassembly in the logic that implements special handling for MPHC_RXLEV_REQ messages. The code is now fixed to properly match what the binary object version does; with this fix the firmware now performs the power measurement phase correctly and the initial network registration succeeds.
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sat, 16 May 2015 06:34:09 +0000
parents 024042383a26
children 09b8b2327838
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
231
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
2 * This C module implements the reading and decoding of inode information.
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <endian.h>
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <stdlib.h>
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <string.h>
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <strings.h>
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
11 #include "types.h"
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "struct.h"
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "globals.h"
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15 u8 blank_flash_line[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
16 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
17
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 alloc_inode_table()
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
19 {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
20 inode_info = malloc(sizeof(struct inode_info *) * inode_limit);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
21 if (!inode_info) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
22 perror("malloc of inode table");
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
23 exit(1);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
24 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
25 bzero(inode_info, sizeof(struct inode_info *) * inode_limit);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
26 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
27
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
28 static int
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
29 convert_ptr(in, infp)
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
30 int in;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
31 int *infp;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
32 {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
33 if (in == 0xFFFF) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
34 *infp = 0;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
35 return(0);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
36 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
37 if (in < 1 || in >= inode_limit)
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
38 return(-1);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
39 *infp = in;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
40 return(1);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
41 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
42
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
43 validate_inode(ino)
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
44 {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
45 struct inode_flash *fl;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
46 struct inode_info *inf;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
47
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
48 if (ino < 1 || ino >= inode_limit)
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
49 return(0);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
50 if (inode_info[ino])
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
51 return(1);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
52 fl = (struct inode_flash *)inode_block + ino;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
53 if (!bcmp(fl, blank_flash_line, sizeof blank_flash_line))
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
54 return(0);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
55 inf = malloc(sizeof(struct inode_info));
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
56 if (!inf) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
57 perror("malloc of struct inode_info");
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
58 exit(1);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
59 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
60 bzero(inf, sizeof(struct inode_info));
234
024042383a26 tiffs IVA: ls reports file sizes
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 233
diff changeset
61 inf->ino = ino;
231
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
62 inf->len = le16toh(fl->len);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
63 if (inf->len & 0xF) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
64 fprintf(stderr,
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
65 "warning: inode #%x: invalid length, skipping\n", ino);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
66 free(inf);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
67 return(0);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
68 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
69 inf->type = fl->type;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
70 switch (inf->type) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
71 case 0x00:
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
72 break;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
73 case 0xE1:
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
74 case 0xF1:
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
75 case 0xF2:
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
76 case 0xF3:
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
77 case 0xF4:
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
78 if (!inf->len) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
79 fprintf(stderr,
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
80 "warning: inode #%x: non-deleted object has zero length, skipping\n",
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
81 ino);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
82 free(inf);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
83 return(0);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
84 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
85 break;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
86 default:
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
87 fprintf(stderr,
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
88 "warning: inode #%x: unexpected object type %02X, skipping\n",
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
89 ino, inf->type);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
90 free(inf);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
91 return(0);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
92 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
93 if (convert_ptr(le16toh(fl->descend), &inf->descend) < 0) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
94 fprintf(stderr,
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
95 "warning: inode #%x: invalid descend pointer, skipping\n",
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
96 ino);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
97 free(inf);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
98 return(0);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
99 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
100 if (convert_ptr(le16toh(fl->sibling), &inf->sibling) < 0) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
101 fprintf(stderr,
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
102 "warning: inode #%x: invalid sibling pointer, skipping\n",
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
103 ino);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
104 free(inf);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
105 return(0);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
106 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
107 if (inf->len) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
108 inf->rawloc = le32toh(fl->dataptr);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
109 if (inf->rawloc > 0x0FFFFFFF) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
110 invdptr: fprintf(stderr,
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
111 "warning: inode #%x: invalid data pointer, skipping\n",
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
112 ino);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
113 free(inf);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
114 return(0);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
115 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
116 inf->offset = inf->rawloc << 4;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
117 if (inf->offset >= total_ffs_size)
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
118 goto invdptr;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
119 if (inf->offset + inf->len > total_ffs_size) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
120 fprintf(stderr,
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
121 "warning: inode #%x: data pointer + length > FFS total size, skipping\n",
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
122 ino);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
123 free(inf);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
124 return(0);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
125 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
126 inf->dataptr = image + inf->offset;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
127 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
128 inode_info[ino] = inf;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
129 return(1);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
130 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
131
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
132 find_root_inode()
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
133 {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
134 int ino;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
135
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
136 if (root_inode) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
137 if (!validate_inode(root_inode)) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
138 fprintf(stderr,
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
139 "error: root inode specified with -r is invalid\n");
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
140 exit(1);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
141 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
142 return(1);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
143 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
144 for (ino = 1; ino < inode_limit; ino++) {
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
145 if (!validate_inode(ino))
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
146 continue;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
147 if (inode_info[ino]->type != 0xF2)
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
148 continue;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
149 if (*inode_info[ino]->dataptr != '/')
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
150 continue;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
151 root_inode = ino;
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
152 if (verbose)
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
153 fprintf(stderr, "Found root inode at #%x\n", ino);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
154 if (inode_info[ino]->sibling)
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
155 fprintf(stderr,
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
156 "warning: root inode #%x has a non-null sibling pointer\n",
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
157 ino);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
158 return(0);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
159 }
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
160 fprintf(stderr, "error: no root inode found; try -r\n");
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
161 exit(1);
5ceacdbd4490 tiffs IVA: finds the root inode
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
162 }