1
2
3
4
5
6
7
8
9 #ifndef _HFS_H
10 #define _HFS_H
11
12
13 #define HFS_DD_BLK 0
14 #define HFS_PMAP_BLK 1
15 #define HFS_MDB_BLK 2
16
17
18 #define HFS_DRVR_DESC_MAGIC 0x4552
19 #define HFS_OLD_PMAP_MAGIC 0x5453
20 #define HFS_NEW_PMAP_MAGIC 0x504D
21 #define HFS_SUPER_MAGIC 0x4244
22 #define HFS_MFS_SUPER_MAGIC 0xD2D7
23
24
25 #define HFS_SECTOR_SIZE 512
26 #define HFS_SECTOR_SIZE_BITS 9
27 #define HFS_NAMELEN 31
28 #define HFS_MAX_NAMELEN 128
29 #define HFS_MAX_VALENCE 32767U
30
31
32
33
34 #define HFS_SB_ATTRIB_HLOCK (1 << 7)
35 #define HFS_SB_ATTRIB_UNMNT (1 << 8)
36 #define HFS_SB_ATTRIB_SPARED (1 << 9)
37 #define HFS_SB_ATTRIB_INCNSTNT (1 << 11)
38 #define HFS_SB_ATTRIB_SLOCK (1 << 15)
39
40
41 #define HFS_POR_CNID 1
42 #define HFS_ROOT_CNID 2
43 #define HFS_EXT_CNID 3
44 #define HFS_CAT_CNID 4
45 #define HFS_BAD_CNID 5
46 #define HFS_ALLOC_CNID 6
47 #define HFS_START_CNID 7
48 #define HFS_ATTR_CNID 8
49 #define HFS_EXCH_CNID 15
50 #define HFS_FIRSTUSER_CNID 16
51
52
53 #define HFS_CDR_DIR 0x01
54 #define HFS_CDR_FIL 0x02
55 #define HFS_CDR_THD 0x03
56 #define HFS_CDR_FTH 0x04
57
58
59 #define HFS_FK_DATA 0x00
60 #define HFS_FK_RSRC 0xFF
61
62
63 #define HFS_FIL_LOCK 0x01
64 #define HFS_FIL_THD 0x02
65 #define HFS_FIL_DOPEN 0x04
66 #define HFS_FIL_ROPEN 0x08
67 #define HFS_FIL_DIR 0x10
68 #define HFS_FIL_NOCOPY 0x40
69 #define HFS_FIL_USED 0x80
70
71
72 #define HFS_DIR_LOCK 0x01
73 #define HFS_DIR_THD 0x02
74 #define HFS_DIR_INEXPFOLDER 0x04
75 #define HFS_DIR_MOUNTED 0x08
76 #define HFS_DIR_DIR 0x10
77 #define HFS_DIR_EXPFOLDER 0x20
78
79
80 #define HFS_FLG_INITED 0x0100
81 #define HFS_FLG_LOCKED 0x1000
82 #define HFS_FLG_INVISIBLE 0x4000
83
84
85
86
87 struct hfs_name {
88 u8 len;
89 u8 name[HFS_NAMELEN];
90 } __packed;
91
92 struct hfs_point {
93 __be16 v;
94 __be16 h;
95 } __packed;
96
97 struct hfs_rect {
98 __be16 top;
99 __be16 left;
100 __be16 bottom;
101 __be16 right;
102 } __packed;
103
104 struct hfs_finfo {
105 __be32 fdType;
106 __be32 fdCreator;
107 __be16 fdFlags;
108 struct hfs_point fdLocation;
109 __be16 fdFldr;
110 } __packed;
111
112 struct hfs_fxinfo {
113 __be16 fdIconID;
114 u8 fdUnused[8];
115 __be16 fdComment;
116 __be32 fdPutAway;
117 } __packed;
118
119 struct hfs_dinfo {
120 struct hfs_rect frRect;
121 __be16 frFlags;
122 struct hfs_point frLocation;
123 __be16 frView;
124 } __packed;
125
126 struct hfs_dxinfo {
127 struct hfs_point frScroll;
128 __be32 frOpenChain;
129 __be16 frUnused;
130 __be16 frComment;
131 __be32 frPutAway;
132 } __packed;
133
134 union hfs_finder_info {
135 struct {
136 struct hfs_finfo finfo;
137 struct hfs_fxinfo fxinfo;
138 } file;
139 struct {
140 struct hfs_dinfo dinfo;
141 struct hfs_dxinfo dxinfo;
142 } dir;
143 } __packed;
144
145
146 #define HFS_BKEY(X) (((void)((X)->KeyLen)), ((struct hfs_bkey *)(X)))
147
148
149 struct hfs_cat_key {
150 u8 key_len;
151 u8 reserved;
152 __be32 ParID;
153 struct hfs_name CName;
154 } __packed;
155
156
157 struct hfs_ext_key {
158 u8 key_len;
159 u8 FkType;
160 __be32 FNum;
161 __be16 FABN;
162 } __packed;
163
164 typedef union hfs_btree_key {
165 u8 key_len;
166 struct hfs_cat_key cat;
167 struct hfs_ext_key ext;
168 } hfs_btree_key;
169
170 #define HFS_MAX_CAT_KEYLEN (sizeof(struct hfs_cat_key) - sizeof(u8))
171 #define HFS_MAX_EXT_KEYLEN (sizeof(struct hfs_ext_key) - sizeof(u8))
172
173 typedef union hfs_btree_key btree_key;
174
175 struct hfs_extent {
176 __be16 block;
177 __be16 count;
178 };
179 typedef struct hfs_extent hfs_extent_rec[3];
180
181
182 struct hfs_cat_file {
183 s8 type;
184 u8 reserved;
185 u8 Flags;
186 s8 Typ;
187 struct hfs_finfo UsrWds;
188 __be32 FlNum;
189 __be16 StBlk;
190 __be32 LgLen;
191 __be32 PyLen;
192 __be16 RStBlk;
193 __be32 RLgLen;
194 __be32 RPyLen;
195 __be32 CrDat;
196 __be32 MdDat;
197 __be32 BkDat;
198 struct hfs_fxinfo FndrInfo;
199 __be16 ClpSize;
200
201 hfs_extent_rec ExtRec;
202
203 hfs_extent_rec RExtRec;
204
205 u32 Resrv;
206 } __packed;
207
208
209 struct hfs_cat_dir {
210 s8 type;
211 u8 reserved;
212 __be16 Flags;
213 __be16 Val;
214
215 __be32 DirID;
216 __be32 CrDat;
217 __be32 MdDat;
218 __be32 BkDat;
219 struct hfs_dinfo UsrInfo;
220 struct hfs_dxinfo FndrInfo;
221 u8 Resrv[16];
222 } __packed;
223
224
225 struct hfs_cat_thread {
226 s8 type;
227 u8 reserved[9];
228 __be32 ParID;
229 struct hfs_name CName;
230 } __packed;
231
232
233 typedef union hfs_cat_rec {
234 s8 type;
235 struct hfs_cat_file file;
236 struct hfs_cat_dir dir;
237 struct hfs_cat_thread thread;
238 } hfs_cat_rec;
239
240 struct hfs_mdb {
241 __be16 drSigWord;
242 __be32 drCrDate;
243 __be32 drLsMod;
244 __be16 drAtrb;
245 __be16 drNmFls;
246 __be16 drVBMSt;
247
248 __be16 drAllocPtr;
249
250 __be16 drNmAlBlks;
251 __be32 drAlBlkSiz;
252 __be32 drClpSiz;
253
254 __be16 drAlBlSt;
255
256 __be32 drNxtCNID;
257
258 __be16 drFreeBks;
259 u8 drVN[28];
260 __be32 drVolBkUp;
261 __be16 drVSeqNum;
262 __be32 drWrCnt;
263 __be32 drXTClpSiz;
264 __be32 drCTClpSiz;
265 __be16 drNmRtDirs;
266
267 __be32 drFilCnt;
268 __be32 drDirCnt;
269 u8 drFndrInfo[32];
270 __be16 drEmbedSigWord;
271 __be32 drEmbedExtent;
272
273
274
275 __be32 drXTFlSize;
276 hfs_extent_rec drXTExtRec;
277 __be32 drCTFlSize;
278 hfs_extent_rec drCTExtRec;
279 } __packed;
280
281
282
283 struct hfs_readdir_data {
284 struct list_head list;
285 struct file *file;
286 struct hfs_cat_key key;
287 };
288
289 #endif