Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * HFS/HFS+ common definitions, inline functions,
4 * and shared functionality.
5 */
6
7#ifndef _HFS_COMMON_H_
8#define _HFS_COMMON_H_
9
10#ifdef pr_fmt
11#undef pr_fmt
12#endif
13
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15
16#define hfs_dbg(fmt, ...) \
17 pr_debug("pid %d:%s:%d %s(): " fmt, \
18 current->pid, __FILE__, __LINE__, __func__, ##__VA_ARGS__) \
19
20/*
21 * Format of structures on disk
22 * Information taken from Apple Technote #1150 (HFS Plus Volume Format)
23 */
24
25/* offsets to various blocks */
26#define HFS_DD_BLK 0 /* Driver Descriptor block */
27#define HFS_PMAP_BLK 1 /* First block of partition map */
28#define HFS_MDB_BLK 2 /* Block (w/i partition) of MDB */
29
30/* magic numbers for various disk blocks */
31#define HFS_DRVR_DESC_MAGIC 0x4552 /* "ER": driver descriptor map */
32#define HFS_OLD_PMAP_MAGIC 0x5453 /* "TS": old-type partition map */
33#define HFS_NEW_PMAP_MAGIC 0x504D /* "PM": new-type partition map */
34#define HFS_SUPER_MAGIC 0x4244 /* "BD": HFS MDB (super block) */
35#define HFS_MFS_SUPER_MAGIC 0xD2D7 /* MFS MDB (super block) */
36
37#define HFSPLUS_VOLHEAD_SIG 0x482b
38#define HFSPLUS_VOLHEAD_SIGX 0x4858
39#define HFSPLUS_SUPER_MAGIC 0x482b
40
41#define HFSP_WRAP_MAGIC 0x4244
42#define HFSP_WRAP_ATTRIB_SLOCK 0x8000
43#define HFSP_WRAP_ATTRIB_SPARED 0x0200
44
45#define HFSP_WRAPOFF_SIG 0x00
46#define HFSP_WRAPOFF_ATTRIB 0x0A
47#define HFSP_WRAPOFF_ABLKSIZE 0x14
48#define HFSP_WRAPOFF_ABLKSTART 0x1C
49#define HFSP_WRAPOFF_EMBEDSIG 0x7C
50#define HFSP_WRAPOFF_EMBEDEXT 0x7E
51
52#define HFSP_HARDLINK_TYPE 0x686c6e6b /* 'hlnk' */
53#define HFSP_HFSPLUS_CREATOR 0x6866732b /* 'hfs+' */
54
55#define HFSP_SYMLINK_TYPE 0x736c6e6b /* 'slnk' */
56#define HFSP_SYMLINK_CREATOR 0x72686170 /* 'rhap' */
57
58#define HFSP_MOUNT_VERSION 0x482b4c78 /* 'H+Lx' */
59
60#define HFSP_HIDDENDIR_NAME \
61 "\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80\xe2\x90\x80HFS+ Private Data"
62
63/* various FIXED size parameters */
64#define HFS_SECTOR_SIZE 512 /* size of an HFS sector */
65#define HFS_SECTOR_SIZE_BITS 9 /* log_2(HFS_SECTOR_SIZE) */
66#define HFS_MAX_VALENCE 32767U
67
68#define HFSPLUS_SECTOR_SIZE HFS_SECTOR_SIZE
69#define HFSPLUS_SECTOR_SHIFT HFS_SECTOR_SIZE_BITS
70#define HFSPLUS_VOLHEAD_SECTOR 2
71#define HFSPLUS_MIN_VERSION 4
72#define HFSPLUS_CURRENT_VERSION 5
73
74#define HFS_NAMELEN 31 /* maximum length of an HFS filename */
75#define HFS_MAX_NAMELEN 128
76
77#define HFSPLUS_MAX_STRLEN 255
78#define HFSPLUS_ATTR_MAX_STRLEN 127
79
80/* Meanings of the drAtrb field of the MDB,
81 * Reference: _Inside Macintosh: Files_ p. 2-61
82 */
83#define HFS_SB_ATTRIB_HLOCK (1 << 7)
84#define HFS_SB_ATTRIB_UNMNT (1 << 8)
85#define HFS_SB_ATTRIB_SPARED (1 << 9)
86#define HFS_SB_ATTRIB_INCNSTNT (1 << 11)
87#define HFS_SB_ATTRIB_SLOCK (1 << 15)
88
89/* values for hfs_cat_rec.cdrType */
90#define HFS_CDR_DIR 0x01 /* folder (directory) */
91#define HFS_CDR_FIL 0x02 /* file */
92#define HFS_CDR_THD 0x03 /* folder (directory) thread */
93#define HFS_CDR_FTH 0x04 /* file thread */
94
95/* legal values for hfs_ext_key.FkType and hfs_file.fork */
96#define HFS_FK_DATA 0x00
97#define HFS_FK_RSRC 0xFF
98
99/* bits in hfs_fil_entry.Flags */
100#define HFS_FIL_LOCK 0x01 /* locked */
101#define HFS_FIL_THD 0x02 /* file thread */
102#define HFS_FIL_DOPEN 0x04 /* data fork open */
103#define HFS_FIL_ROPEN 0x08 /* resource fork open */
104#define HFS_FIL_DIR 0x10 /* directory (always clear) */
105#define HFS_FIL_NOCOPY 0x40 /* copy-protected file */
106#define HFS_FIL_USED 0x80 /* open */
107
108/* bits in hfs_dir_entry.Flags. dirflags is 16 bits. */
109#define HFS_DIR_LOCK 0x01 /* locked */
110#define HFS_DIR_THD 0x02 /* directory thread */
111#define HFS_DIR_INEXPFOLDER 0x04 /* in a shared area */
112#define HFS_DIR_MOUNTED 0x08 /* mounted */
113#define HFS_DIR_DIR 0x10 /* directory (always set) */
114#define HFS_DIR_EXPFOLDER 0x20 /* share point */
115
116/* bits hfs_finfo.fdFlags */
117#define HFS_FLG_INITED 0x0100
118#define HFS_FLG_LOCKED 0x1000
119#define HFS_FLG_INVISIBLE 0x4000
120
121/* Some special File ID numbers */
122#define HFS_POR_CNID 1 /* Parent Of the Root */
123#define HFSPLUS_POR_CNID HFS_POR_CNID
124#define HFS_ROOT_CNID 2 /* ROOT directory */
125#define HFSPLUS_ROOT_CNID HFS_ROOT_CNID
126#define HFS_EXT_CNID 3 /* EXTents B-tree */
127#define HFSPLUS_EXT_CNID HFS_EXT_CNID
128#define HFS_CAT_CNID 4 /* CATalog B-tree */
129#define HFSPLUS_CAT_CNID HFS_CAT_CNID
130#define HFS_BAD_CNID 5 /* BAD blocks file */
131#define HFSPLUS_BAD_CNID HFS_BAD_CNID
132#define HFS_ALLOC_CNID 6 /* ALLOCation file (HFS+) */
133#define HFSPLUS_ALLOC_CNID HFS_ALLOC_CNID
134#define HFS_START_CNID 7 /* STARTup file (HFS+) */
135#define HFSPLUS_START_CNID HFS_START_CNID
136#define HFS_ATTR_CNID 8 /* ATTRibutes file (HFS+) */
137#define HFSPLUS_ATTR_CNID HFS_ATTR_CNID
138#define HFS_EXCH_CNID 15 /* ExchangeFiles temp id */
139#define HFSPLUS_EXCH_CNID HFS_EXCH_CNID
140#define HFS_FIRSTUSER_CNID 16 /* first available user id */
141#define HFSPLUS_FIRSTUSER_CNID HFS_FIRSTUSER_CNID
142
143/*======== HFS/HFS+ structures as they appear on the disk ========*/
144
145typedef __be32 hfsplus_cnid;
146typedef __be16 hfsplus_unichr;
147
148/* Pascal-style string of up to 31 characters */
149struct hfs_name {
150 u8 len;
151 u8 name[HFS_NAMELEN];
152} __packed;
153
154/* A "string" as used in filenames, etc. */
155struct hfsplus_unistr {
156 __be16 length;
157 hfsplus_unichr unicode[HFSPLUS_MAX_STRLEN];
158} __packed;
159
160/*
161 * A "string" is used in attributes file
162 * for name of extended attribute
163 */
164struct hfsplus_attr_unistr {
165 __be16 length;
166 hfsplus_unichr unicode[HFSPLUS_ATTR_MAX_STRLEN];
167} __packed;
168
169enum {
170 HFS_REGULAR_NAME,
171 HFS_XATTR_NAME,
172};
173
174struct hfs_extent {
175 __be16 block;
176 __be16 count;
177};
178typedef struct hfs_extent hfs_extent_rec[3];
179
180/* A single contiguous area of a file */
181struct hfsplus_extent {
182 __be32 start_block;
183 __be32 block_count;
184} __packed;
185typedef struct hfsplus_extent hfsplus_extent_rec[8];
186
187/* Information for a "Fork" in a file */
188struct hfsplus_fork_raw {
189 __be64 total_size;
190 __be32 clump_size;
191 __be32 total_blocks;
192 hfsplus_extent_rec extents;
193} __packed;
194
195struct hfs_mdb {
196 __be16 drSigWord; /* Signature word indicating fs type */
197 __be32 drCrDate; /* fs creation date/time */
198 __be32 drLsMod; /* fs modification date/time */
199 __be16 drAtrb; /* fs attributes */
200 __be16 drNmFls; /* number of files in root directory */
201 __be16 drVBMSt; /* location (in 512-byte blocks)
202 of the volume bitmap */
203 __be16 drAllocPtr; /* location (in allocation blocks)
204 to begin next allocation search */
205 __be16 drNmAlBlks; /* number of allocation blocks */
206 __be32 drAlBlkSiz; /* bytes in an allocation block */
207 __be32 drClpSiz; /* clumpsize, the number of bytes to
208 allocate when extending a file */
209 __be16 drAlBlSt; /* location (in 512-byte blocks)
210 of the first allocation block */
211 __be32 drNxtCNID; /* CNID to assign to the next
212 file or directory created */
213 __be16 drFreeBks; /* number of free allocation blocks */
214 u8 drVN[28]; /* the volume label */
215 __be32 drVolBkUp; /* fs backup date/time */
216 __be16 drVSeqNum; /* backup sequence number */
217 __be32 drWrCnt; /* fs write count */
218 __be32 drXTClpSiz; /* clumpsize for the extents B-tree */
219 __be32 drCTClpSiz; /* clumpsize for the catalog B-tree */
220 __be16 drNmRtDirs; /* number of directories in
221 the root directory */
222 __be32 drFilCnt; /* number of files in the fs */
223 __be32 drDirCnt; /* number of directories in the fs */
224 u8 drFndrInfo[32]; /* data used by the Finder */
225 __be16 drEmbedSigWord; /* embedded volume signature */
226 __be32 drEmbedExtent; /* starting block number (xdrStABN)
227 and number of allocation blocks
228 (xdrNumABlks) occupied by embedded
229 volume */
230 __be32 drXTFlSize; /* bytes in the extents B-tree */
231 hfs_extent_rec drXTExtRec; /* extents B-tree's first 3 extents */
232 __be32 drCTFlSize; /* bytes in the catalog B-tree */
233 hfs_extent_rec drCTExtRec; /* catalog B-tree's first 3 extents */
234} __packed;
235
236/* HFS+ Volume Header */
237struct hfsplus_vh {
238 __be16 signature;
239 __be16 version;
240 __be32 attributes;
241 __be32 last_mount_vers;
242 u32 reserved;
243
244 __be32 create_date;
245 __be32 modify_date;
246 __be32 backup_date;
247 __be32 checked_date;
248
249 __be32 file_count;
250 __be32 folder_count;
251
252 __be32 blocksize;
253 __be32 total_blocks;
254 __be32 free_blocks;
255
256 __be32 next_alloc;
257 __be32 rsrc_clump_sz;
258 __be32 data_clump_sz;
259 hfsplus_cnid next_cnid;
260
261 __be32 write_count;
262 __be64 encodings_bmp;
263
264 u32 finder_info[8];
265
266 struct hfsplus_fork_raw alloc_file;
267 struct hfsplus_fork_raw ext_file;
268 struct hfsplus_fork_raw cat_file;
269 struct hfsplus_fork_raw attr_file;
270 struct hfsplus_fork_raw start_file;
271} __packed;
272
273/* HFS+ volume attributes */
274#define HFSPLUS_VOL_UNMNT (1 << 8)
275#define HFSPLUS_VOL_SPARE_BLK (1 << 9)
276#define HFSPLUS_VOL_NOCACHE (1 << 10)
277#define HFSPLUS_VOL_INCNSTNT (1 << 11)
278#define HFSPLUS_VOL_NODEID_REUSED (1 << 12)
279#define HFSPLUS_VOL_JOURNALED (1 << 13)
280#define HFSPLUS_VOL_SOFTLOCK (1 << 15)
281#define HFSPLUS_VOL_UNUSED_NODE_FIX (1 << 31)
282
283struct hfs_point {
284 __be16 v;
285 __be16 h;
286} __packed;
287
288typedef struct hfs_point hfsp_point;
289
290struct hfs_rect {
291 __be16 top;
292 __be16 left;
293 __be16 bottom;
294 __be16 right;
295} __packed;
296
297typedef struct hfs_rect hfsp_rect;
298
299struct hfs_finfo {
300 __be32 fdType;
301 __be32 fdCreator;
302 __be16 fdFlags;
303 struct hfs_point fdLocation;
304 __be16 fdFldr;
305} __packed;
306
307typedef struct hfs_finfo FInfo;
308
309struct hfs_fxinfo {
310 __be16 fdIconID;
311 u8 fdUnused[8];
312 __be16 fdComment;
313 __be32 fdPutAway;
314} __packed;
315
316typedef struct hfs_fxinfo FXInfo;
317
318struct hfs_dinfo {
319 struct hfs_rect frRect;
320 __be16 frFlags;
321 struct hfs_point frLocation;
322 __be16 frView;
323} __packed;
324
325typedef struct hfs_dinfo DInfo;
326
327struct hfs_dxinfo {
328 struct hfs_point frScroll;
329 __be32 frOpenChain;
330 __be16 frUnused;
331 __be16 frComment;
332 __be32 frPutAway;
333} __packed;
334
335typedef struct hfs_dxinfo DXInfo;
336
337union hfs_finder_info {
338 struct {
339 struct hfs_finfo finfo;
340 struct hfs_fxinfo fxinfo;
341 } file;
342 struct {
343 struct hfs_dinfo dinfo;
344 struct hfs_dxinfo dxinfo;
345 } dir;
346} __packed;
347
348/* The key used in the catalog b-tree: */
349struct hfs_cat_key {
350 u8 key_len; /* number of bytes in the key */
351 u8 reserved; /* padding */
352 __be32 ParID; /* CNID of the parent dir */
353 struct hfs_name CName; /* The filename of the entry */
354} __packed;
355
356/* HFS+ catalog entry key */
357struct hfsplus_cat_key {
358 __be16 key_len;
359 hfsplus_cnid parent;
360 struct hfsplus_unistr name;
361} __packed;
362
363#define HFSPLUS_CAT_KEYLEN (sizeof(struct hfsplus_cat_key))
364
365/* The key used in the extents b-tree: */
366struct hfs_ext_key {
367 u8 key_len; /* number of bytes in the key */
368 u8 FkType; /* HFS_FK_{DATA,RSRC} */
369 __be32 FNum; /* The File ID of the file */
370 __be16 FABN; /* allocation blocks number*/
371} __packed;
372
373/* HFS+ extents tree key */
374struct hfsplus_ext_key {
375 __be16 key_len;
376 u8 fork_type;
377 u8 pad;
378 hfsplus_cnid cnid;
379 __be32 start_block;
380} __packed;
381
382#define HFSPLUS_EXT_KEYLEN sizeof(struct hfsplus_ext_key)
383
384typedef union hfs_btree_key {
385 u8 key_len; /* number of bytes in the key */
386 struct hfs_cat_key cat;
387 struct hfs_ext_key ext;
388} hfs_btree_key;
389
390#define HFS_MAX_CAT_KEYLEN (sizeof(struct hfs_cat_key) - sizeof(u8))
391#define HFS_MAX_EXT_KEYLEN (sizeof(struct hfs_ext_key) - sizeof(u8))
392
393typedef union hfs_btree_key btree_key;
394
395/* The catalog record for a file */
396struct hfs_cat_file {
397 s8 type; /* The type of entry */
398 u8 reserved;
399 u8 Flags; /* Flags such as read-only */
400 s8 Typ; /* file version number = 0 */
401 struct hfs_finfo UsrWds; /* data used by the Finder */
402 __be32 FlNum; /* The CNID */
403 __be16 StBlk; /* obsolete */
404 __be32 LgLen; /* The logical EOF of the data fork*/
405 __be32 PyLen; /* The physical EOF of the data fork */
406 __be16 RStBlk; /* obsolete */
407 __be32 RLgLen; /* The logical EOF of the rsrc fork */
408 __be32 RPyLen; /* The physical EOF of the rsrc fork */
409 __be32 CrDat; /* The creation date */
410 __be32 MdDat; /* The modified date */
411 __be32 BkDat; /* The last backup date */
412 struct hfs_fxinfo FndrInfo; /* more data for the Finder */
413 __be16 ClpSize; /* number of bytes to allocate
414 when extending files */
415 hfs_extent_rec ExtRec; /* first extent record
416 for the data fork */
417 hfs_extent_rec RExtRec; /* first extent record
418 for the resource fork */
419 u32 Resrv; /* reserved by Apple */
420} __packed;
421
422/* the catalog record for a directory */
423struct hfs_cat_dir {
424 s8 type; /* The type of entry */
425 u8 reserved;
426 __be16 Flags; /* flags */
427 __be16 Val; /* Valence: number of files and
428 dirs in the directory */
429 __be32 DirID; /* The CNID */
430 __be32 CrDat; /* The creation date */
431 __be32 MdDat; /* The modification date */
432 __be32 BkDat; /* The last backup date */
433 struct hfs_dinfo UsrInfo; /* data used by the Finder */
434 struct hfs_dxinfo FndrInfo; /* more data used by Finder */
435 u8 Resrv[16]; /* reserved by Apple */
436} __packed;
437
438/* the catalog record for a thread */
439struct hfs_cat_thread {
440 s8 type; /* The type of entry */
441 u8 reserved[9]; /* reserved by Apple */
442 __be32 ParID; /* CNID of parent directory */
443 struct hfs_name CName; /* The name of this entry */
444} __packed;
445
446/* A catalog tree record */
447typedef union hfs_cat_rec {
448 s8 type; /* The type of entry */
449 struct hfs_cat_file file;
450 struct hfs_cat_dir dir;
451 struct hfs_cat_thread thread;
452} hfs_cat_rec;
453
454/* POSIX permissions */
455struct hfsplus_perm {
456 __be32 owner;
457 __be32 group;
458 u8 rootflags;
459 u8 userflags;
460 __be16 mode;
461 __be32 dev;
462} __packed;
463
464#define HFSPLUS_FLG_NODUMP 0x01
465#define HFSPLUS_FLG_IMMUTABLE 0x02
466#define HFSPLUS_FLG_APPEND 0x04
467
468/* HFS/HFS+ BTree node descriptor */
469struct hfs_bnode_desc {
470 __be32 next; /* (V) Number of the next node at this level */
471 __be32 prev; /* (V) Number of the prev node at this level */
472 u8 type; /* (F) The type of node */
473 u8 height; /* (F) The level of this node (leaves=1) */
474 __be16 num_recs; /* (V) The number of records in this node */
475 u16 reserved;
476} __packed;
477
478/* HFS/HFS+ BTree node types */
479#define HFS_NODE_INDEX 0x00 /* An internal (index) node */
480#define HFS_NODE_HEADER 0x01 /* The tree header node (node 0) */
481#define HFS_NODE_MAP 0x02 /* Holds part of the bitmap of used nodes */
482#define HFS_NODE_LEAF 0xFF /* A leaf (ndNHeight==1) node */
483
484/* HFS/HFS+ BTree header */
485struct hfs_btree_header_rec {
486 __be16 depth; /* (V) The number of levels in this B-tree */
487 __be32 root; /* (V) The node number of the root node */
488 __be32 leaf_count; /* (V) The number of leaf records */
489 __be32 leaf_head; /* (V) The number of the first leaf node */
490 __be32 leaf_tail; /* (V) The number of the last leaf node */
491 __be16 node_size; /* (F) The number of bytes in a node (=512) */
492 __be16 max_key_len; /* (F) The length of a key in an index node */
493 __be32 node_count; /* (V) The total number of nodes */
494 __be32 free_nodes; /* (V) The number of unused nodes */
495 u16 reserved1;
496 __be32 clump_size; /* (F) clump size. not usually used. */
497 u8 btree_type; /* (F) BTree type */
498 u8 key_type;
499 __be32 attributes; /* (F) attributes */
500 u32 reserved3[16];
501} __packed;
502
503/* BTree attributes */
504#define BTREE_ATTR_BADCLOSE 0x00000001 /* b-tree not closed properly. not
505 used by hfsplus. */
506#define HFS_TREE_BIGKEYS 0x00000002 /* key length is u16 instead of u8.
507 used by hfsplus. */
508#define HFS_TREE_VARIDXKEYS 0x00000004 /* variable key length instead of
509 max key length. use din catalog
510 b-tree but not in extents
511 b-tree (hfsplus). */
512
513/* HFS+ BTree misc info */
514#define HFSPLUS_TREE_HEAD 0
515#define HFSPLUS_NODE_MXSZ 32768
516#define HFSPLUS_ATTR_TREE_NODE_SIZE 8192
517#define HFSPLUS_BTREE_HDR_NODE_RECS_COUNT 3
518#define HFSPLUS_BTREE_HDR_MAP_REC_INDEX 2 /* Map (bitmap) record in Header node */
519#define HFSPLUS_BTREE_MAP_NODE_REC_INDEX 0 /* Map record in Map Node */
520#define HFSPLUS_BTREE_HDR_USER_BYTES 128
521#define HFSPLUS_BTREE_MAP_NODE_RECS_COUNT 2
522#define HFSPLUS_BTREE_MAP_NODE_RESERVED_BYTES 2
523
524/* btree key type */
525#define HFSPLUS_KEY_CASEFOLDING 0xCF /* case-insensitive */
526#define HFSPLUS_KEY_BINARY 0xBC /* case-sensitive */
527
528/* HFS+ folder data (part of an hfsplus_cat_entry) */
529struct hfsplus_cat_folder {
530 __be16 type;
531 __be16 flags;
532 __be32 valence;
533 hfsplus_cnid id;
534 __be32 create_date;
535 __be32 content_mod_date;
536 __be32 attribute_mod_date;
537 __be32 access_date;
538 __be32 backup_date;
539 struct hfsplus_perm permissions;
540 struct_group_attr(info, __packed,
541 DInfo user_info;
542 DXInfo finder_info;
543 );
544 __be32 text_encoding;
545 __be32 subfolders; /* Subfolder count in HFSX. Reserved in HFS+. */
546} __packed;
547
548/* HFS+ file data (part of a cat_entry) */
549struct hfsplus_cat_file {
550 __be16 type;
551 __be16 flags;
552 u32 reserved1;
553 hfsplus_cnid id;
554 __be32 create_date;
555 __be32 content_mod_date;
556 __be32 attribute_mod_date;
557 __be32 access_date;
558 __be32 backup_date;
559 struct hfsplus_perm permissions;
560 struct_group_attr(info, __packed,
561 FInfo user_info;
562 FXInfo finder_info;
563 );
564 __be32 text_encoding;
565 u32 reserved2;
566
567 struct hfsplus_fork_raw data_fork;
568 struct hfsplus_fork_raw rsrc_fork;
569} __packed;
570
571/* File and folder flag bits */
572#define HFSPLUS_FILE_LOCKED 0x0001
573#define HFSPLUS_FILE_THREAD_EXISTS 0x0002
574#define HFSPLUS_XATTR_EXISTS 0x0004
575#define HFSPLUS_ACL_EXISTS 0x0008
576#define HFSPLUS_HAS_FOLDER_COUNT 0x0010 /* Folder has subfolder count
577 * (HFSX only) */
578
579/* HFS+ catalog thread (part of a cat_entry) */
580struct hfsplus_cat_thread {
581 __be16 type;
582 s16 reserved;
583 hfsplus_cnid parentID;
584 struct hfsplus_unistr nodeName;
585} __packed;
586
587#define HFSPLUS_MIN_THREAD_SZ 10
588
589/* A data record in the catalog tree */
590typedef union {
591 __be16 type;
592 struct hfsplus_cat_folder folder;
593 struct hfsplus_cat_file file;
594 struct hfsplus_cat_thread thread;
595} __packed hfsplus_cat_entry;
596
597/* HFS+ catalog entry type */
598#define HFSPLUS_FOLDER 0x0001
599#define HFSPLUS_FILE 0x0002
600#define HFSPLUS_FOLDER_THREAD 0x0003
601#define HFSPLUS_FILE_THREAD 0x0004
602
603#define HFSPLUS_XATTR_FINDER_INFO_NAME "com.apple.FinderInfo"
604#define HFSPLUS_XATTR_ACL_NAME "com.apple.system.Security"
605
606#define HFSPLUS_ATTR_INLINE_DATA 0x10
607#define HFSPLUS_ATTR_FORK_DATA 0x20
608#define HFSPLUS_ATTR_EXTENTS 0x30
609
610/* HFS+ attributes tree key */
611struct hfsplus_attr_key {
612 __be16 key_len;
613 __be16 pad;
614 hfsplus_cnid cnid;
615 __be32 start_block;
616 struct hfsplus_attr_unistr key_name;
617} __packed;
618
619#define HFSPLUS_ATTR_KEYLEN sizeof(struct hfsplus_attr_key)
620
621/* HFS+ fork data attribute */
622struct hfsplus_attr_fork_data {
623 __be32 record_type;
624 __be32 reserved;
625 struct hfsplus_fork_raw the_fork;
626} __packed;
627
628/* HFS+ extension attribute */
629struct hfsplus_attr_extents {
630 __be32 record_type;
631 __be32 reserved;
632 struct hfsplus_extent extents;
633} __packed;
634
635#define HFSPLUS_MAX_INLINE_DATA_SIZE 3802
636
637/* HFS+ attribute inline data */
638struct hfsplus_attr_inline_data {
639 __be32 record_type;
640 __be32 reserved1;
641 u8 reserved2[6];
642 __be16 length;
643 u8 raw_bytes[HFSPLUS_MAX_INLINE_DATA_SIZE];
644} __packed;
645
646/* A data record in the attributes tree */
647typedef union {
648 __be32 record_type;
649 struct hfsplus_attr_fork_data fork_data;
650 struct hfsplus_attr_extents extents;
651 struct hfsplus_attr_inline_data inline_data;
652} __packed hfsplus_attr_entry;
653
654/* HFS+ generic BTree key */
655typedef union {
656 __be16 key_len;
657 struct hfsplus_cat_key cat;
658 struct hfsplus_ext_key ext;
659 struct hfsplus_attr_key attr;
660} __packed hfsplus_btree_key;
661
662#endif /* _HFS_COMMON_H_ */