0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _LINUX_HFSPLUS_RAW_H
0015 #define _LINUX_HFSPLUS_RAW_H
0016
0017 #include <linux/types.h>
0018
0019
0020 #define HFSPLUS_SECTOR_SIZE 512
0021 #define HFSPLUS_SECTOR_SHIFT 9
0022 #define HFSPLUS_VOLHEAD_SECTOR 2
0023 #define HFSPLUS_VOLHEAD_SIG 0x482b
0024 #define HFSPLUS_VOLHEAD_SIGX 0x4858
0025 #define HFSPLUS_SUPER_MAGIC 0x482b
0026 #define HFSPLUS_MIN_VERSION 4
0027 #define HFSPLUS_CURRENT_VERSION 5
0028
0029 #define HFSP_WRAP_MAGIC 0x4244
0030 #define HFSP_WRAP_ATTRIB_SLOCK 0x8000
0031 #define HFSP_WRAP_ATTRIB_SPARED 0x0200
0032
0033 #define HFSP_WRAPOFF_SIG 0x00
0034 #define HFSP_WRAPOFF_ATTRIB 0x0A
0035 #define HFSP_WRAPOFF_ABLKSIZE 0x14
0036 #define HFSP_WRAPOFF_ABLKSTART 0x1C
0037 #define HFSP_WRAPOFF_EMBEDSIG 0x7C
0038 #define HFSP_WRAPOFF_EMBEDEXT 0x7E
0039
0040 #define HFSP_HIDDENDIR_NAME \
0041 "\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80HFS+ Private Data"
0042
0043 #define HFSP_HARDLINK_TYPE 0x686c6e6b
0044 #define HFSP_HFSPLUS_CREATOR 0x6866732b
0045
0046 #define HFSP_SYMLINK_TYPE 0x736c6e6b
0047 #define HFSP_SYMLINK_CREATOR 0x72686170
0048
0049 #define HFSP_MOUNT_VERSION 0x482b4c78
0050
0051
0052
0053 typedef __be32 hfsplus_cnid;
0054 typedef __be16 hfsplus_unichr;
0055
0056 #define HFSPLUS_MAX_STRLEN 255
0057 #define HFSPLUS_ATTR_MAX_STRLEN 127
0058
0059
0060 struct hfsplus_unistr {
0061 __be16 length;
0062 hfsplus_unichr unicode[HFSPLUS_MAX_STRLEN];
0063 } __packed;
0064
0065
0066
0067
0068
0069 struct hfsplus_attr_unistr {
0070 __be16 length;
0071 hfsplus_unichr unicode[HFSPLUS_ATTR_MAX_STRLEN];
0072 } __packed;
0073
0074
0075 struct hfsplus_perm {
0076 __be32 owner;
0077 __be32 group;
0078 u8 rootflags;
0079 u8 userflags;
0080 __be16 mode;
0081 __be32 dev;
0082 } __packed;
0083
0084 #define HFSPLUS_FLG_NODUMP 0x01
0085 #define HFSPLUS_FLG_IMMUTABLE 0x02
0086 #define HFSPLUS_FLG_APPEND 0x04
0087
0088
0089 struct hfsplus_extent {
0090 __be32 start_block;
0091 __be32 block_count;
0092 } __packed;
0093 typedef struct hfsplus_extent hfsplus_extent_rec[8];
0094
0095
0096 struct hfsplus_fork_raw {
0097 __be64 total_size;
0098 __be32 clump_size;
0099 __be32 total_blocks;
0100 hfsplus_extent_rec extents;
0101 } __packed;
0102
0103
0104 struct hfsplus_vh {
0105 __be16 signature;
0106 __be16 version;
0107 __be32 attributes;
0108 __be32 last_mount_vers;
0109 u32 reserved;
0110
0111 __be32 create_date;
0112 __be32 modify_date;
0113 __be32 backup_date;
0114 __be32 checked_date;
0115
0116 __be32 file_count;
0117 __be32 folder_count;
0118
0119 __be32 blocksize;
0120 __be32 total_blocks;
0121 __be32 free_blocks;
0122
0123 __be32 next_alloc;
0124 __be32 rsrc_clump_sz;
0125 __be32 data_clump_sz;
0126 hfsplus_cnid next_cnid;
0127
0128 __be32 write_count;
0129 __be64 encodings_bmp;
0130
0131 u32 finder_info[8];
0132
0133 struct hfsplus_fork_raw alloc_file;
0134 struct hfsplus_fork_raw ext_file;
0135 struct hfsplus_fork_raw cat_file;
0136 struct hfsplus_fork_raw attr_file;
0137 struct hfsplus_fork_raw start_file;
0138 } __packed;
0139
0140
0141 #define HFSPLUS_VOL_UNMNT (1 << 8)
0142 #define HFSPLUS_VOL_SPARE_BLK (1 << 9)
0143 #define HFSPLUS_VOL_NOCACHE (1 << 10)
0144 #define HFSPLUS_VOL_INCNSTNT (1 << 11)
0145 #define HFSPLUS_VOL_NODEID_REUSED (1 << 12)
0146 #define HFSPLUS_VOL_JOURNALED (1 << 13)
0147 #define HFSPLUS_VOL_SOFTLOCK (1 << 15)
0148 #define HFSPLUS_VOL_UNUSED_NODE_FIX (1 << 31)
0149
0150
0151 struct hfs_bnode_desc {
0152 __be32 next;
0153 __be32 prev;
0154 s8 type;
0155 u8 height;
0156 __be16 num_recs;
0157 u16 reserved;
0158 } __packed;
0159
0160
0161 #define HFS_NODE_INDEX 0x00
0162 #define HFS_NODE_HEADER 0x01
0163 #define HFS_NODE_MAP 0x02
0164 #define HFS_NODE_LEAF 0xFF
0165
0166
0167 struct hfs_btree_header_rec {
0168 __be16 depth;
0169 __be32 root;
0170 __be32 leaf_count;
0171 __be32 leaf_head;
0172 __be32 leaf_tail;
0173 __be16 node_size;
0174 __be16 max_key_len;
0175 __be32 node_count;
0176 __be32 free_nodes;
0177 u16 reserved1;
0178 __be32 clump_size;
0179 u8 btree_type;
0180 u8 key_type;
0181 __be32 attributes;
0182 u32 reserved3[16];
0183 } __packed;
0184
0185
0186 #define HFS_TREE_BIGKEYS 2
0187 #define HFS_TREE_VARIDXKEYS 4
0188
0189
0190 #define HFSPLUS_TREE_HEAD 0
0191 #define HFSPLUS_NODE_MXSZ 32768
0192 #define HFSPLUS_ATTR_TREE_NODE_SIZE 8192
0193 #define HFSPLUS_BTREE_HDR_NODE_RECS_COUNT 3
0194 #define HFSPLUS_BTREE_HDR_USER_BYTES 128
0195
0196
0197 #define HFSPLUS_POR_CNID 1
0198 #define HFSPLUS_ROOT_CNID 2
0199 #define HFSPLUS_EXT_CNID 3
0200 #define HFSPLUS_CAT_CNID 4
0201 #define HFSPLUS_BAD_CNID 5
0202 #define HFSPLUS_ALLOC_CNID 6
0203 #define HFSPLUS_START_CNID 7
0204 #define HFSPLUS_ATTR_CNID 8
0205 #define HFSPLUS_EXCH_CNID 15
0206 #define HFSPLUS_FIRSTUSER_CNID 16
0207
0208
0209 #define HFSPLUS_KEY_CASEFOLDING 0xCF
0210 #define HFSPLUS_KEY_BINARY 0xBC
0211
0212
0213 struct hfsplus_cat_key {
0214 __be16 key_len;
0215 hfsplus_cnid parent;
0216 struct hfsplus_unistr name;
0217 } __packed;
0218
0219 #define HFSPLUS_CAT_KEYLEN (sizeof(struct hfsplus_cat_key))
0220
0221
0222 struct hfsp_point {
0223 __be16 v;
0224 __be16 h;
0225 } __packed;
0226
0227 struct hfsp_rect {
0228 __be16 top;
0229 __be16 left;
0230 __be16 bottom;
0231 __be16 right;
0232 } __packed;
0233
0234
0235
0236 struct DInfo {
0237 struct hfsp_rect frRect;
0238 __be16 frFlags;
0239 struct hfsp_point frLocation;
0240 __be16 frView;
0241 } __packed;
0242
0243 struct DXInfo {
0244 struct hfsp_point frScroll;
0245 __be32 frOpenChain;
0246 __be16 frUnused;
0247 __be16 frComment;
0248 __be32 frPutAway;
0249 } __packed;
0250
0251
0252 struct hfsplus_cat_folder {
0253 __be16 type;
0254 __be16 flags;
0255 __be32 valence;
0256 hfsplus_cnid id;
0257 __be32 create_date;
0258 __be32 content_mod_date;
0259 __be32 attribute_mod_date;
0260 __be32 access_date;
0261 __be32 backup_date;
0262 struct hfsplus_perm permissions;
0263 struct_group_attr(info, __packed,
0264 struct DInfo user_info;
0265 struct DXInfo finder_info;
0266 );
0267 __be32 text_encoding;
0268 __be32 subfolders;
0269 } __packed;
0270
0271
0272 struct FInfo {
0273 __be32 fdType;
0274 __be32 fdCreator;
0275 __be16 fdFlags;
0276 struct hfsp_point fdLocation;
0277 __be16 fdFldr;
0278 } __packed;
0279
0280 struct FXInfo {
0281 __be16 fdIconID;
0282 u8 fdUnused[8];
0283 __be16 fdComment;
0284 __be32 fdPutAway;
0285 } __packed;
0286
0287
0288 struct hfsplus_cat_file {
0289 __be16 type;
0290 __be16 flags;
0291 u32 reserved1;
0292 hfsplus_cnid id;
0293 __be32 create_date;
0294 __be32 content_mod_date;
0295 __be32 attribute_mod_date;
0296 __be32 access_date;
0297 __be32 backup_date;
0298 struct hfsplus_perm permissions;
0299 struct_group_attr(info, __packed,
0300 struct FInfo user_info;
0301 struct FXInfo finder_info;
0302 );
0303 __be32 text_encoding;
0304 u32 reserved2;
0305
0306 struct hfsplus_fork_raw data_fork;
0307 struct hfsplus_fork_raw rsrc_fork;
0308 } __packed;
0309
0310
0311 #define HFSPLUS_FILE_LOCKED 0x0001
0312 #define HFSPLUS_FILE_THREAD_EXISTS 0x0002
0313 #define HFSPLUS_XATTR_EXISTS 0x0004
0314 #define HFSPLUS_ACL_EXISTS 0x0008
0315 #define HFSPLUS_HAS_FOLDER_COUNT 0x0010
0316
0317
0318
0319 struct hfsplus_cat_thread {
0320 __be16 type;
0321 s16 reserved;
0322 hfsplus_cnid parentID;
0323 struct hfsplus_unistr nodeName;
0324 } __packed;
0325
0326 #define HFSPLUS_MIN_THREAD_SZ 10
0327
0328
0329 typedef union {
0330 __be16 type;
0331 struct hfsplus_cat_folder folder;
0332 struct hfsplus_cat_file file;
0333 struct hfsplus_cat_thread thread;
0334 } __packed hfsplus_cat_entry;
0335
0336
0337 #define HFSPLUS_FOLDER 0x0001
0338 #define HFSPLUS_FILE 0x0002
0339 #define HFSPLUS_FOLDER_THREAD 0x0003
0340 #define HFSPLUS_FILE_THREAD 0x0004
0341
0342
0343 struct hfsplus_ext_key {
0344 __be16 key_len;
0345 u8 fork_type;
0346 u8 pad;
0347 hfsplus_cnid cnid;
0348 __be32 start_block;
0349 } __packed;
0350
0351 #define HFSPLUS_EXT_KEYLEN sizeof(struct hfsplus_ext_key)
0352
0353 #define HFSPLUS_XATTR_FINDER_INFO_NAME "com.apple.FinderInfo"
0354 #define HFSPLUS_XATTR_ACL_NAME "com.apple.system.Security"
0355
0356 #define HFSPLUS_ATTR_INLINE_DATA 0x10
0357 #define HFSPLUS_ATTR_FORK_DATA 0x20
0358 #define HFSPLUS_ATTR_EXTENTS 0x30
0359
0360
0361 struct hfsplus_attr_key {
0362 __be16 key_len;
0363 __be16 pad;
0364 hfsplus_cnid cnid;
0365 __be32 start_block;
0366 struct hfsplus_attr_unistr key_name;
0367 } __packed;
0368
0369 #define HFSPLUS_ATTR_KEYLEN sizeof(struct hfsplus_attr_key)
0370
0371
0372 struct hfsplus_attr_fork_data {
0373 __be32 record_type;
0374 __be32 reserved;
0375 struct hfsplus_fork_raw the_fork;
0376 } __packed;
0377
0378
0379 struct hfsplus_attr_extents {
0380 __be32 record_type;
0381 __be32 reserved;
0382 struct hfsplus_extent extents;
0383 } __packed;
0384
0385 #define HFSPLUS_MAX_INLINE_DATA_SIZE 3802
0386
0387
0388 struct hfsplus_attr_inline_data {
0389 __be32 record_type;
0390 __be32 reserved1;
0391 u8 reserved2[6];
0392 __be16 length;
0393 u8 raw_bytes[HFSPLUS_MAX_INLINE_DATA_SIZE];
0394 } __packed;
0395
0396
0397 typedef union {
0398 __be32 record_type;
0399 struct hfsplus_attr_fork_data fork_data;
0400 struct hfsplus_attr_extents extents;
0401 struct hfsplus_attr_inline_data inline_data;
0402 } __packed hfsplus_attr_entry;
0403
0404
0405 typedef union {
0406 __be16 key_len;
0407 struct hfsplus_cat_key cat;
0408 struct hfsplus_ext_key ext;
0409 struct hfsplus_attr_key attr;
0410 } __packed hfsplus_btree_key;
0411
0412 #endif