2 * Copyright (c) 2000-2003 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 #ifndef __HFSVOLUMES__
30 #include <sys/types.h>
31 #include <sys/appleapiopts.h>
36 * This file describes the on-disk format for HFS and HFS Plus volumes.
37 * The HFS Plus volume format is desciibed in detail in Apple Technote 1150.
39 * http://developer.apple.com/technotes/tn/tn1150.html
47 /* some on-disk hfs structures have 68K alignment (misaligned) */
48 #pragma options align=mac68k
50 /* Signatures used to differentiate between HFS and HFS Plus volumes */
52 kHFSSigWord
= 0x4244, /* 'BD' in ASCII */
53 kHFSPlusSigWord
= 0x482B, /* 'H+' in ASCII */
54 kHFSXSigWord
= 0x4858, /* 'HX' in ASCII */
56 kHFSPlusVersion
= 0x0004, /* 'H+' volumes are version 4 only */
57 kHFSXVersion
= 0x0005, /* 'HX' volumes start with version 5 */
59 kHFSPlusMountVersion
= 0x31302E30, /* '10.0' for Mac OS X */
60 kHFSJMountVersion
= 0x4846534a /* 'HFSJ' for journaled HFS+ on OS X */
64 #ifdef __APPLE_API_PRIVATE
66 * Mac OS X has a special directory for linked and unlinked files (HFS Plus only).
67 * This directory and its contents are never exported from the filesystem under
70 * To make this folder name sort last, it has embedded null prefix.
71 * (0xC0, 0x80 in UTF-8)
73 #define HFSPLUSMETADATAFOLDER "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
76 * Files in the HFS Private Data folder have one of the following prefixes
77 * followed by a decimal number (no leading zeros). For indirect nodes this
78 * number is a 32 bit random number. For unlinked (deleted) files that are
79 * still open, the number is the file ID for that file.
81 * e.g. iNode7182000 and temp3296
83 #define HFS_INODE_PREFIX "iNode"
84 #define HFS_DELETE_PREFIX "temp"
86 #endif /* __APPLE_API_PRIVATE */
89 * Indirect link files (hard links) have the following type/creator.
92 kHardLinkFileType
= 0x686C6E6B, /* 'hlnk' */
93 kHFSPlusCreator
= 0x6866732B /* 'hfs+' */
98 /* Unicode strings are used for HFS Plus file and folder names */
100 u_int16_t length
; /* number of unicode characters */
101 u_int16_t unicode
[255]; /* unicode characters */
103 typedef struct HFSUniStr255 HFSUniStr255
;
104 typedef const HFSUniStr255
*ConstHFSUniStr255Param
;
105 #endif /* __FILES__ */
108 kHFSMaxVolumeNameChars
= 27,
109 kHFSMaxFileNameChars
= 31,
110 kHFSPlusMaxFileNameChars
= 255
114 /* Extent overflow file data structures */
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 */
123 typedef struct HFSExtentKey HFSExtentKey
;
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 */
133 typedef struct HFSPlusExtentKey HFSPlusExtentKey
;
135 /* Number of extent descriptors per extent record */
137 kHFSExtentDensity
= 3,
138 kHFSPlusExtentDensity
= 8
141 /* HFS extent descriptor */
142 struct HFSExtentDescriptor
{
143 u_int16_t startBlock
; /* first allocation block */
144 u_int16_t blockCount
; /* number of allocation blocks */
146 typedef struct HFSExtentDescriptor HFSExtentDescriptor
;
148 /* HFS Plus extent descriptor */
149 struct HFSPlusExtentDescriptor
{
150 u_int32_t startBlock
; /* first allocation block */
151 u_int32_t blockCount
; /* number of allocation blocks */
153 typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor
;
155 /* HFS extent record */
156 typedef HFSExtentDescriptor HFSExtentRecord
[3];
158 /* HFS Plus extent record */
159 typedef HFSPlusExtentDescriptor HFSPlusExtentRecord
[8];
162 /* Finder information */
163 struct FndrFileInfo
{
164 u_int32_t fdType
; /* file type */
165 u_int32_t fdCreator
; /* file creator */
166 u_int16_t fdFlags
; /* Finder flags */
168 int16_t v
; /* file's location */
173 typedef struct FndrFileInfo FndrFileInfo
;
176 struct { /* folder's window rectangle */
182 unsigned short frFlags
; /* Finder flags */
184 u_int16_t v
; /* folder's location */
189 typedef struct FndrDirInfo FndrDirInfo
;
191 struct FndrOpaqueInfo
{
194 typedef struct FndrOpaqueInfo FndrOpaqueInfo
;
197 /* HFS Plus Fork data info - 80 bytes */
198 struct HFSPlusForkData
{
199 u_int64_t logicalSize
; /* fork's logical size in bytes */
200 u_int32_t clumpSize
; /* fork's clump size in bytes */
201 u_int32_t totalBlocks
; /* total blocks used by this fork */
202 HFSPlusExtentRecord extents
; /* initial set of extents */
204 typedef struct HFSPlusForkData HFSPlusForkData
;
207 /* Mac OS X has 16 bytes worth of "BSD" info.
209 * Note: Mac OS 9 implementations and applications
210 * should preserve, but not change, this information.
212 struct HFSPlusBSDInfo
{
213 u_int32_t ownerID
; /* user or group ID of file/folder owner */
214 u_int32_t groupID
; /* additional user of group ID */
215 u_int8_t adminFlags
; /* super-user changeable flags */
216 u_int8_t ownerFlags
; /* owner changeable flags */
217 u_int16_t fileMode
; /* file type and permission bits */
219 u_int32_t iNodeNum
; /* indirect node number (hard links only) */
220 u_int32_t linkCount
; /* links that refer to this indirect node */
221 u_int32_t rawDevice
; /* special file device (FBLK and FCHR only) */
224 typedef struct HFSPlusBSDInfo HFSPlusBSDInfo
;
227 /* Catalog file data structures */
230 kHFSRootParentID
= 1, /* Parent ID of the root folder */
231 kHFSRootFolderID
= 2, /* Folder ID of the root folder */
232 kHFSExtentsFileID
= 3, /* File ID of the extents file */
233 kHFSCatalogFileID
= 4, /* File ID of the catalog file */
234 kHFSBadBlockFileID
= 5, /* File ID of the bad allocation block file */
235 kHFSAllocationFileID
= 6, /* File ID of the allocation file (HFS Plus only) */
236 kHFSStartupFileID
= 7, /* File ID of the startup file (HFS Plus only) */
237 kHFSAttributesFileID
= 8, /* File ID of the attribute file (HFS Plus only) */
238 kHFSRepairCatalogFileID
= 14, /* Used when rebuilding Catalog B-tree */
239 kHFSBogusExtentFileID
= 15, /* Used for exchanging extents in extents file */
240 kHFSFirstUserCatalogNodeID
= 16
243 /* HFS catalog key */
244 struct HFSCatalogKey
{
245 u_int8_t keyLength
; /* key length (in bytes) */
246 u_int8_t reserved
; /* reserved (set to zero) */
247 u_int32_t parentID
; /* parent folder ID */
248 u_char nodeName
[kHFSMaxFileNameChars
+ 1]; /* catalog node name */
250 typedef struct HFSCatalogKey HFSCatalogKey
;
252 /* HFS Plus catalog key */
253 struct HFSPlusCatalogKey
{
254 u_int16_t keyLength
; /* key length (in bytes) */
255 u_int32_t parentID
; /* parent folder ID */
256 HFSUniStr255 nodeName
; /* catalog node name */
258 typedef struct HFSPlusCatalogKey HFSPlusCatalogKey
;
260 /* Catalog record types */
262 /* HFS Catalog Records */
263 kHFSFolderRecord
= 0x0100, /* Folder record */
264 kHFSFileRecord
= 0x0200, /* File record */
265 kHFSFolderThreadRecord
= 0x0300, /* Folder thread record */
266 kHFSFileThreadRecord
= 0x0400, /* File thread record */
268 /* HFS Plus Catalog Records */
269 kHFSPlusFolderRecord
= 1, /* Folder record */
270 kHFSPlusFileRecord
= 2, /* File record */
271 kHFSPlusFolderThreadRecord
= 3, /* Folder thread record */
272 kHFSPlusFileThreadRecord
= 4 /* File thread record */
276 /* Catalog file record flags */
278 kHFSFileLockedBit
= 0x0000, /* file is locked and cannot be written to */
279 kHFSFileLockedMask
= 0x0001,
280 kHFSThreadExistsBit
= 0x0001, /* a file thread record exists for this file */
281 kHFSThreadExistsMask
= 0x0002
285 /* HFS catalog folder record - 70 bytes */
286 struct HFSCatalogFolder
{
287 int16_t recordType
; /* == kHFSFolderRecord */
288 u_int16_t flags
; /* folder flags */
289 u_int16_t valence
; /* folder valence */
290 u_int32_t folderID
; /* folder ID */
291 u_int32_t createDate
; /* date and time of creation */
292 u_int32_t modifyDate
; /* date and time of last modification */
293 u_int32_t backupDate
; /* date and time of last backup */
294 FndrDirInfo userInfo
; /* Finder information */
295 FndrOpaqueInfo finderInfo
; /* additional Finder information */
296 u_int32_t reserved
[4]; /* reserved - initialized as zero */
298 typedef struct HFSCatalogFolder HFSCatalogFolder
;
300 /* HFS Plus catalog folder record - 88 bytes */
301 struct HFSPlusCatalogFolder
{
302 int16_t recordType
; /* == kHFSPlusFolderRecord */
303 u_int16_t flags
; /* file flags */
304 u_int32_t valence
; /* folder's valence (limited to 2^16 in Mac OS) */
305 u_int32_t folderID
; /* folder ID */
306 u_int32_t createDate
; /* date and time of creation */
307 u_int32_t contentModDate
; /* date and time of last content modification */
308 u_int32_t attributeModDate
; /* date and time of last attribute modification */
309 u_int32_t accessDate
; /* date and time of last access (MacOS X only) */
310 u_int32_t backupDate
; /* date and time of last backup */
311 HFSPlusBSDInfo bsdInfo
; /* permissions (for MacOS X) */
312 FndrDirInfo userInfo
; /* Finder information */
313 FndrOpaqueInfo finderInfo
; /* additional Finder information */
314 u_int32_t textEncoding
; /* hint for name conversions */
315 u_int32_t reserved
; /* reserved - initialized as zero */
317 typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder
;
319 /* HFS catalog file record - 102 bytes */
320 struct HFSCatalogFile
{
321 int16_t recordType
; /* == kHFSFileRecord */
322 u_int8_t flags
; /* file flags */
323 int8_t fileType
; /* file type (unused ?) */
324 FndrFileInfo userInfo
; /* Finder information */
325 u_int32_t fileID
; /* file ID */
326 u_int16_t dataStartBlock
; /* not used - set to zero */
327 int32_t dataLogicalSize
; /* logical EOF of data fork */
328 int32_t dataPhysicalSize
; /* physical EOF of data fork */
329 u_int16_t rsrcStartBlock
; /* not used - set to zero */
330 int32_t rsrcLogicalSize
; /* logical EOF of resource fork */
331 int32_t rsrcPhysicalSize
; /* physical EOF of resource fork */
332 u_int32_t createDate
; /* date and time of creation */
333 u_int32_t modifyDate
; /* date and time of last modification */
334 u_int32_t backupDate
; /* date and time of last backup */
335 FndrOpaqueInfo finderInfo
; /* additional Finder information */
336 u_int16_t clumpSize
; /* file clump size (not used) */
337 HFSExtentRecord dataExtents
; /* first data fork extent record */
338 HFSExtentRecord rsrcExtents
; /* first resource fork extent record */
339 u_int32_t reserved
; /* reserved - initialized as zero */
341 typedef struct HFSCatalogFile HFSCatalogFile
;
343 /* HFS Plus catalog file record - 248 bytes */
344 struct HFSPlusCatalogFile
{
345 int16_t recordType
; /* == kHFSPlusFileRecord */
346 u_int16_t flags
; /* file flags */
347 u_int32_t reserved1
; /* reserved - initialized as zero */
348 u_int32_t fileID
; /* file ID */
349 u_int32_t createDate
; /* date and time of creation */
350 u_int32_t contentModDate
; /* date and time of last content modification */
351 u_int32_t attributeModDate
; /* date and time of last attribute modification */
352 u_int32_t accessDate
; /* date and time of last access (MacOS X only) */
353 u_int32_t backupDate
; /* date and time of last backup */
354 HFSPlusBSDInfo bsdInfo
; /* permissions (for MacOS X) */
355 FndrFileInfo userInfo
; /* Finder information */
356 FndrOpaqueInfo finderInfo
; /* additional Finder information */
357 u_int32_t textEncoding
; /* hint for name conversions */
358 u_int32_t reserved2
; /* reserved - initialized as zero */
360 /* Note: these start on double long (64 bit) boundry */
361 HFSPlusForkData dataFork
; /* size and block data for data fork */
362 HFSPlusForkData resourceFork
; /* size and block data for resource fork */
364 typedef struct HFSPlusCatalogFile HFSPlusCatalogFile
;
366 /* HFS catalog thread record - 46 bytes */
367 struct HFSCatalogThread
{
368 int16_t recordType
; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */
369 int32_t reserved
[2]; /* reserved - initialized as zero */
370 u_int32_t parentID
; /* parent ID for this catalog node */
371 u_char nodeName
[kHFSMaxFileNameChars
+ 1]; /* name of this catalog node */
373 typedef struct HFSCatalogThread HFSCatalogThread
;
375 /* HFS Plus catalog thread record -- 264 bytes */
376 struct HFSPlusCatalogThread
{
377 int16_t recordType
; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
378 int16_t reserved
; /* reserved - initialized as zero */
379 u_int32_t parentID
; /* parent ID for this catalog node */
380 HFSUniStr255 nodeName
; /* name of this catalog node (variable length) */
382 typedef struct HFSPlusCatalogThread HFSPlusCatalogThread
;
384 #ifdef __APPLE_API_UNSTABLE
386 These are the types of records in the attribute B-tree. The values were
387 chosen so that they wouldn't conflict with the catalog record types.
390 kHFSPlusAttrInlineData
= 0x10, /* if size < kAttrOverflowSize */
391 kHFSPlusAttrForkData
= 0x20, /* if size >= kAttrOverflowSize */
392 kHFSPlusAttrExtents
= 0x30 /* overflow extents for large attributes */
397 HFSPlusAttrInlineData
398 For small attributes, whose entire value is stored within this one
400 There would not be any other records for this attribute.
402 struct HFSPlusAttrInlineData
{
403 u_int32_t recordType
; /* == kHFSPlusAttrInlineData*/
405 u_int32_t logicalSize
; /* size in bytes of userData*/
406 u_int8_t userData
[2]; /* variable length; space allocated is a multiple of 2 bytes*/
408 typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData
;
413 For larger attributes, whose value is stored in allocation blocks.
414 If the attribute has more than 8 extents, there will be additonal
415 records (of type HFSPlusAttrExtents) for this attribute.
417 struct HFSPlusAttrForkData
{
418 u_int32_t recordType
; /* == kHFSPlusAttrForkData*/
420 HFSPlusForkData theFork
; /* size and first extents of value*/
422 typedef struct HFSPlusAttrForkData HFSPlusAttrForkData
;
426 This record contains information about overflow extents for large,
427 fragmented attributes.
429 struct HFSPlusAttrExtents
{
430 u_int32_t recordType
; /* == kHFSPlusAttrExtents*/
432 HFSPlusExtentRecord extents
; /* additional extents*/
434 typedef struct HFSPlusAttrExtents HFSPlusAttrExtents
;
436 /* A generic Attribute Record*/
437 union HFSPlusAttrRecord
{
438 u_int32_t recordType
;
439 HFSPlusAttrInlineData inlineData
;
440 HFSPlusAttrForkData forkData
;
441 HFSPlusAttrExtents overflowExtents
;
443 typedef union HFSPlusAttrRecord HFSPlusAttrRecord
;
445 /* Key and node lengths */
447 kHFSPlusExtentKeyMaximumLength
= sizeof(HFSPlusExtentKey
) - sizeof(u_int16_t
),
448 kHFSExtentKeyMaximumLength
= sizeof(HFSExtentKey
) - sizeof(u_int8_t
),
449 kHFSPlusCatalogKeyMaximumLength
= sizeof(HFSPlusCatalogKey
) - sizeof(u_int16_t
),
450 kHFSPlusCatalogKeyMinimumLength
= kHFSPlusCatalogKeyMaximumLength
- sizeof(HFSUniStr255
) + sizeof(u_int16_t
),
451 kHFSCatalogKeyMaximumLength
= sizeof(HFSCatalogKey
) - sizeof(u_int8_t
),
452 kHFSCatalogKeyMinimumLength
= kHFSCatalogKeyMaximumLength
- (kHFSMaxFileNameChars
+ 1) + sizeof(u_int8_t
),
453 kHFSPlusCatalogMinNodeSize
= 4096,
454 kHFSPlusExtentMinNodeSize
= 512,
455 kHFSPlusAttrMinNodeSize
= 4096
457 #endif /* __APPLE_API_UNSTABLE */
459 /* HFS and HFS Plus volume attribute bits */
461 /* Bits 0-6 are reserved (always cleared by MountVol call) */
462 kHFSVolumeHardwareLockBit
= 7, /* volume is locked by hardware */
463 kHFSVolumeUnmountedBit
= 8, /* volume was successfully unmounted */
464 kHFSVolumeSparedBlocksBit
= 9, /* volume has bad blocks spared */
465 kHFSVolumeNoCacheRequiredBit
= 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */
466 kHFSBootVolumeInconsistentBit
= 11, /* boot volume is inconsistent (System 7.6 and later) */
467 kHFSCatalogNodeIDsReusedBit
= 12,
468 kHFSVolumeJournaledBit
= 13, /* this volume has a journal on it */
469 kHFSVolumeInconsistentBit
= 14, /* serious inconsistencies detected at runtime */
470 kHFSVolumeSoftwareLockBit
= 15, /* volume is locked by software */
472 kHFSVolumeHardwareLockMask
= 1 << kHFSVolumeHardwareLockBit
,
473 kHFSVolumeUnmountedMask
= 1 << kHFSVolumeUnmountedBit
,
474 kHFSVolumeSparedBlocksMask
= 1 << kHFSVolumeSparedBlocksBit
,
475 kHFSVolumeNoCacheRequiredMask
= 1 << kHFSVolumeNoCacheRequiredBit
,
476 kHFSBootVolumeInconsistentMask
= 1 << kHFSBootVolumeInconsistentBit
,
477 kHFSCatalogNodeIDsReusedMask
= 1 << kHFSCatalogNodeIDsReusedBit
,
478 kHFSVolumeJournaledMask
= 1 << kHFSVolumeJournaledBit
,
479 kHFSVolumeInconsistentMask
= 1 << kHFSVolumeInconsistentBit
,
480 kHFSVolumeSoftwareLockMask
= 1 << kHFSVolumeSoftwareLockBit
,
481 kHFSMDBAttributesMask
= 0x8380
485 /* HFS Master Directory Block - 162 bytes */
486 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
487 struct HFSMasterDirectoryBlock
{
488 u_int16_t drSigWord
; /* == kHFSSigWord */
489 u_int32_t drCrDate
; /* date and time of volume creation */
490 u_int32_t drLsMod
; /* date and time of last modification */
491 u_int16_t drAtrb
; /* volume attributes */
492 u_int16_t drNmFls
; /* number of files in root folder */
493 u_int16_t drVBMSt
; /* first block of volume bitmap */
494 u_int16_t drAllocPtr
; /* start of next allocation search */
495 u_int16_t drNmAlBlks
; /* number of allocation blocks in volume */
496 u_int32_t drAlBlkSiz
; /* size (in bytes) of allocation blocks */
497 u_int32_t drClpSiz
; /* default clump size */
498 u_int16_t drAlBlSt
; /* first allocation block in volume */
499 u_int32_t drNxtCNID
; /* next unused catalog node ID */
500 u_int16_t drFreeBks
; /* number of unused allocation blocks */
501 u_char drVN
[kHFSMaxVolumeNameChars
+ 1]; /* volume name */
502 u_int32_t drVolBkUp
; /* date and time of last backup */
503 u_int16_t drVSeqNum
; /* volume backup sequence number */
504 u_int32_t drWrCnt
; /* volume write count */
505 u_int32_t drXTClpSiz
; /* clump size for extents overflow file */
506 u_int32_t drCTClpSiz
; /* clump size for catalog file */
507 u_int16_t drNmRtDirs
; /* number of directories in root folder */
508 u_int32_t drFilCnt
; /* number of files in volume */
509 u_int32_t drDirCnt
; /* number of directories in volume */
510 u_int32_t drFndrInfo
[8]; /* information used by the Finder */
511 u_int16_t drEmbedSigWord
; /* embedded volume signature (formerly drVCSize) */
512 HFSExtentDescriptor drEmbedExtent
; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
513 u_int32_t drXTFlSize
; /* size of extents overflow file */
514 HFSExtentRecord drXTExtRec
; /* extent record for extents overflow file */
515 u_int32_t drCTFlSize
; /* size of catalog file */
516 HFSExtentRecord drCTExtRec
; /* extent record for catalog file */
518 typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock
;
521 #ifdef __APPLE_API_UNSTABLE
522 #define SET_HFS_TEXT_ENCODING(hint) \
523 (0x656e6300 | ((hint) & 0xff))
524 #define GET_HFS_TEXT_ENCODING(hint) \
525 (((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU)
526 #endif /* __APPLE_API_UNSTABLE */
529 /* HFS Plus Volume Header - 512 bytes */
530 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
531 struct HFSPlusVolumeHeader
{
532 u_int16_t signature
; /* == kHFSPlusSigWord */
533 u_int16_t version
; /* == kHFSPlusVersion */
534 u_int32_t attributes
; /* volume attributes */
535 u_int32_t lastMountedVersion
; /* implementation version which last mounted volume */
536 u_int32_t journalInfoBlock
; /* block addr of journal info (if volume is journaled, zero otherwise) */
538 u_int32_t createDate
; /* date and time of volume creation */
539 u_int32_t modifyDate
; /* date and time of last modification */
540 u_int32_t backupDate
; /* date and time of last backup */
541 u_int32_t checkedDate
; /* date and time of last disk check */
543 u_int32_t fileCount
; /* number of files in volume */
544 u_int32_t folderCount
; /* number of directories in volume */
546 u_int32_t blockSize
; /* size (in bytes) of allocation blocks */
547 u_int32_t totalBlocks
; /* number of allocation blocks in volume (includes this header and VBM*/
548 u_int32_t freeBlocks
; /* number of unused allocation blocks */
550 u_int32_t nextAllocation
; /* start of next allocation search */
551 u_int32_t rsrcClumpSize
; /* default resource fork clump size */
552 u_int32_t dataClumpSize
; /* default data fork clump size */
553 u_int32_t nextCatalogID
; /* next unused catalog node ID */
555 u_int32_t writeCount
; /* volume write count */
556 u_int64_t encodingsBitmap
; /* which encodings have been use on this volume */
558 u_int8_t finderInfo
[32]; /* information used by the Finder */
560 HFSPlusForkData allocationFile
; /* allocation bitmap file */
561 HFSPlusForkData extentsFile
; /* extents B-tree file */
562 HFSPlusForkData catalogFile
; /* catalog B-tree file */
563 HFSPlusForkData attributesFile
; /* extended attributes B-tree file */
564 HFSPlusForkData startupFile
; /* boot file (secondary loader) */
566 typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader
;
569 /* B-tree structures */
578 u_int8_t rawData
[kMaxKeyLength
+2];
580 typedef union BTreeKey BTreeKey
;
582 /* BTNodeDescriptor -- Every B-tree node starts with these fields. */
583 struct BTNodeDescriptor
{
584 u_int32_t fLink
; /* next node at this level*/
585 u_int32_t bLink
; /* previous node at this level*/
586 int8_t kind
; /* kind of node (leaf, index, header, map)*/
587 u_int8_t height
; /* zero for header, map; child is one more than parent*/
588 u_int16_t numRecords
; /* number of records in this node*/
589 u_int16_t reserved
; /* reserved - initialized as zero */
591 typedef struct BTNodeDescriptor BTNodeDescriptor
;
593 /* Constants for BTNodeDescriptor kind */
601 /* BTHeaderRec -- The first record of a B-tree header node */
603 u_int16_t treeDepth
; /* maximum height (usually leaf nodes) */
604 u_int32_t rootNode
; /* node number of root node */
605 u_int32_t leafRecords
; /* number of leaf records in all leaf nodes */
606 u_int32_t firstLeafNode
; /* node number of first leaf node */
607 u_int32_t lastLeafNode
; /* node number of last leaf node */
608 u_int16_t nodeSize
; /* size of a node, in bytes */
609 u_int16_t maxKeyLength
; /* reserved */
610 u_int32_t totalNodes
; /* total number of nodes in tree */
611 u_int32_t freeNodes
; /* number of unused (free) nodes in tree */
612 u_int16_t reserved1
; /* unused */
613 u_int32_t clumpSize
; /* reserved */
614 u_int8_t btreeType
; /* reserved */
615 u_int8_t keyCompareType
; /* Key string Comparison Type */
616 u_int32_t attributes
; /* persistent attributes about the tree */
617 u_int32_t reserved3
[16]; /* reserved */
619 typedef struct BTHeaderRec BTHeaderRec
;
621 /* Constants for BTHeaderRec attributes */
623 kBTBadCloseMask
= 0x00000001, /* reserved */
624 kBTBigKeysMask
= 0x00000002, /* key length field is 16 bits */
625 kBTVariableIndexKeysMask
= 0x00000004 /* keys in index nodes are variable length */
629 /* Catalog Key Name Comparison Type */
631 kHFSCaseFolding
= 0xCF, /* case folding (case-insensitive) */
632 kHFSBinaryCompare
= 0xBC, /* binary compare (case-sensitive) */
635 /* JournalInfoBlock - Structure that describes where our journal lives */
636 struct JournalInfoBlock
{
638 u_int32_t device_signature
[8]; // signature used to locate our device.
639 u_int64_t offset
; // byte offset to the journal on the device
640 u_int64_t size
; // size in bytes of the journal
641 u_int32_t reserved
[32];
643 typedef struct JournalInfoBlock JournalInfoBlock
;
646 kJIJournalInFSMask
= 0x00000001,
647 kJIJournalOnOtherDeviceMask
= 0x00000002,
648 kJIJournalNeedInitMask
= 0x00000004
652 #pragma options align=reset
659 #warning hfs_format.h is not compatible with HFSVolumes.h (include only one)
660 #endif /* __HFSVOLUMES__ */
662 #endif /* __HFS_FORMAT__ */