]> git.saurik.com Git - apple/hfs.git/blob - livefiles_hfs_plugin/lf_hfs_format.h
hfs-522.0.9.tar.gz
[apple/hfs.git] / livefiles_hfs_plugin / lf_hfs_format.h
1 /* Copyright © 2017-2018 Apple Inc. All rights reserved.
2 *
3 * lf_hfs_format.h
4 * livefiles_hfs
5 *
6 * Created by Or Haimovich on 18/3/18.
7 */
8
9 #ifndef lf_hfs_format_h
10 #define lf_hfs_format_h
11
12 #include <stdlib.h>
13 #include "lf_hfs_common.h"
14
15 /*
16 * Files in the "HFS+ Private Data" folder have one of the following prefixes
17 * followed by a decimal number (no leading zeros) for the file ID.
18 *
19 * Note: Earlier version of Mac OS X used a 32 bit random number for the link
20 * ref number instead of the file id.
21 *
22 * e.g. iNode7182000 and temp3296
23 */
24 #define HFS_INODE_PREFIX "iNode"
25 #define HFS_DELETE_PREFIX "temp"
26
27 /*
28 * Files in the ".HFS+ Private Directory Data" folder have the following
29 * prefix followed by a decimal number (no leading zeros) for the file ID.
30 *
31 * e.g. dir_555
32 */
33 #define HFS_DIRINODE_PREFIX "dir_"
34
35 /*
36 * Atrributes B-tree Data Record
37 *
38 * For small attributes, whose entire value is stored
39 * within a single B-tree record.
40 */
41 struct HFSPlusAttrData {
42 u_int32_t recordType; /* == kHFSPlusAttrInlineData */
43 u_int32_t reserved[2];
44 u_int32_t attrSize; /* size of attribute data in bytes */
45 u_int8_t attrData[2]; /* variable length */
46 } __attribute__((aligned(2), packed));
47 typedef struct HFSPlusAttrData HFSPlusAttrData;
48
49 /*
50 * Hardlink inodes save the head of the link chain in
51 * an extended attribute named FIRST_LINK_XATTR_NAME.
52 * The attribute data is the decimal value in ASCII
53 * of the cnid for the first link in the chain.
54 *
55 * This extended attribute is private (i.e. its not
56 * exported in the getxattr/listxattr POSIX APIs).
57 */
58 #define FIRST_LINK_XATTR_NAME "com.apple.system.hfs.firstlink"
59 #define FIRST_LINK_XATTR_REC_SIZE (sizeof(HFSPlusAttrData) - 2 + 12)
60
61 /*
62 * Mac OS X has two special directories on HFS+ volumes for hardlinked files
63 * and hardlinked directories as well as for open-unlinked files.
64 *
65 * These directories and their contents are not exported from the filesystem
66 * under Mac OS X.
67 */
68 #define HFSPLUSMETADATAFOLDER "\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80HFS+ Private Data"
69 #define HFSPLUS_DIR_METADATA_FOLDER ".HFS+ Private Directory Data\xd"
70
71
72 /* Signatures used to differentiate between HFS and HFS Plus volumes */
73 enum {
74 kHFSSigWord = 0x4244, /* 'BD' in ASCII */
75 kHFSPlusSigWord = 0x482B, /* 'H+' in ASCII */
76 kHFSXSigWord = 0x4858, /* 'HX' in ASCII */
77 kHFSPlusVersion = 0x0004, /* 'H+' volumes are version 4 only */
78 kHFSXVersion = 0x0005, /* 'HX' volumes start with version 5 */
79 kHFSPlusMountVersion = 0x31302E30, /* '10.0' for Mac OS X */
80 kHFSJMountVersion = 0x4846534a, /* 'HFSJ' for journaled HFS+ on OS X */
81 kFSKMountVersion = 0x46534b21 /* 'FSK!' for failed journal replay */
82 };
83
84 /*
85 * The name space ID for generating an HFS volume UUID
86 *
87 * B3E20F39-F292-11D6-97A4-00306543ECAC
88 */
89 #define HFS_UUID_NAMESPACE_ID "\xB3\xE2\x0F\x39\xF2\x92\x11\xD6\x97\xA4\x00\x30\x65\x43\xEC\xAC"
90
91 enum {
92 kHFSMaxVolumeNameChars = 27,
93 kHFSMaxFileNameChars = 31,
94 kHFSPlusMaxFileNameChars = 255
95 };
96
97 /*
98 * Indirect link files (hard links) have the following type/creator.
99 */
100 enum {
101 kHardLinkFileType = 0x686C6E6B, /* 'hlnk' */
102 kHFSPlusCreator = 0x6866732B /* 'hfs+' */
103 };
104
105 /*
106 * File type and creator for symbolic links
107 */
108 enum {
109 kSymLinkFileType = 0x736C6E6B, /* 'slnk' */
110 kSymLinkCreator = 0x72686170 /* 'rhap' */
111 };
112
113
114 /* Extent overflow file data structures */
115
116 /* HFS Extent key */
117 struct HFSExtentKey {
118 u_int8_t keyLength; /* length of key, excluding this field */
119 u_int8_t forkType; /* 0 = data fork, FF = resource fork */
120 u_int32_t fileID; /* file ID */
121 u_int16_t startBlock; /* first file allocation block number in this extent */
122 } __attribute__((aligned(2), packed));
123 typedef struct HFSExtentKey HFSExtentKey;
124
125 /* HFS Plus Extent key */
126 struct HFSPlusExtentKey {
127 u_int16_t keyLength; /* length of key, excluding this field */
128 u_int8_t forkType; /* 0 = data fork, FF = resource fork */
129 u_int8_t pad; /* make the other fields align on 32-bit boundary */
130 u_int32_t fileID; /* file ID */
131 u_int32_t startBlock; /* first file allocation block number in this extent */
132 } __attribute__((aligned(2), packed));
133 typedef struct HFSPlusExtentKey HFSPlusExtentKey;
134
135
136 /* HFS extent descriptor */
137 struct HFSExtentDescriptor {
138 u_int16_t startBlock; /* first allocation block */
139 u_int16_t blockCount; /* number of allocation blocks */
140 } __attribute__((aligned(2), packed));
141 typedef struct HFSExtentDescriptor HFSExtentDescriptor;
142
143 /* HFS Plus extent descriptor */
144 struct HFSPlusExtentDescriptor {
145 u_int32_t startBlock; /* first allocation block */
146 u_int32_t blockCount; /* number of allocation blocks */
147 } __attribute__((aligned(2), packed));
148 typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor;
149
150 enum {
151 kHFSExtentDensity = 3,
152 kHFSPlusExtentDensity = 8
153 };
154
155 /* HFS extent record */
156 typedef HFSExtentDescriptor HFSExtentRecord[3];
157
158 /* HFS Plus extent record */
159 typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
160
161 /* Catalog Key Name Comparison Type */
162 enum {
163 kHFSCaseFolding = 0xCF, /* case folding (case-insensitive) */
164 kHFSBinaryCompare = 0xBC /* binary compare (case-sensitive) */
165 };
166
167 /* HFS Plus Fork data info - 80 bytes */
168 struct HFSPlusForkData {
169 u_int64_t logicalSize; /* fork's logical size in bytes */
170 u_int32_t clumpSize; /* fork's clump size in bytes */
171 u_int32_t totalBlocks; /* total blocks used by this fork */
172 HFSPlusExtentRecord extents; /* initial set of extents */
173 } __attribute__((aligned(2), packed));
174 typedef struct HFSPlusForkData HFSPlusForkData;
175
176 /* HFS Plus catalog thread record -- 264 bytes */
177 struct HFSPlusCatalogThread {
178 int16_t recordType; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
179 int16_t reserved; /* reserved - initialized as zero */
180 u_int32_t parentID; /* parent ID for this catalog node */
181 HFSUniStr255 nodeName; /* name of this catalog node (variable length) */
182 } __attribute__((aligned(2), packed));
183 typedef struct HFSPlusCatalogThread HFSPlusCatalogThread;
184
185 /* Catalog file data structures */
186
187 enum {
188 kHFSRootParentID = 1, /* Parent ID of the root folder */
189 kHFSRootFolderID = 2, /* Folder ID of the root folder */
190 kHFSExtentsFileID = 3, /* File ID of the extents file */
191 kHFSCatalogFileID = 4, /* File ID of the catalog file */
192 kHFSBadBlockFileID = 5, /* File ID of the bad allocation block file */
193 kHFSAllocationFileID = 6, /* File ID of the allocation file (HFS Plus only) */
194 kHFSStartupFileID = 7, /* File ID of the startup file (HFS Plus only) */
195 kHFSAttributesFileID = 8, /* File ID of the attribute file (HFS Plus only) */
196 kHFSAttributeDataFileID = 13, /* Used in Mac OS X runtime for extent based attributes */
197 /* kHFSAttributeDataFileID is never stored on disk. */
198 kHFSRepairCatalogFileID = 14, /* Used when rebuilding Catalog B-tree */
199 kHFSBogusExtentFileID = 15, /* Used for exchanging extents in extents file */
200 kHFSFirstUserCatalogNodeID = 16
201 };
202
203 /* HFS Plus catalog key */
204 struct HFSPlusCatalogKey {
205 u_int16_t keyLength; /* key length (in bytes) */
206 u_int32_t parentID; /* parent folder ID */
207 HFSUniStr255 nodeName; /* catalog node name */
208 } __attribute__((aligned(2), packed));
209 typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
210
211 /* Catalog record types */
212 enum {
213 kHFSPlusFolderRecord = 1, /* Folder record */
214 kHFSPlusFileRecord = 2, /* File record */
215 kHFSPlusFolderThreadRecord = 3, /* Folder thread record */
216 kHFSPlusFileThreadRecord = 4 /* File thread record */
217 };
218
219 /* Catalog file record flags */
220 enum {
221 kHFSFileLockedBit = 0x0000, /* file is locked and cannot be written to */
222 kHFSFileLockedMask = 0x0001,
223
224 kHFSThreadExistsBit = 0x0001, /* a file thread record exists for this file */
225 kHFSThreadExistsMask = 0x0002,
226
227 kHFSHasAttributesBit = 0x0002, /* object has extended attributes */
228 kHFSHasAttributesMask = 0x0004,
229
230 kHFSHasSecurityBit = 0x0003, /* object has security data (ACLs) */
231 kHFSHasSecurityMask = 0x0008,
232
233 kHFSHasFolderCountBit = 0x0004, /* only for HFSX, folder maintains a separate sub-folder count */
234 kHFSHasFolderCountMask = 0x0010, /* (sum of folder records and directory hard links) */
235
236 kHFSHasLinkChainBit = 0x0005, /* has hardlink chain (inode or link) */
237 kHFSHasLinkChainMask = 0x0020,
238
239 kHFSHasChildLinkBit = 0x0006, /* folder has a child that's a dir link */
240 kHFSHasChildLinkMask = 0x0040,
241
242 kHFSHasDateAddedBit = 0x0007, /* File/Folder has the date-added stored in the finder info. */
243 kHFSHasDateAddedMask = 0x0080,
244
245 kHFSFastDevPinnedBit = 0x0008, /* this file has been pinned to the fast-device by the hot-file code on cooperative fusion */
246 kHFSFastDevPinnedMask = 0x0100,
247
248 kHFSDoNotFastDevPinBit = 0x0009, /* this file can not be pinned to the fast-device */
249 kHFSDoNotFastDevPinMask = 0x0200,
250
251 kHFSFastDevCandidateBit = 0x000a, /* this item is a potential candidate for fast-dev pinning (as are any of its descendents */
252 kHFSFastDevCandidateMask = 0x0400,
253
254 kHFSAutoCandidateBit = 0x000b, /* this item was automatically marked as a fast-dev candidate by the kernel */
255 kHFSAutoCandidateMask = 0x0800
256
257 // There are only 4 flag bits remaining: 0x1000, 0x2000, 0x4000, 0x8000
258
259 };
260
261 /*
262 * Atrributes B-tree Data Record
263 *
264 * For small attributes, whose entire value is stored
265 * within a single B-tree record.
266 */
267
268 /* Attribute key */
269 enum { kHFSMaxAttrNameLen = 127 };
270 struct HFSPlusAttrKey {
271 u_int16_t keyLength; /* key length (in bytes) */
272 u_int16_t pad; /* set to zero */
273 u_int32_t fileID; /* file associated with attribute */
274 u_int32_t startBlock; /* first allocation block number for extents */
275 u_int16_t attrNameLen; /* number of unicode characters */
276 u_int16_t attrName[kHFSMaxAttrNameLen]; /* attribute name (Unicode) */
277 } __attribute__((aligned(2), packed));
278 typedef struct HFSPlusAttrKey HFSPlusAttrKey;
279
280 #define kHFSPlusAttrKeyMaximumLength (sizeof(HFSPlusAttrKey) - sizeof(u_int16_t))
281 #define kHFSPlusAttrKeyMinimumLength (kHFSPlusAttrKeyMaximumLength - kHFSMaxAttrNameLen*sizeof(u_int16_t))
282
283
284 /* Key and node lengths */
285 enum {
286 kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(u_int16_t),
287 kHFSExtentKeyMaximumLength = sizeof(HFSExtentKey) - sizeof(u_int8_t),
288 kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(u_int16_t),
289 kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(u_int16_t),
290 kHFSPlusCatalogMinNodeSize = 4096,
291 kHFSPlusExtentMinNodeSize = 512,
292 kHFSPlusAttrMinNodeSize = 4096
293 };
294
295 /* HFS and HFS Plus volume attribute bits */
296 enum {
297 /* Bits 0-6 are reserved (always cleared by MountVol call) */
298 kHFSVolumeHardwareLockBit = 7, /* volume is locked by hardware */
299 kHFSVolumeUnmountedBit = 8, /* volume was successfully unmounted */
300 kHFSVolumeSparedBlocksBit = 9, /* volume has bad blocks spared */
301 kHFSVolumeNoCacheRequiredBit = 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */
302 kHFSBootVolumeInconsistentBit = 11, /* boot volume is inconsistent (System 7.6 and later) */
303 kHFSCatalogNodeIDsReusedBit = 12,
304 kHFSVolumeJournaledBit = 13, /* this volume has a journal on it */
305 kHFSVolumeInconsistentBit = 14, /* serious inconsistencies detected at runtime */
306 kHFSVolumeSoftwareLockBit = 15, /* volume is locked by software */
307 /*
308 * HFS only has 16 bits of attributes in the MDB, but HFS Plus has 32 bits.
309 * Therefore, bits 16-31 can only be used on HFS Plus.
310 */
311 kHFSUnusedNodeFixBit = 31, /* Unused nodes in the Catalog B-tree have been zero-filled. See Radar #6947811. */
312 kHFSContentProtectionBit = 30, /* Volume has per-file content protection */
313
314 /*** Keep these in sync with the bits above ! ****/
315 kHFSVolumeHardwareLockMask = 0x00000080,
316 kHFSVolumeUnmountedMask = 0x00000100,
317 kHFSVolumeSparedBlocksMask = 0x00000200,
318 kHFSVolumeNoCacheRequiredMask = 0x00000400,
319 kHFSBootVolumeInconsistentMask = 0x00000800,
320 kHFSCatalogNodeIDsReusedMask = 0x00001000,
321 kHFSVolumeJournaledMask = 0x00002000,
322 kHFSVolumeInconsistentMask = 0x00004000,
323 kHFSVolumeSoftwareLockMask = 0x00008000,
324
325 /* Bits 16-31 are allocated from high to low */
326
327 kHFSContentProtectionMask = 0x40000000,
328 kHFSUnusedNodeFixMask = 0x80000000,
329
330 kHFSMDBAttributesMask = 0x8380
331 };
332
333 enum {
334 kHFSUnusedNodesFixDate = 0xc5ef2480 /* March 25, 2009 */
335 };
336
337 /* Mac OS X has 16 bytes worth of "BSD" info.
338 *
339 * Note: Mac OS 9 implementations and applications
340 * should preserve, but not change, this information.
341 */
342 struct HFSPlusBSDInfo {
343 u_int32_t ownerID; /* user-id of owner or hard link chain previous link */
344 u_int32_t groupID; /* group-id of owner or hard link chain next link */
345 u_int8_t adminFlags; /* super-user changeable flags */
346 u_int8_t ownerFlags; /* owner changeable flags */
347 u_int16_t fileMode; /* file type and permission bits */
348 union {
349 u_int32_t iNodeNum; /* indirect node number (hard links only) */
350 u_int32_t linkCount; /* links that refer to this indirect node */
351 u_int32_t rawDevice; /* special file device (FBLK and FCHR only) */
352 } special;
353 } __attribute__((aligned(2), packed));
354 typedef struct HFSPlusBSDInfo HFSPlusBSDInfo;
355
356 #define hl_firstLinkID reserved1 /* Valid only if HasLinkChain flag is set (indirect nodes only) */
357
358 #define hl_prevLinkID bsdInfo.ownerID /* Valid only if HasLinkChain flag is set */
359 #define hl_nextLinkID bsdInfo.groupID /* Valid only if HasLinkChain flag is set */
360
361 #define hl_linkReference bsdInfo.special.iNodeNum
362 #define hl_linkCount bsdInfo.special.linkCount
363
364 /* Finder information */
365 struct FndrFileInfo {
366 u_int32_t fdType; /* file type */
367 u_int32_t fdCreator; /* file creator */
368 u_int16_t fdFlags; /* Finder flags */
369 struct {
370 int16_t v; /* file's location */
371 int16_t h;
372 } fdLocation;
373 int16_t opaque;
374 } __attribute__((aligned(2), packed));
375 typedef struct FndrFileInfo FndrFileInfo;
376
377 struct FndrDirInfo {
378 struct { /* folder's window rectangle */
379 int16_t top;
380 int16_t left;
381 int16_t bottom;
382 int16_t right;
383 } frRect;
384 unsigned short frFlags; /* Finder flags */
385 struct {
386 u_int16_t v; /* folder's location */
387 u_int16_t h;
388 } frLocation;
389 int16_t opaque;
390 } __attribute__((aligned(2), packed));
391 typedef struct FndrDirInfo FndrDirInfo;
392
393 struct FndrOpaqueInfo {
394 int8_t opaque[16];
395 } __attribute__((aligned(2), packed));
396 typedef struct FndrOpaqueInfo FndrOpaqueInfo;
397
398 struct FndrExtendedDirInfo {
399 u_int32_t document_id;
400 u_int32_t date_added;
401 u_int16_t extended_flags;
402 u_int16_t reserved3;
403 u_int32_t write_gen_counter;
404 } __attribute__((aligned(2), packed));
405
406 struct FndrExtendedFileInfo {
407 u_int32_t document_id;
408 u_int32_t date_added;
409 u_int16_t extended_flags;
410 u_int16_t reserved2;
411 u_int32_t write_gen_counter;
412 } __attribute__((aligned(2), packed));
413
414 /* HFS Plus catalog folder record - 88 bytes */
415 struct HFSPlusCatalogFolder {
416 int16_t recordType; /* == kHFSPlusFolderRecord */
417 u_int16_t flags; /* file flags */
418 u_int32_t valence; /* folder's item count */
419 u_int32_t folderID; /* folder ID */
420 u_int32_t createDate; /* date and time of creation */
421 u_int32_t contentModDate; /* date and time of last content modification */
422 u_int32_t attributeModDate; /* date and time of last attribute modification */
423 u_int32_t accessDate; /* date and time of last access (MacOS X only) */
424 u_int32_t backupDate; /* date and time of last backup */
425 HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */
426 FndrDirInfo userInfo; /* Finder information */
427 FndrOpaqueInfo finderInfo; /* additional Finder information */
428 u_int32_t textEncoding; /* hint for name conversions */
429 u_int32_t folderCount; /* number of enclosed folders, active when HasFolderCount is set */
430 } __attribute__((aligned(2), packed));
431 typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder;
432
433
434 /*
435 * These are the types of records in the attribute B-tree. The values were
436 * chosen so that they wouldn't conflict with the catalog record types.
437 */
438 enum {
439 kHFSPlusAttrInlineData = 0x10, /* attributes whose data fits in a b-tree node */
440 kHFSPlusAttrForkData = 0x20, /* extent based attributes (data lives in extents) */
441 kHFSPlusAttrExtents = 0x30 /* overflow extents for large attributes */
442 };
443
444
445 /*
446 * HFSPlusAttrForkData
447 * For larger attributes, whose value is stored in allocation blocks.
448 * If the attribute has more than 8 extents, there will be additional
449 * records (of type HFSPlusAttrExtents) for this attribute.
450 */
451 struct HFSPlusAttrForkData {
452 u_int32_t recordType; /* == kHFSPlusAttrForkData*/
453 u_int32_t reserved;
454 HFSPlusForkData theFork; /* size and first extents of value*/
455 } __attribute__((aligned(2), packed));
456 typedef struct HFSPlusAttrForkData HFSPlusAttrForkData;
457
458 /*
459 * HFSPlusAttrExtents
460 * This record contains information about overflow extents for large,
461 * fragmented attributes.
462 */
463 struct HFSPlusAttrExtents {
464 u_int32_t recordType; /* == kHFSPlusAttrExtents*/
465 u_int32_t reserved;
466 HFSPlusExtentRecord extents; /* additional extents*/
467 } __attribute__((aligned(2), packed));
468 typedef struct HFSPlusAttrExtents HFSPlusAttrExtents;
469
470 /* HFSPlusAttrInlineData is obsolete use HFSPlusAttrData instead */
471 struct HFSPlusAttrInlineData {
472 u_int32_t recordType;
473 u_int32_t reserved;
474 u_int32_t logicalSize;
475 u_int8_t userData[2];
476 } __attribute__((aligned(2), packed));
477 typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData;
478
479
480 /* A generic Attribute Record */
481 union HFSPlusAttrRecord {
482 u_int32_t recordType;
483 HFSPlusAttrInlineData inlineData; /* NOT USED */
484 HFSPlusAttrData attrData;
485 HFSPlusAttrForkData forkData;
486 HFSPlusAttrExtents overflowExtents;
487 };
488 typedef union HFSPlusAttrRecord HFSPlusAttrRecord;
489
490
491 /* HFS Plus catalog file record - 248 bytes */
492 struct HFSPlusCatalogFile {
493 int16_t recordType; /* == kHFSPlusFileRecord */
494 u_int16_t flags; /* file flags */
495 u_int32_t reserved1; /* reserved - initialized as zero */
496 u_int32_t fileID; /* file ID */
497 u_int32_t createDate; /* date and time of creation */
498 u_int32_t contentModDate; /* date and time of last content modification */
499 u_int32_t attributeModDate; /* date and time of last attribute modification */
500 u_int32_t accessDate; /* date and time of last access (MacOS X only) */
501 u_int32_t backupDate; /* date and time of last backup */
502 HFSPlusBSDInfo bsdInfo; /* permissions (for MacOS X) */
503 FndrFileInfo userInfo; /* Finder information */
504 FndrOpaqueInfo finderInfo; /* additional Finder information */
505 u_int32_t textEncoding; /* hint for name conversions */
506 u_int32_t reserved2; /* reserved - initialized as zero */
507
508 /* Note: these start on double long (64 bit) boundary */
509 HFSPlusForkData dataFork; /* size and block data for data fork */
510 HFSPlusForkData resourceFork; /* size and block data for resource fork */
511 } __attribute__((aligned(2), packed));
512 typedef struct HFSPlusCatalogFile HFSPlusCatalogFile;
513
514 /* HFS Master Directory Block - 162 bytes */
515 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
516 struct HFSMasterDirectoryBlock {
517 u_int16_t drSigWord; /* == kHFSSigWord */
518 u_int32_t drCrDate; /* date and time of volume creation */
519 u_int32_t drLsMod; /* date and time of last modification */
520 u_int16_t drAtrb; /* volume attributes */
521 u_int16_t drNmFls; /* number of files in root folder */
522 u_int16_t drVBMSt; /* first block of volume bitmap */
523 u_int16_t drAllocPtr; /* start of next allocation search */
524 u_int16_t drNmAlBlks; /* number of allocation blocks in volume */
525 u_int32_t drAlBlkSiz; /* size (in bytes) of allocation blocks */
526 u_int32_t drClpSiz; /* default clump size */
527 u_int16_t drAlBlSt; /* first allocation block in volume */
528 u_int32_t drNxtCNID; /* next unused catalog node ID */
529 u_int16_t drFreeBks; /* number of unused allocation blocks */
530 u_int8_t drVN[kHFSMaxVolumeNameChars + 1]; /* volume name */
531 u_int32_t drVolBkUp; /* date and time of last backup */
532 u_int16_t drVSeqNum; /* volume backup sequence number */
533 u_int32_t drWrCnt; /* volume write count */
534 u_int32_t drXTClpSiz; /* clump size for extents overflow file */
535 u_int32_t drCTClpSiz; /* clump size for catalog file */
536 u_int16_t drNmRtDirs; /* number of directories in root folder */
537 u_int32_t drFilCnt; /* number of files in volume */
538 u_int32_t drDirCnt; /* number of directories in volume */
539 u_int32_t drFndrInfo[8]; /* information used by the Finder */
540 u_int16_t drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */
541 HFSExtentDescriptor drEmbedExtent; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
542 u_int32_t drXTFlSize; /* size of extents overflow file */
543 HFSExtentRecord drXTExtRec; /* extent record for extents overflow file */
544 u_int32_t drCTFlSize; /* size of catalog file */
545 HFSExtentRecord drCTExtRec; /* extent record for catalog file */
546 } __attribute__((aligned(2), packed));
547 typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock;
548
549 /* HFS Plus Volume Header - 512 bytes */
550 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
551 struct HFSPlusVolumeHeader {
552 u_int16_t signature; /* == kHFSPlusSigWord */
553 u_int16_t version; /* == kHFSPlusVersion */
554 u_int32_t attributes; /* volume attributes */
555 u_int32_t lastMountedVersion; /* implementation version which last mounted volume */
556 u_int32_t journalInfoBlock; /* block addr of journal info (if volume is journaled, zero otherwise) */
557
558 u_int32_t createDate; /* date and time of volume creation */
559 u_int32_t modifyDate; /* date and time of last modification */
560 u_int32_t backupDate; /* date and time of last backup */
561 u_int32_t checkedDate; /* date and time of last disk check */
562
563 u_int32_t fileCount; /* number of files in volume */
564 u_int32_t folderCount; /* number of directories in volume */
565
566 u_int32_t blockSize; /* size (in bytes) of allocation blocks */
567 u_int32_t totalBlocks; /* number of allocation blocks in volume (includes this header and VBM*/
568 u_int32_t freeBlocks; /* number of unused allocation blocks */
569
570 u_int32_t nextAllocation; /* start of next allocation search */
571 u_int32_t rsrcClumpSize; /* default resource fork clump size */
572 u_int32_t dataClumpSize; /* default data fork clump size */
573 u_int32_t nextCatalogID; /* next unused catalog node ID */
574
575 u_int32_t writeCount; /* volume write count */
576 u_int64_t encodingsBitmap; /* which encodings have been use on this volume */
577
578 u_int8_t finderInfo[32]; /* information used by the Finder */
579
580 HFSPlusForkData allocationFile; /* allocation bitmap file */
581 HFSPlusForkData extentsFile; /* extents B-tree file */
582 HFSPlusForkData catalogFile; /* catalog B-tree file */
583 HFSPlusForkData attributesFile; /* extended attributes B-tree file */
584 HFSPlusForkData startupFile; /* boot file (secondary loader) */
585 } __attribute__((aligned(2), packed));
586 typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader;
587
588 /* JournalInfoBlock - Structure that describes where our journal lives */
589
590 // the original size of the reserved field in the JournalInfoBlock was
591 // 32*sizeof(u_int32_t). To keep the total size of the structure the
592 // same we subtract the size of new fields (currently: ext_jnl_uuid and
593 // machine_uuid). If you add additional fields, place them before the
594 // reserved field and subtract their size in this macro.
595 //
596 #define JIB_RESERVED_SIZE ((32*sizeof(u_int32_t)) - sizeof(uuid_string_t) - 48)
597
598 struct JournalInfoBlock {
599 u_int32_t flags;
600 u_int32_t device_signature[8]; // signature used to locate our device.
601 u_int64_t offset; // byte offset to the journal on the device
602 u_int64_t size; // size in bytes of the journal
603 uuid_string_t ext_jnl_uuid;
604 char machine_serial_num[48];
605 char reserved[JIB_RESERVED_SIZE];
606 } __attribute__((aligned(2), packed));
607 typedef struct JournalInfoBlock JournalInfoBlock;
608
609 enum {
610 kJIJournalInFSMask = 0x00000001,
611 kJIJournalOnOtherDeviceMask = 0x00000002,
612 kJIJournalNeedInitMask = 0x00000004
613 };
614
615 //
616 // This the content type uuid for "external journal" GPT
617 // partitions. Each instance of a partition also has a
618 // uuid that uniquely identifies that instance.
619 //
620 #define EXTJNL_CONTENT_TYPE_UUID "4A6F7572-6E61-11AA-AA11-00306543ECAC"
621
622
623 #endif /* lf_hfs_format_h */