Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/include/linux/hfsplus_raw.h | |
3 | * | |
4 | * Copyright (C) 1999 | |
5 | * Brad Boyer (flar@pants.nu) | |
6 | * (C) 2003 Ardis Technologies <roman@ardistech.com> | |
7 | * | |
8 | * Format of structures on disk | |
9 | * Information taken from Apple Technote #1150 (HFS Plus Volume Format) | |
10 | * | |
11 | */ | |
12 | ||
13 | #ifndef _LINUX_HFSPLUS_RAW_H | |
14 | #define _LINUX_HFSPLUS_RAW_H | |
15 | ||
16 | #include <linux/types.h> | |
17 | ||
18 | #define __packed __attribute__ ((packed)) | |
19 | ||
20 | /* Some constants */ | |
21 | #define HFSPLUS_SECTOR_SIZE 512 | |
22 | #define HFSPLUS_SECTOR_SHIFT 9 | |
23 | #define HFSPLUS_VOLHEAD_SECTOR 2 | |
24 | #define HFSPLUS_VOLHEAD_SIG 0x482b | |
25 | #define HFSPLUS_SUPER_MAGIC 0x482b | |
26 | #define HFSPLUS_CURRENT_VERSION 4 | |
27 | ||
28 | #define HFSP_WRAP_MAGIC 0x4244 | |
29 | #define HFSP_WRAP_ATTRIB_SLOCK 0x8000 | |
30 | #define HFSP_WRAP_ATTRIB_SPARED 0x0200 | |
31 | ||
32 | #define HFSP_WRAPOFF_SIG 0x00 | |
33 | #define HFSP_WRAPOFF_ATTRIB 0x0A | |
34 | #define HFSP_WRAPOFF_ABLKSIZE 0x14 | |
35 | #define HFSP_WRAPOFF_ABLKSTART 0x1C | |
36 | #define HFSP_WRAPOFF_EMBEDSIG 0x7C | |
37 | #define HFSP_WRAPOFF_EMBEDEXT 0x7E | |
38 | ||
39 | #define HFSP_HIDDENDIR_NAME "\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80HFS+ Private Data" | |
40 | ||
41 | #define HFSP_HARDLINK_TYPE 0x686c6e6b /* 'hlnk' */ | |
42 | #define HFSP_HFSPLUS_CREATOR 0x6866732b /* 'hfs+' */ | |
43 | ||
44 | #define HFSP_MOUNT_VERSION 0x482b4c78 /* 'H+Lx' */ | |
45 | ||
46 | /* Structures used on disk */ | |
47 | ||
48 | typedef __be32 hfsplus_cnid; | |
49 | typedef __be16 hfsplus_unichr; | |
50 | ||
51 | /* A "string" as used in filenames, etc. */ | |
52 | struct hfsplus_unistr { | |
53 | __be16 length; | |
54 | hfsplus_unichr unicode[255]; | |
55 | } __packed; | |
56 | ||
57 | #define HFSPLUS_MAX_STRLEN 255 | |
58 | ||
59 | /* POSIX permissions */ | |
60 | struct hfsplus_perm { | |
61 | __be32 owner; | |
62 | __be32 group; | |
63 | u8 rootflags; | |
64 | u8 userflags; | |
65 | __be16 mode; | |
66 | __be32 dev; | |
67 | } __packed; | |
68 | ||
69 | #define HFSPLUS_FLG_NODUMP 0x01 | |
70 | #define HFSPLUS_FLG_IMMUTABLE 0x02 | |
71 | #define HFSPLUS_FLG_APPEND 0x04 | |
72 | ||
73 | /* A single contiguous area of a file */ | |
74 | struct hfsplus_extent { | |
75 | __be32 start_block; | |
76 | __be32 block_count; | |
77 | } __packed; | |
78 | typedef struct hfsplus_extent hfsplus_extent_rec[8]; | |
79 | ||
80 | /* Information for a "Fork" in a file */ | |
81 | struct hfsplus_fork_raw { | |
82 | __be64 total_size; | |
83 | __be32 clump_size; | |
84 | __be32 total_blocks; | |
85 | hfsplus_extent_rec extents; | |
86 | } __packed; | |
87 | ||
88 | /* HFS+ Volume Header */ | |
89 | struct hfsplus_vh { | |
90 | __be16 signature; | |
91 | __be16 version; | |
92 | __be32 attributes; | |
93 | __be32 last_mount_vers; | |
94 | u32 reserved; | |
95 | ||
96 | __be32 create_date; | |
97 | __be32 modify_date; | |
98 | __be32 backup_date; | |
99 | __be32 checked_date; | |
100 | ||
101 | __be32 file_count; | |
102 | __be32 folder_count; | |
103 | ||
104 | __be32 blocksize; | |
105 | __be32 total_blocks; | |
106 | __be32 free_blocks; | |
107 | ||
108 | __be32 next_alloc; | |
109 | __be32 rsrc_clump_sz; | |
110 | __be32 data_clump_sz; | |
111 | hfsplus_cnid next_cnid; | |
112 | ||
113 | __be32 write_count; | |
114 | __be64 encodings_bmp; | |
115 | ||
116 | u8 finder_info[32]; | |
117 | ||
118 | struct hfsplus_fork_raw alloc_file; | |
119 | struct hfsplus_fork_raw ext_file; | |
120 | struct hfsplus_fork_raw cat_file; | |
121 | struct hfsplus_fork_raw attr_file; | |
122 | struct hfsplus_fork_raw start_file; | |
123 | } __packed; | |
124 | ||
125 | /* HFS+ volume attributes */ | |
b0b623c3 RZ |
126 | #define HFSPLUS_VOL_UNMNT (1 << 8) |
127 | #define HFSPLUS_VOL_SPARE_BLK (1 << 9) | |
128 | #define HFSPLUS_VOL_NOCACHE (1 << 10) | |
129 | #define HFSPLUS_VOL_INCNSTNT (1 << 11) | |
130 | #define HFSPLUS_VOL_NODEID_REUSED (1 << 12) | |
131 | #define HFSPLUS_VOL_JOURNALED (1 << 13) | |
132 | #define HFSPLUS_VOL_SOFTLOCK (1 << 15) | |
1da177e4 LT |
133 | |
134 | /* HFS+ BTree node descriptor */ | |
135 | struct hfs_bnode_desc { | |
136 | __be32 next; | |
137 | __be32 prev; | |
138 | s8 type; | |
139 | u8 height; | |
140 | __be16 num_recs; | |
141 | u16 reserved; | |
142 | } __packed; | |
143 | ||
144 | /* HFS+ BTree node types */ | |
145 | #define HFS_NODE_INDEX 0x00 | |
146 | #define HFS_NODE_HEADER 0x01 | |
147 | #define HFS_NODE_MAP 0x02 | |
148 | #define HFS_NODE_LEAF 0xFF | |
149 | ||
150 | /* HFS+ BTree header */ | |
151 | struct hfs_btree_header_rec { | |
152 | __be16 depth; | |
153 | __be32 root; | |
154 | __be32 leaf_count; | |
155 | __be32 leaf_head; | |
156 | __be32 leaf_tail; | |
157 | __be16 node_size; | |
158 | __be16 max_key_len; | |
159 | __be32 node_count; | |
160 | __be32 free_nodes; | |
161 | u16 reserved1; | |
162 | __be32 clump_size; | |
163 | u8 btree_type; | |
164 | u8 reserved2; | |
165 | __be32 attributes; | |
166 | u32 reserved3[16]; | |
167 | } __packed; | |
168 | ||
169 | /* BTree attributes */ | |
170 | #define HFS_TREE_BIGKEYS 2 | |
171 | #define HFS_TREE_VARIDXKEYS 4 | |
172 | ||
173 | /* HFS+ BTree misc info */ | |
174 | #define HFSPLUS_TREE_HEAD 0 | |
175 | #define HFSPLUS_NODE_MXSZ 32768 | |
176 | ||
177 | /* Some special File ID numbers (stolen from hfs.h) */ | |
178 | #define HFSPLUS_POR_CNID 1 /* Parent Of the Root */ | |
179 | #define HFSPLUS_ROOT_CNID 2 /* ROOT directory */ | |
180 | #define HFSPLUS_EXT_CNID 3 /* EXTents B-tree */ | |
181 | #define HFSPLUS_CAT_CNID 4 /* CATalog B-tree */ | |
182 | #define HFSPLUS_BAD_CNID 5 /* BAD blocks file */ | |
183 | #define HFSPLUS_ALLOC_CNID 6 /* ALLOCation file */ | |
184 | #define HFSPLUS_START_CNID 7 /* STARTup file */ | |
185 | #define HFSPLUS_ATTR_CNID 8 /* ATTRibutes file */ | |
186 | #define HFSPLUS_EXCH_CNID 15 /* ExchangeFiles temp id */ | |
187 | #define HFSPLUS_FIRSTUSER_CNID 16 /* first available user id */ | |
188 | ||
189 | /* HFS+ catalog entry key */ | |
190 | struct hfsplus_cat_key { | |
191 | __be16 key_len; | |
192 | hfsplus_cnid parent; | |
193 | struct hfsplus_unistr name; | |
194 | } __packed; | |
195 | ||
196 | ||
197 | /* Structs from hfs.h */ | |
198 | struct hfsp_point { | |
199 | __be16 v; | |
200 | __be16 h; | |
201 | } __packed; | |
202 | ||
203 | struct hfsp_rect { | |
204 | __be16 top; | |
205 | __be16 left; | |
206 | __be16 bottom; | |
207 | __be16 right; | |
208 | } __packed; | |
209 | ||
210 | ||
211 | /* HFS directory info (stolen from hfs.h */ | |
212 | struct DInfo { | |
213 | struct hfsp_rect frRect; | |
214 | __be16 frFlags; | |
215 | struct hfsp_point frLocation; | |
216 | __be16 frView; | |
217 | } __packed; | |
218 | ||
219 | struct DXInfo { | |
220 | struct hfsp_point frScroll; | |
221 | __be32 frOpenChain; | |
222 | __be16 frUnused; | |
223 | __be16 frComment; | |
224 | __be32 frPutAway; | |
225 | } __packed; | |
226 | ||
227 | /* HFS+ folder data (part of an hfsplus_cat_entry) */ | |
228 | struct hfsplus_cat_folder { | |
229 | __be16 type; | |
230 | __be16 flags; | |
231 | __be32 valence; | |
232 | hfsplus_cnid id; | |
233 | __be32 create_date; | |
234 | __be32 content_mod_date; | |
235 | __be32 attribute_mod_date; | |
236 | __be32 access_date; | |
237 | __be32 backup_date; | |
238 | struct hfsplus_perm permissions; | |
239 | struct DInfo user_info; | |
240 | struct DXInfo finder_info; | |
241 | __be32 text_encoding; | |
242 | u32 reserved; | |
243 | } __packed; | |
244 | ||
245 | /* HFS file info (stolen from hfs.h) */ | |
246 | struct FInfo { | |
247 | __be32 fdType; | |
248 | __be32 fdCreator; | |
249 | __be16 fdFlags; | |
250 | struct hfsp_point fdLocation; | |
251 | __be16 fdFldr; | |
252 | } __packed; | |
253 | ||
254 | struct FXInfo { | |
255 | __be16 fdIconID; | |
256 | u8 fdUnused[8]; | |
257 | __be16 fdComment; | |
258 | __be32 fdPutAway; | |
259 | } __packed; | |
260 | ||
261 | /* HFS+ file data (part of a cat_entry) */ | |
262 | struct hfsplus_cat_file { | |
263 | __be16 type; | |
264 | __be16 flags; | |
265 | u32 reserved1; | |
266 | hfsplus_cnid id; | |
267 | __be32 create_date; | |
268 | __be32 content_mod_date; | |
269 | __be32 attribute_mod_date; | |
270 | __be32 access_date; | |
271 | __be32 backup_date; | |
272 | struct hfsplus_perm permissions; | |
273 | struct FInfo user_info; | |
274 | struct FXInfo finder_info; | |
275 | __be32 text_encoding; | |
276 | u32 reserved2; | |
277 | ||
278 | struct hfsplus_fork_raw data_fork; | |
279 | struct hfsplus_fork_raw rsrc_fork; | |
280 | } __packed; | |
281 | ||
282 | /* File attribute bits */ | |
283 | #define HFSPLUS_FILE_LOCKED 0x0001 | |
284 | #define HFSPLUS_FILE_THREAD_EXISTS 0x0002 | |
285 | ||
286 | /* HFS+ catalog thread (part of a cat_entry) */ | |
287 | struct hfsplus_cat_thread { | |
288 | __be16 type; | |
289 | s16 reserved; | |
290 | hfsplus_cnid parentID; | |
291 | struct hfsplus_unistr nodeName; | |
292 | } __packed; | |
293 | ||
294 | #define HFSPLUS_MIN_THREAD_SZ 10 | |
295 | ||
296 | /* A data record in the catalog tree */ | |
297 | typedef union { | |
298 | __be16 type; | |
299 | struct hfsplus_cat_folder folder; | |
300 | struct hfsplus_cat_file file; | |
301 | struct hfsplus_cat_thread thread; | |
302 | } __packed hfsplus_cat_entry; | |
303 | ||
304 | /* HFS+ catalog entry type */ | |
305 | #define HFSPLUS_FOLDER 0x0001 | |
306 | #define HFSPLUS_FILE 0x0002 | |
307 | #define HFSPLUS_FOLDER_THREAD 0x0003 | |
308 | #define HFSPLUS_FILE_THREAD 0x0004 | |
309 | ||
310 | /* HFS+ extents tree key */ | |
311 | struct hfsplus_ext_key { | |
312 | __be16 key_len; | |
313 | u8 fork_type; | |
314 | u8 pad; | |
315 | hfsplus_cnid cnid; | |
316 | __be32 start_block; | |
317 | } __packed; | |
318 | ||
319 | #define HFSPLUS_EXT_KEYLEN 12 | |
320 | ||
321 | /* HFS+ generic BTree key */ | |
322 | typedef union { | |
323 | __be16 key_len; | |
324 | struct hfsplus_cat_key cat; | |
325 | struct hfsplus_ext_key ext; | |
326 | } __packed hfsplus_btree_key; | |
327 | ||
328 | #endif |