2 * linux/include/linux/hfsplus_raw.h
8 * Format of structures on disk
9 * Information taken from Apple Technote #1150 (HFS Plus Volume Format)
13 #ifndef _LINUX_HFSPLUS_RAW_H
14 #define _LINUX_HFSPLUS_RAW_H
16 #include <linux/types.h>
19 #define HFSPLUS_SECTOR_SIZE 512
20 #define HFSPLUS_SECTOR_SHIFT 9
21 #define HFSPLUS_VOLHEAD_SECTOR 2
22 #define HFSPLUS_VOLHEAD_SIG 0x482b
23 #define HFSPLUS_VOLHEAD_SIGX 0x4858
24 #define HFSPLUS_SUPER_MAGIC 0x482b
25 #define HFSPLUS_MIN_VERSION 4
26 #define HFSPLUS_CURRENT_VERSION 5
28 #define HFSP_WRAP_MAGIC 0x4244
29 #define HFSP_WRAP_ATTRIB_SLOCK 0x8000
30 #define HFSP_WRAP_ATTRIB_SPARED 0x0200
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
39 #define HFSP_HIDDENDIR_NAME \
40 "\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80HFS+ Private Data"
42 #define HFSP_HARDLINK_TYPE 0x686c6e6b /* 'hlnk' */
43 #define HFSP_HFSPLUS_CREATOR 0x6866732b /* 'hfs+' */
45 #define HFSP_SYMLINK_TYPE 0x736c6e6b /* 'slnk' */
46 #define HFSP_SYMLINK_CREATOR 0x72686170 /* 'rhap' */
48 #define HFSP_MOUNT_VERSION 0x482b4c78 /* 'H+Lx' */
50 /* Structures used on disk */
52 typedef __be32 hfsplus_cnid;
53 typedef __be16 hfsplus_unichr;
55 #define HFSPLUS_MAX_STRLEN 255
56 #define HFSPLUS_ATTR_MAX_STRLEN 127
58 /* A "string" as used in filenames, etc. */
59 struct hfsplus_unistr {
61 hfsplus_unichr unicode[HFSPLUS_MAX_STRLEN];
65 * A "string" is used in attributes file
66 * for name of extended attribute
68 struct hfsplus_attr_unistr {
70 hfsplus_unichr unicode[HFSPLUS_ATTR_MAX_STRLEN];
73 /* POSIX permissions */
83 #define HFSPLUS_FLG_NODUMP 0x01
84 #define HFSPLUS_FLG_IMMUTABLE 0x02
85 #define HFSPLUS_FLG_APPEND 0x04
87 /* A single contiguous area of a file */
88 struct hfsplus_extent {
92 typedef struct hfsplus_extent hfsplus_extent_rec[8];
94 /* Information for a "Fork" in a file */
95 struct hfsplus_fork_raw {
99 hfsplus_extent_rec extents;
102 /* HFS+ Volume Header */
107 __be32 last_mount_vers;
123 __be32 rsrc_clump_sz;
124 __be32 data_clump_sz;
125 hfsplus_cnid next_cnid;
128 __be64 encodings_bmp;
132 struct hfsplus_fork_raw alloc_file;
133 struct hfsplus_fork_raw ext_file;
134 struct hfsplus_fork_raw cat_file;
135 struct hfsplus_fork_raw attr_file;
136 struct hfsplus_fork_raw start_file;
139 /* HFS+ volume attributes */
140 #define HFSPLUS_VOL_UNMNT (1 << 8)
141 #define HFSPLUS_VOL_SPARE_BLK (1 << 9)
142 #define HFSPLUS_VOL_NOCACHE (1 << 10)
143 #define HFSPLUS_VOL_INCNSTNT (1 << 11)
144 #define HFSPLUS_VOL_NODEID_REUSED (1 << 12)
145 #define HFSPLUS_VOL_JOURNALED (1 << 13)
146 #define HFSPLUS_VOL_SOFTLOCK (1 << 15)
148 /* HFS+ BTree node descriptor */
149 struct hfs_bnode_desc {
158 /* HFS+ BTree node types */
159 #define HFS_NODE_INDEX 0x00 /* An internal (index) node */
160 #define HFS_NODE_HEADER 0x01 /* The tree header node (node 0) */
161 #define HFS_NODE_MAP 0x02 /* Holds part of the bitmap of used nodes */
162 #define HFS_NODE_LEAF 0xFF /* A leaf (ndNHeight==1) node */
164 /* HFS+ BTree header */
165 struct hfs_btree_header_rec {
183 /* BTree attributes */
184 #define HFS_TREE_BIGKEYS 2
185 #define HFS_TREE_VARIDXKEYS 4
187 /* HFS+ BTree misc info */
188 #define HFSPLUS_TREE_HEAD 0
189 #define HFSPLUS_NODE_MXSZ 32768
190 #define HFSPLUS_ATTR_TREE_NODE_SIZE 8192
191 #define HFSPLUS_BTREE_HDR_NODE_RECS_COUNT 3
192 #define HFSPLUS_BTREE_HDR_USER_BYTES 128
194 /* Some special File ID numbers (stolen from hfs.h) */
195 #define HFSPLUS_POR_CNID 1 /* Parent Of the Root */
196 #define HFSPLUS_ROOT_CNID 2 /* ROOT directory */
197 #define HFSPLUS_EXT_CNID 3 /* EXTents B-tree */
198 #define HFSPLUS_CAT_CNID 4 /* CATalog B-tree */
199 #define HFSPLUS_BAD_CNID 5 /* BAD blocks file */
200 #define HFSPLUS_ALLOC_CNID 6 /* ALLOCation file */
201 #define HFSPLUS_START_CNID 7 /* STARTup file */
202 #define HFSPLUS_ATTR_CNID 8 /* ATTRibutes file */
203 #define HFSPLUS_EXCH_CNID 15 /* ExchangeFiles temp id */
204 #define HFSPLUS_FIRSTUSER_CNID 16 /* first available user id */
207 #define HFSPLUS_KEY_CASEFOLDING 0xCF /* case-insensitive */
208 #define HFSPLUS_KEY_BINARY 0xBC /* case-sensitive */
210 /* HFS+ catalog entry key */
211 struct hfsplus_cat_key {
214 struct hfsplus_unistr name;
217 #define HFSPLUS_CAT_KEYLEN (sizeof(struct hfsplus_cat_key))
219 /* Structs from hfs.h */
233 /* HFS directory info (stolen from hfs.h */
235 struct hfsp_rect frRect;
237 struct hfsp_point frLocation;
242 struct hfsp_point frScroll;
249 /* HFS+ folder data (part of an hfsplus_cat_entry) */
250 struct hfsplus_cat_folder {
256 __be32 content_mod_date;
257 __be32 attribute_mod_date;
260 struct hfsplus_perm permissions;
261 struct DInfo user_info;
262 struct DXInfo finder_info;
263 __be32 text_encoding;
267 /* HFS file info (stolen from hfs.h) */
272 struct hfsp_point fdLocation;
283 /* HFS+ file data (part of a cat_entry) */
284 struct hfsplus_cat_file {
290 __be32 content_mod_date;
291 __be32 attribute_mod_date;
294 struct hfsplus_perm permissions;
295 struct FInfo user_info;
296 struct FXInfo finder_info;
297 __be32 text_encoding;
300 struct hfsplus_fork_raw data_fork;
301 struct hfsplus_fork_raw rsrc_fork;
304 /* File attribute bits */
305 #define HFSPLUS_FILE_LOCKED 0x0001
306 #define HFSPLUS_FILE_THREAD_EXISTS 0x0002
307 #define HFSPLUS_XATTR_EXISTS 0x0004
308 #define HFSPLUS_ACL_EXISTS 0x0008
310 /* HFS+ catalog thread (part of a cat_entry) */
311 struct hfsplus_cat_thread {
314 hfsplus_cnid parentID;
315 struct hfsplus_unistr nodeName;
318 #define HFSPLUS_MIN_THREAD_SZ 10
320 /* A data record in the catalog tree */
323 struct hfsplus_cat_folder folder;
324 struct hfsplus_cat_file file;
325 struct hfsplus_cat_thread thread;
326 } __packed hfsplus_cat_entry;
328 /* HFS+ catalog entry type */
329 #define HFSPLUS_FOLDER 0x0001
330 #define HFSPLUS_FILE 0x0002
331 #define HFSPLUS_FOLDER_THREAD 0x0003
332 #define HFSPLUS_FILE_THREAD 0x0004
334 /* HFS+ extents tree key */
335 struct hfsplus_ext_key {
343 #define HFSPLUS_EXT_KEYLEN sizeof(struct hfsplus_ext_key)
345 #define HFSPLUS_XATTR_FINDER_INFO_NAME "com.apple.FinderInfo"
346 #define HFSPLUS_XATTR_ACL_NAME "com.apple.system.Security"
348 #define HFSPLUS_ATTR_INLINE_DATA 0x10
349 #define HFSPLUS_ATTR_FORK_DATA 0x20
350 #define HFSPLUS_ATTR_EXTENTS 0x30
352 /* HFS+ attributes tree key */
353 struct hfsplus_attr_key {
358 struct hfsplus_attr_unistr key_name;
361 #define HFSPLUS_ATTR_KEYLEN sizeof(struct hfsplus_attr_key)
363 /* HFS+ fork data attribute */
364 struct hfsplus_attr_fork_data {
367 struct hfsplus_fork_raw the_fork;
370 /* HFS+ extension attribute */
371 struct hfsplus_attr_extents {
374 struct hfsplus_extent extents;
377 #define HFSPLUS_MAX_INLINE_DATA_SIZE 3802
379 /* HFS+ attribute inline data */
380 struct hfsplus_attr_inline_data {
385 u8 raw_bytes[HFSPLUS_MAX_INLINE_DATA_SIZE];
388 /* A data record in the attributes tree */
391 struct hfsplus_attr_fork_data fork_data;
392 struct hfsplus_attr_extents extents;
393 struct hfsplus_attr_inline_data inline_data;
394 } __packed hfsplus_attr_entry;
396 /* HFS+ generic BTree key */
399 struct hfsplus_cat_key cat;
400 struct hfsplus_ext_key ext;
401 struct hfsplus_attr_key attr;
402 } __packed hfsplus_btree_key;