2 * linux/include/linux/hfsplus_raw.h
5 * Brad Boyer (flar@pants.nu)
6 * (C) 2003 Ardis Technologies <roman@ardistech.com>
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 "\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80HFS+ Private Data"
41 #define HFSP_HARDLINK_TYPE 0x686c6e6b /* 'hlnk' */
42 #define HFSP_HFSPLUS_CREATOR 0x6866732b /* 'hfs+' */
44 #define HFSP_SYMLINK_TYPE 0x736c6e6b /* 'slnk' */
45 #define HFSP_SYMLINK_CREATOR 0x72686170 /* 'rhap' */
47 #define HFSP_MOUNT_VERSION 0x482b4c78 /* 'H+Lx' */
49 /* Structures used on disk */
51 typedef __be32 hfsplus_cnid;
52 typedef __be16 hfsplus_unichr;
54 /* A "string" as used in filenames, etc. */
55 struct hfsplus_unistr {
57 hfsplus_unichr unicode[255];
60 #define HFSPLUS_MAX_STRLEN 255
62 /* POSIX permissions */
72 #define HFSPLUS_FLG_NODUMP 0x01
73 #define HFSPLUS_FLG_IMMUTABLE 0x02
74 #define HFSPLUS_FLG_APPEND 0x04
76 /* A single contiguous area of a file */
77 struct hfsplus_extent {
81 typedef struct hfsplus_extent hfsplus_extent_rec[8];
83 /* Information for a "Fork" in a file */
84 struct hfsplus_fork_raw {
88 hfsplus_extent_rec extents;
91 /* HFS+ Volume Header */
96 __be32 last_mount_vers;
112 __be32 rsrc_clump_sz;
113 __be32 data_clump_sz;
114 hfsplus_cnid next_cnid;
117 __be64 encodings_bmp;
121 struct hfsplus_fork_raw alloc_file;
122 struct hfsplus_fork_raw ext_file;
123 struct hfsplus_fork_raw cat_file;
124 struct hfsplus_fork_raw attr_file;
125 struct hfsplus_fork_raw start_file;
128 /* HFS+ volume attributes */
129 #define HFSPLUS_VOL_UNMNT (1 << 8)
130 #define HFSPLUS_VOL_SPARE_BLK (1 << 9)
131 #define HFSPLUS_VOL_NOCACHE (1 << 10)
132 #define HFSPLUS_VOL_INCNSTNT (1 << 11)
133 #define HFSPLUS_VOL_NODEID_REUSED (1 << 12)
134 #define HFSPLUS_VOL_JOURNALED (1 << 13)
135 #define HFSPLUS_VOL_SOFTLOCK (1 << 15)
137 /* HFS+ BTree node descriptor */
138 struct hfs_bnode_desc {
147 /* HFS+ BTree node types */
148 #define HFS_NODE_INDEX 0x00
149 #define HFS_NODE_HEADER 0x01
150 #define HFS_NODE_MAP 0x02
151 #define HFS_NODE_LEAF 0xFF
153 /* HFS+ BTree header */
154 struct hfs_btree_header_rec {
172 /* BTree attributes */
173 #define HFS_TREE_BIGKEYS 2
174 #define HFS_TREE_VARIDXKEYS 4
176 /* HFS+ BTree misc info */
177 #define HFSPLUS_TREE_HEAD 0
178 #define HFSPLUS_NODE_MXSZ 32768
180 /* Some special File ID numbers (stolen from hfs.h) */
181 #define HFSPLUS_POR_CNID 1 /* Parent Of the Root */
182 #define HFSPLUS_ROOT_CNID 2 /* ROOT directory */
183 #define HFSPLUS_EXT_CNID 3 /* EXTents B-tree */
184 #define HFSPLUS_CAT_CNID 4 /* CATalog B-tree */
185 #define HFSPLUS_BAD_CNID 5 /* BAD blocks file */
186 #define HFSPLUS_ALLOC_CNID 6 /* ALLOCation file */
187 #define HFSPLUS_START_CNID 7 /* STARTup file */
188 #define HFSPLUS_ATTR_CNID 8 /* ATTRibutes file */
189 #define HFSPLUS_EXCH_CNID 15 /* ExchangeFiles temp id */
190 #define HFSPLUS_FIRSTUSER_CNID 16 /* first available user id */
193 #define HFSPLUS_KEY_CASEFOLDING 0xCF /* case-insensitive */
194 #define HFSPLUS_KEY_BINARY 0xBC /* case-sensitive */
196 /* HFS+ catalog entry key */
197 struct hfsplus_cat_key {
200 struct hfsplus_unistr name;
204 /* Structs from hfs.h */
218 /* HFS directory info (stolen from hfs.h */
220 struct hfsp_rect frRect;
222 struct hfsp_point frLocation;
227 struct hfsp_point frScroll;
234 /* HFS+ folder data (part of an hfsplus_cat_entry) */
235 struct hfsplus_cat_folder {
241 __be32 content_mod_date;
242 __be32 attribute_mod_date;
245 struct hfsplus_perm permissions;
246 struct DInfo user_info;
247 struct DXInfo finder_info;
248 __be32 text_encoding;
252 /* HFS file info (stolen from hfs.h) */
257 struct hfsp_point fdLocation;
268 /* HFS+ file data (part of a cat_entry) */
269 struct hfsplus_cat_file {
275 __be32 content_mod_date;
276 __be32 attribute_mod_date;
279 struct hfsplus_perm permissions;
280 struct FInfo user_info;
281 struct FXInfo finder_info;
282 __be32 text_encoding;
285 struct hfsplus_fork_raw data_fork;
286 struct hfsplus_fork_raw rsrc_fork;
289 /* File attribute bits */
290 #define HFSPLUS_FILE_LOCKED 0x0001
291 #define HFSPLUS_FILE_THREAD_EXISTS 0x0002
293 /* HFS+ catalog thread (part of a cat_entry) */
294 struct hfsplus_cat_thread {
297 hfsplus_cnid parentID;
298 struct hfsplus_unistr nodeName;
301 #define HFSPLUS_MIN_THREAD_SZ 10
303 /* A data record in the catalog tree */
306 struct hfsplus_cat_folder folder;
307 struct hfsplus_cat_file file;
308 struct hfsplus_cat_thread thread;
309 } __packed hfsplus_cat_entry;
311 /* HFS+ catalog entry type */
312 #define HFSPLUS_FOLDER 0x0001
313 #define HFSPLUS_FILE 0x0002
314 #define HFSPLUS_FOLDER_THREAD 0x0003
315 #define HFSPLUS_FILE_THREAD 0x0004
317 /* HFS+ extents tree key */
318 struct hfsplus_ext_key {
326 #define HFSPLUS_EXT_KEYLEN 12
328 /* HFS+ generic BTree key */
331 struct hfsplus_cat_key cat;
332 struct hfsplus_ext_key ext;
333 } __packed hfsplus_btree_key;