2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 #ifndef __HFS_FORMAT__
26 #define __HFS_FORMAT__
28 #include <sys/appleapiopts.h>
33 * This file describes the on-disk format for HFS and HFS Plus volumes.
34 * The HFS Plus volume format is desciibed in detail in Apple Technote 1150.
36 * http://developer.apple.com/technotes/tn/tn1150.html
44 /* some on-disk hfs structures have 68K alignment (misaligned) */
45 #pragma options align=mac68k
47 /* Signatures used to differentiate between HFS and HFS Plus volumes */
49 kHFSSigWord
= 0x4244, /* 'BD' in ASCII */
50 kHFSPlusSigWord
= 0x482B, /* 'H+' in ASCII */
51 kHFSJSigWord
= 0x484a, /* 'HJ' in ASCII */
52 kHFSPlusVersion
= 0x0004, /* will change as format changes */
53 /* version 4 shipped with Mac OS 8.1 */
54 kHFSPlusMountVersion
= 0x31302E30, /* '10.0' for Mac OS X */
55 kHFSJMountVersion
= 0x4846534a /* 'HFSJ' for journaled HFS+ on OS X */
59 #ifdef __APPLE_API_PRIVATE
61 * Mac OS X has a special directory for linked and unlinked files (HFS Plus only).
62 * This directory and its contents are never exported from the filesystem under
65 * To make this folder name sort last, it has embedded null prefix.
66 * (0xC0, 0x80 in UTF-8)
68 #define HFSPLUSMETADATAFOLDER "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
71 * Files in the HFS Private Data folder have one of the following prefixes
72 * followed by a decimal number (no leading zeros). For indirect nodes this
73 * number is a 32 bit random number. For unlinked (deleted) files that are
74 * still open, the number is the file ID for that file.
76 * e.g. iNode7182000 and temp3296
78 #define HFS_INODE_PREFIX "iNode"
79 #define HFS_DELETE_PREFIX "temp"
81 #endif /* __APPLE_API_PRIVATE */
84 * Indirect link files (hard links) have the following type/creator.
87 kHardLinkFileType
= 0x686C6E6B, /* 'hlnk' */
88 kHFSPlusCreator
= 0x6866732B /* 'hfs+' */
92 /* Unicode strings are used for HFS Plus file and folder names */
94 u_int16_t length
; /* number of unicode characters */
95 u_int16_t unicode
[255]; /* unicode characters */
97 typedef struct HFSUniStr255 HFSUniStr255
;
98 typedef const HFSUniStr255
*ConstHFSUniStr255Param
;
101 kHFSMaxVolumeNameChars
= 27,
102 kHFSMaxFileNameChars
= 31,
103 kHFSPlusMaxFileNameChars
= 255
107 /* Extent overflow file data structures */
110 struct HFSExtentKey
{
111 u_int8_t keyLength
; /* length of key, excluding this field */
112 u_int8_t forkType
; /* 0 = data fork, FF = resource fork */
113 u_int32_t fileID
; /* file ID */
114 u_int16_t startBlock
; /* first file allocation block number in this extent */
116 typedef struct HFSExtentKey HFSExtentKey
;
118 /* HFS Plus Extent key */
119 struct HFSPlusExtentKey
{
120 u_int16_t keyLength
; /* length of key, excluding this field */
121 u_int8_t forkType
; /* 0 = data fork, FF = resource fork */
122 u_int8_t pad
; /* make the other fields align on 32-bit boundary */
123 u_int32_t fileID
; /* file ID */
124 u_int32_t startBlock
; /* first file allocation block number in this extent */
126 typedef struct HFSPlusExtentKey HFSPlusExtentKey
;
128 /* Number of extent descriptors per extent record */
130 kHFSExtentDensity
= 3,
131 kHFSPlusExtentDensity
= 8
134 /* HFS extent descriptor */
135 struct HFSExtentDescriptor
{
136 u_int16_t startBlock
; /* first allocation block */
137 u_int16_t blockCount
; /* number of allocation blocks */
139 typedef struct HFSExtentDescriptor HFSExtentDescriptor
;
141 /* HFS Plus extent descriptor */
142 struct HFSPlusExtentDescriptor
{
143 u_int32_t startBlock
; /* first allocation block */
144 u_int32_t blockCount
; /* number of allocation blocks */
146 typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor
;
148 /* HFS extent record */
149 typedef HFSExtentDescriptor HFSExtentRecord
[3];
151 /* HFS Plus extent record */
152 typedef HFSPlusExtentDescriptor HFSPlusExtentRecord
[8];
155 /* Finder information */
156 struct FndrFileInfo
{
157 u_int32_t fdType
; /* file type */
158 u_int32_t fdCreator
; /* file creator */
159 u_int16_t fdFlags
; /* Finder flags */
161 int16_t v
; /* file's location */
166 typedef struct FndrFileInfo FndrFileInfo
;
169 struct { /* folder's window rectangle */
175 unsigned short frFlags
; /* Finder flags */
177 u_int16_t v
; /* folder's location */
182 typedef struct FndrDirInfo FndrDirInfo
;
184 struct FndrOpaqueInfo
{
187 typedef struct FndrOpaqueInfo FndrOpaqueInfo
;
190 /* HFS Plus Fork data info - 80 bytes */
191 struct HFSPlusForkData
{
192 u_int64_t logicalSize
; /* fork's logical size in bytes */
193 u_int32_t clumpSize
; /* fork's clump size in bytes */
194 u_int32_t totalBlocks
; /* total blocks used by this fork */
195 HFSPlusExtentRecord extents
; /* initial set of extents */
197 typedef struct HFSPlusForkData HFSPlusForkData
;
200 /* Mac OS X has 16 bytes worth of "BSD" info.
202 * Note: Mac OS 9 implementations and applications
203 * should preserve, but not change, this information.
205 struct HFSPlusBSDInfo
{
206 u_int32_t ownerID
; /* user or group ID of file/folder owner */
207 u_int32_t groupID
; /* additional user of group ID */
208 u_int8_t adminFlags
; /* super-user changeable flags */
209 u_int8_t ownerFlags
; /* owner changeable flags */
210 u_int16_t fileMode
; /* file type and permission bits */
212 u_int32_t iNodeNum
; /* indirect node number (hard links only) */
213 u_int32_t linkCount
; /* links that refer to this indirect node */
214 u_int32_t rawDevice
; /* special file device (FBLK and FCHR only) */
217 typedef struct HFSPlusBSDInfo HFSPlusBSDInfo
;
220 /* Catalog file data structures */
223 kHFSRootParentID
= 1, /* Parent ID of the root folder */
224 kHFSRootFolderID
= 2, /* Folder ID of the root folder */
225 kHFSExtentsFileID
= 3, /* File ID of the extents file */
226 kHFSCatalogFileID
= 4, /* File ID of the catalog file */
227 kHFSBadBlockFileID
= 5, /* File ID of the bad allocation block file */
228 kHFSAllocationFileID
= 6, /* File ID of the allocation file (HFS Plus only) */
229 kHFSStartupFileID
= 7, /* File ID of the startup file (HFS Plus only) */
230 kHFSAttributesFileID
= 8, /* File ID of the attribute file (HFS Plus only) */
231 kHFSBogusExtentFileID
= 15, /* Used for exchanging extents in extents file */
232 kHFSFirstUserCatalogNodeID
= 16
235 /* HFS catalog key */
236 struct HFSCatalogKey
{
237 u_int8_t keyLength
; /* key length (in bytes) */
238 u_int8_t reserved
; /* reserved (set to zero) */
239 u_int32_t parentID
; /* parent folder ID */
240 u_char nodeName
[kHFSMaxFileNameChars
+ 1]; /* catalog node name */
242 typedef struct HFSCatalogKey HFSCatalogKey
;
244 /* HFS Plus catalog key */
245 struct HFSPlusCatalogKey
{
246 u_int16_t keyLength
; /* key length (in bytes) */
247 u_int32_t parentID
; /* parent folder ID */
248 HFSUniStr255 nodeName
; /* catalog node name */
250 typedef struct HFSPlusCatalogKey HFSPlusCatalogKey
;
252 /* Catalog record types */
254 /* HFS Catalog Records */
255 kHFSFolderRecord
= 0x0100, /* Folder record */
256 kHFSFileRecord
= 0x0200, /* File record */
257 kHFSFolderThreadRecord
= 0x0300, /* Folder thread record */
258 kHFSFileThreadRecord
= 0x0400, /* File thread record */
260 /* HFS Plus Catalog Records */
261 kHFSPlusFolderRecord
= 1, /* Folder record */
262 kHFSPlusFileRecord
= 2, /* File record */
263 kHFSPlusFolderThreadRecord
= 3, /* Folder thread record */
264 kHFSPlusFileThreadRecord
= 4 /* File thread record */
268 /* Catalog file record flags */
270 kHFSFileLockedBit
= 0x0000, /* file is locked and cannot be written to */
271 kHFSFileLockedMask
= 0x0001,
272 kHFSThreadExistsBit
= 0x0001, /* a file thread record exists for this file */
273 kHFSThreadExistsMask
= 0x0002
277 /* HFS catalog folder record - 70 bytes */
278 struct HFSCatalogFolder
{
279 int16_t recordType
; /* == kHFSFolderRecord */
280 u_int16_t flags
; /* folder flags */
281 u_int16_t valence
; /* folder valence */
282 u_int32_t folderID
; /* folder ID */
283 u_int32_t createDate
; /* date and time of creation */
284 u_int32_t modifyDate
; /* date and time of last modification */
285 u_int32_t backupDate
; /* date and time of last backup */
286 FndrDirInfo userInfo
; /* Finder information */
287 FndrOpaqueInfo finderInfo
; /* additional Finder information */
288 u_int32_t reserved
[4]; /* reserved - initialized as zero */
290 typedef struct HFSCatalogFolder HFSCatalogFolder
;
292 /* HFS Plus catalog folder record - 88 bytes */
293 struct HFSPlusCatalogFolder
{
294 int16_t recordType
; /* == kHFSPlusFolderRecord */
295 u_int16_t flags
; /* file flags */
296 u_int32_t valence
; /* folder's valence (limited to 2^16 in Mac OS) */
297 u_int32_t folderID
; /* folder ID */
298 u_int32_t createDate
; /* date and time of creation */
299 u_int32_t contentModDate
; /* date and time of last content modification */
300 u_int32_t attributeModDate
; /* date and time of last attribute modification */
301 u_int32_t accessDate
; /* date and time of last access (MacOS X only) */
302 u_int32_t backupDate
; /* date and time of last backup */
303 HFSPlusBSDInfo bsdInfo
; /* permissions (for MacOS X) */
304 FndrDirInfo userInfo
; /* Finder information */
305 FndrOpaqueInfo finderInfo
; /* additional Finder information */
306 u_int32_t textEncoding
; /* hint for name conversions */
307 u_int32_t reserved
; /* reserved - initialized as zero */
309 typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder
;
311 /* HFS catalog file record - 102 bytes */
312 struct HFSCatalogFile
{
313 int16_t recordType
; /* == kHFSFileRecord */
314 u_int8_t flags
; /* file flags */
315 int8_t fileType
; /* file type (unused ?) */
316 FndrFileInfo userInfo
; /* Finder information */
317 u_int32_t fileID
; /* file ID */
318 u_int16_t dataStartBlock
; /* not used - set to zero */
319 int32_t dataLogicalSize
; /* logical EOF of data fork */
320 int32_t dataPhysicalSize
; /* physical EOF of data fork */
321 u_int16_t rsrcStartBlock
; /* not used - set to zero */
322 int32_t rsrcLogicalSize
; /* logical EOF of resource fork */
323 int32_t rsrcPhysicalSize
; /* physical EOF of resource fork */
324 u_int32_t createDate
; /* date and time of creation */
325 u_int32_t modifyDate
; /* date and time of last modification */
326 u_int32_t backupDate
; /* date and time of last backup */
327 FndrOpaqueInfo finderInfo
; /* additional Finder information */
328 u_int16_t clumpSize
; /* file clump size (not used) */
329 HFSExtentRecord dataExtents
; /* first data fork extent record */
330 HFSExtentRecord rsrcExtents
; /* first resource fork extent record */
331 u_int32_t reserved
; /* reserved - initialized as zero */
333 typedef struct HFSCatalogFile HFSCatalogFile
;
335 /* HFS Plus catalog file record - 248 bytes */
336 struct HFSPlusCatalogFile
{
337 int16_t recordType
; /* == kHFSPlusFileRecord */
338 u_int16_t flags
; /* file flags */
339 u_int32_t reserved1
; /* reserved - initialized as zero */
340 u_int32_t fileID
; /* file ID */
341 u_int32_t createDate
; /* date and time of creation */
342 u_int32_t contentModDate
; /* date and time of last content modification */
343 u_int32_t attributeModDate
; /* date and time of last attribute modification */
344 u_int32_t accessDate
; /* date and time of last access (MacOS X only) */
345 u_int32_t backupDate
; /* date and time of last backup */
346 HFSPlusBSDInfo bsdInfo
; /* permissions (for MacOS X) */
347 FndrFileInfo userInfo
; /* Finder information */
348 FndrOpaqueInfo finderInfo
; /* additional Finder information */
349 u_int32_t textEncoding
; /* hint for name conversions */
350 u_int32_t reserved2
; /* reserved - initialized as zero */
352 /* Note: these start on double long (64 bit) boundry */
353 HFSPlusForkData dataFork
; /* size and block data for data fork */
354 HFSPlusForkData resourceFork
; /* size and block data for resource fork */
356 typedef struct HFSPlusCatalogFile HFSPlusCatalogFile
;
358 /* HFS catalog thread record - 46 bytes */
359 struct HFSCatalogThread
{
360 int16_t recordType
; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */
361 int32_t reserved
[2]; /* reserved - initialized as zero */
362 u_int32_t parentID
; /* parent ID for this catalog node */
363 u_char nodeName
[kHFSMaxFileNameChars
+ 1]; /* name of this catalog node */
365 typedef struct HFSCatalogThread HFSCatalogThread
;
367 /* HFS Plus catalog thread record -- 264 bytes */
368 struct HFSPlusCatalogThread
{
369 int16_t recordType
; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
370 int16_t reserved
; /* reserved - initialized as zero */
371 u_int32_t parentID
; /* parent ID for this catalog node */
372 HFSUniStr255 nodeName
; /* name of this catalog node (variable length) */
374 typedef struct HFSPlusCatalogThread HFSPlusCatalogThread
;
376 #ifdef __APPLE_API_UNSTABLE
378 These are the types of records in the attribute B-tree. The values were
379 chosen so that they wouldn't conflict with the catalog record types.
382 kHFSPlusAttrInlineData
= 0x10, /* if size < kAttrOverflowSize */
383 kHFSPlusAttrForkData
= 0x20, /* if size >= kAttrOverflowSize */
384 kHFSPlusAttrExtents
= 0x30 /* overflow extents for large attributes */
389 HFSPlusAttrInlineData
390 For small attributes, whose entire value is stored within this one
392 There would not be any other records for this attribute.
394 struct HFSPlusAttrInlineData
{
395 u_int32_t recordType
; /* == kHFSPlusAttrInlineData*/
397 u_int32_t logicalSize
; /* size in bytes of userData*/
398 u_int8_t userData
[2]; /* variable length; space allocated is a multiple of 2 bytes*/
400 typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData
;
405 For larger attributes, whose value is stored in allocation blocks.
406 If the attribute has more than 8 extents, there will be additonal
407 records (of type HFSPlusAttrExtents) for this attribute.
409 struct HFSPlusAttrForkData
{
410 u_int32_t recordType
; /* == kHFSPlusAttrForkData*/
412 HFSPlusForkData theFork
; /* size and first extents of value*/
414 typedef struct HFSPlusAttrForkData HFSPlusAttrForkData
;
418 This record contains information about overflow extents for large,
419 fragmented attributes.
421 struct HFSPlusAttrExtents
{
422 u_int32_t recordType
; /* == kHFSPlusAttrExtents*/
424 HFSPlusExtentRecord extents
; /* additional extents*/
426 typedef struct HFSPlusAttrExtents HFSPlusAttrExtents
;
428 /* A generic Attribute Record*/
429 union HFSPlusAttrRecord
{
430 u_int32_t recordType
;
431 HFSPlusAttrInlineData inlineData
;
432 HFSPlusAttrForkData forkData
;
433 HFSPlusAttrExtents overflowExtents
;
435 typedef union HFSPlusAttrRecord HFSPlusAttrRecord
;
437 /* Key and node lengths */
439 kHFSPlusExtentKeyMaximumLength
= sizeof(HFSPlusExtentKey
) - sizeof(u_int16_t
),
440 kHFSExtentKeyMaximumLength
= sizeof(HFSExtentKey
) - sizeof(u_int8_t
),
441 kHFSPlusCatalogKeyMaximumLength
= sizeof(HFSPlusCatalogKey
) - sizeof(u_int16_t
),
442 kHFSPlusCatalogKeyMinimumLength
= kHFSPlusCatalogKeyMaximumLength
- sizeof(HFSUniStr255
) + sizeof(u_int16_t
),
443 kHFSCatalogKeyMaximumLength
= sizeof(HFSCatalogKey
) - sizeof(u_int8_t
),
444 kHFSCatalogKeyMinimumLength
= kHFSCatalogKeyMaximumLength
- (kHFSMaxFileNameChars
+ 1) + sizeof(u_int8_t
),
445 kHFSPlusCatalogMinNodeSize
= 4096,
446 kHFSPlusExtentMinNodeSize
= 512,
447 kHFSPlusAttrMinNodeSize
= 4096
449 #endif /* __APPLE_API_UNSTABLE */
451 /* HFS and HFS Plus volume attribute bits */
453 /* Bits 0-6 are reserved (always cleared by MountVol call) */
454 kHFSVolumeHardwareLockBit
= 7, /* volume is locked by hardware */
455 kHFSVolumeUnmountedBit
= 8, /* volume was successfully unmounted */
456 kHFSVolumeSparedBlocksBit
= 9, /* volume has bad blocks spared */
457 kHFSVolumeNoCacheRequiredBit
= 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */
458 kHFSBootVolumeInconsistentBit
= 11, /* boot volume is inconsistent (System 7.6 and later) */
459 kHFSCatalogNodeIDsReusedBit
= 12,
460 kHFSVolumeJournaledBit
= 13, /* this volume has a journal on it */
461 /* Bit 14 is reserved for future use */
462 kHFSVolumeSoftwareLockBit
= 15, /* volume is locked by software */
464 kHFSVolumeHardwareLockMask
= 1 << kHFSVolumeHardwareLockBit
,
465 kHFSVolumeUnmountedMask
= 1 << kHFSVolumeUnmountedBit
,
466 kHFSVolumeSparedBlocksMask
= 1 << kHFSVolumeSparedBlocksBit
,
467 kHFSVolumeNoCacheRequiredMask
= 1 << kHFSVolumeNoCacheRequiredBit
,
468 kHFSBootVolumeInconsistentMask
= 1 << kHFSBootVolumeInconsistentBit
,
469 kHFSCatalogNodeIDsReusedMask
= 1 << kHFSCatalogNodeIDsReusedBit
,
470 kHFSVolumeJournaledMask
= 1 << kHFSVolumeJournaledBit
,
471 kHFSVolumeSoftwareLockMask
= 1 << kHFSVolumeSoftwareLockBit
,
472 kHFSMDBAttributesMask
= 0x8380
476 /* HFS Master Directory Block - 162 bytes */
477 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
478 struct HFSMasterDirectoryBlock
{
479 u_int16_t drSigWord
; /* == kHFSSigWord */
480 u_int32_t drCrDate
; /* date and time of volume creation */
481 u_int32_t drLsMod
; /* date and time of last modification */
482 u_int16_t drAtrb
; /* volume attributes */
483 u_int16_t drNmFls
; /* number of files in root folder */
484 u_int16_t drVBMSt
; /* first block of volume bitmap */
485 u_int16_t drAllocPtr
; /* start of next allocation search */
486 u_int16_t drNmAlBlks
; /* number of allocation blocks in volume */
487 u_int32_t drAlBlkSiz
; /* size (in bytes) of allocation blocks */
488 u_int32_t drClpSiz
; /* default clump size */
489 u_int16_t drAlBlSt
; /* first allocation block in volume */
490 u_int32_t drNxtCNID
; /* next unused catalog node ID */
491 u_int16_t drFreeBks
; /* number of unused allocation blocks */
492 u_char drVN
[kHFSMaxVolumeNameChars
+ 1]; /* volume name */
493 u_int32_t drVolBkUp
; /* date and time of last backup */
494 u_int16_t drVSeqNum
; /* volume backup sequence number */
495 u_int32_t drWrCnt
; /* volume write count */
496 u_int32_t drXTClpSiz
; /* clump size for extents overflow file */
497 u_int32_t drCTClpSiz
; /* clump size for catalog file */
498 u_int16_t drNmRtDirs
; /* number of directories in root folder */
499 u_int32_t drFilCnt
; /* number of files in volume */
500 u_int32_t drDirCnt
; /* number of directories in volume */
501 u_int32_t drFndrInfo
[8]; /* information used by the Finder */
502 u_int16_t drEmbedSigWord
; /* embedded volume signature (formerly drVCSize) */
503 HFSExtentDescriptor drEmbedExtent
; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
504 u_int32_t drXTFlSize
; /* size of extents overflow file */
505 HFSExtentRecord drXTExtRec
; /* extent record for extents overflow file */
506 u_int32_t drCTFlSize
; /* size of catalog file */
507 HFSExtentRecord drCTExtRec
; /* extent record for catalog file */
509 typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock
;
512 /* HFS Plus Volume Header - 512 bytes */
513 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
514 struct HFSPlusVolumeHeader
{
515 u_int16_t signature
; /* == kHFSPlusSigWord */
516 u_int16_t version
; /* == kHFSPlusVersion */
517 u_int32_t attributes
; /* volume attributes */
518 u_int32_t lastMountedVersion
; /* implementation version which last mounted volume */
519 //XXXdbg u_int32_t reserved; /* reserved - initialized as zero */
520 u_int32_t journalInfoBlock
; /* block addr of journal info (if volume is journaled, zero otherwise) */
522 u_int32_t createDate
; /* date and time of volume creation */
523 u_int32_t modifyDate
; /* date and time of last modification */
524 u_int32_t backupDate
; /* date and time of last backup */
525 u_int32_t checkedDate
; /* date and time of last disk check */
527 u_int32_t fileCount
; /* number of files in volume */
528 u_int32_t folderCount
; /* number of directories in volume */
530 u_int32_t blockSize
; /* size (in bytes) of allocation blocks */
531 u_int32_t totalBlocks
; /* number of allocation blocks in volume (includes this header and VBM*/
532 u_int32_t freeBlocks
; /* number of unused allocation blocks */
534 u_int32_t nextAllocation
; /* start of next allocation search */
535 u_int32_t rsrcClumpSize
; /* default resource fork clump size */
536 u_int32_t dataClumpSize
; /* default data fork clump size */
537 u_int32_t nextCatalogID
; /* next unused catalog node ID */
539 u_int32_t writeCount
; /* volume write count */
540 u_int64_t encodingsBitmap
; /* which encodings have been use on this volume */
542 u_int8_t finderInfo
[32]; /* information used by the Finder */
544 HFSPlusForkData allocationFile
; /* allocation bitmap file */
545 HFSPlusForkData extentsFile
; /* extents B-tree file */
546 HFSPlusForkData catalogFile
; /* catalog B-tree file */
547 HFSPlusForkData attributesFile
; /* extended attributes B-tree file */
548 HFSPlusForkData startupFile
; /* boot file (secondary loader) */
550 typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader
;
553 /* B-tree structures */
562 u_int8_t rawData
[kMaxKeyLength
+2];
564 typedef union BTreeKey BTreeKey
;
566 /* BTNodeDescriptor -- Every B-tree node starts with these fields. */
567 struct BTNodeDescriptor
{
568 u_int32_t fLink
; /* next node at this level*/
569 u_int32_t bLink
; /* previous node at this level*/
570 int8_t kind
; /* kind of node (leaf, index, header, map)*/
571 u_int8_t height
; /* zero for header, map; child is one more than parent*/
572 u_int16_t numRecords
; /* number of records in this node*/
573 u_int16_t reserved
; /* reserved - initialized as zero */
575 typedef struct BTNodeDescriptor BTNodeDescriptor
;
577 /* Constants for BTNodeDescriptor kind */
585 /* BTHeaderRec -- The first record of a B-tree header node */
587 u_int16_t treeDepth
; /* maximum height (usually leaf nodes) */
588 u_int32_t rootNode
; /* node number of root node */
589 u_int32_t leafRecords
; /* number of leaf records in all leaf nodes */
590 u_int32_t firstLeafNode
; /* node number of first leaf node */
591 u_int32_t lastLeafNode
; /* node number of last leaf node */
592 u_int16_t nodeSize
; /* size of a node, in bytes */
593 u_int16_t maxKeyLength
; /* reserved */
594 u_int32_t totalNodes
; /* total number of nodes in tree */
595 u_int32_t freeNodes
; /* number of unused (free) nodes in tree */
596 u_int16_t reserved1
; /* unused */
597 u_int32_t clumpSize
; /* reserved */
598 u_int8_t btreeType
; /* reserved */
599 u_int8_t reserved2
; /* reserved */
600 u_int32_t attributes
; /* persistent attributes about the tree */
601 u_int32_t reserved3
[16]; /* reserved */
603 typedef struct BTHeaderRec BTHeaderRec
;
605 /* Constants for BTHeaderRec attributes */
607 kBTBadCloseMask
= 0x00000001, /* reserved */
608 kBTBigKeysMask
= 0x00000002, /* key length field is 16 bits */
609 kBTVariableIndexKeysMask
= 0x00000004 /* keys in index nodes are variable length */
612 /* JournalInfoBlock - Structure that describes where our journal lives */
613 struct JournalInfoBlock
{
615 u_int32_t device_signature
[8]; // signature used to locate our device.
616 u_int64_t offset
; // byte offset to the journal on the device
617 u_int64_t size
; // size in bytes of the journal
618 u_int32_t reserved
[32];
620 typedef struct JournalInfoBlock JournalInfoBlock
;
623 kJIJournalInFSMask
= 0x00000001,
624 kJIJournalOnOtherDeviceMask
= 0x00000002,
625 kJIJournalNeedInitMask
= 0x00000004
629 #pragma options align=reset
635 #endif /* __HFS_FORMAT__ */