2 * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 #ifndef __HFS_FORMAT__
23 #define __HFS_FORMAT__
25 #ifndef __HFSVOLUMES__
27 #include <sys/types.h>
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 kHFSXSigWord
= 0x4858, /* 'HX' in ASCII */
53 kHFSPlusVersion
= 0x0004, /* 'H+' volumes are version 4 only */
54 kHFSXVersion
= 0x0005, /* 'HX' volumes start with version 5 */
56 kHFSPlusMountVersion
= 0x31302E30, /* '10.0' for Mac OS X */
57 kHFSJMountVersion
= 0x4846534a /* 'HFSJ' for journaled HFS+ on OS X */
61 #ifdef __APPLE_API_PRIVATE
63 * Mac OS X has a special directory for linked and unlinked files (HFS Plus only).
64 * This directory and its contents are never exported from the filesystem under
67 * To make this folder name sort last, it has embedded null prefix.
68 * (0xC0, 0x80 in UTF-8)
70 #define HFSPLUSMETADATAFOLDER "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
73 * Files in the HFS Private Data folder have one of the following prefixes
74 * followed by a decimal number (no leading zeros). For indirect nodes this
75 * number is a 32 bit random number. For unlinked (deleted) files that are
76 * still open, the number is the file ID for that file.
78 * e.g. iNode7182000 and temp3296
80 #define HFS_INODE_PREFIX "iNode"
81 #define HFS_DELETE_PREFIX "temp"
83 #endif /* __APPLE_API_PRIVATE */
86 * Indirect link files (hard links) have the following type/creator.
89 kHardLinkFileType
= 0x686C6E6B, /* 'hlnk' */
90 kHFSPlusCreator
= 0x6866732B /* 'hfs+' */
95 /* Unicode strings are used for HFS Plus file and folder names */
97 u_int16_t length
; /* number of unicode characters */
98 u_int16_t unicode
[255]; /* unicode characters */
100 typedef struct HFSUniStr255 HFSUniStr255
;
101 typedef const HFSUniStr255
*ConstHFSUniStr255Param
;
102 #endif /* __FILES__ */
105 kHFSMaxVolumeNameChars
= 27,
106 kHFSMaxFileNameChars
= 31,
107 kHFSPlusMaxFileNameChars
= 255
111 /* Extent overflow file data structures */
114 struct HFSExtentKey
{
115 u_int8_t keyLength
; /* length of key, excluding this field */
116 u_int8_t forkType
; /* 0 = data fork, FF = resource fork */
117 u_int32_t fileID
; /* file ID */
118 u_int16_t startBlock
; /* first file allocation block number in this extent */
120 typedef struct HFSExtentKey HFSExtentKey
;
122 /* HFS Plus Extent key */
123 struct HFSPlusExtentKey
{
124 u_int16_t keyLength
; /* length of key, excluding this field */
125 u_int8_t forkType
; /* 0 = data fork, FF = resource fork */
126 u_int8_t pad
; /* make the other fields align on 32-bit boundary */
127 u_int32_t fileID
; /* file ID */
128 u_int32_t startBlock
; /* first file allocation block number in this extent */
130 typedef struct HFSPlusExtentKey HFSPlusExtentKey
;
132 /* Number of extent descriptors per extent record */
134 kHFSExtentDensity
= 3,
135 kHFSPlusExtentDensity
= 8
138 /* HFS extent descriptor */
139 struct HFSExtentDescriptor
{
140 u_int16_t startBlock
; /* first allocation block */
141 u_int16_t blockCount
; /* number of allocation blocks */
143 typedef struct HFSExtentDescriptor HFSExtentDescriptor
;
145 /* HFS Plus extent descriptor */
146 struct HFSPlusExtentDescriptor
{
147 u_int32_t startBlock
; /* first allocation block */
148 u_int32_t blockCount
; /* number of allocation blocks */
150 typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor
;
152 /* HFS extent record */
153 typedef HFSExtentDescriptor HFSExtentRecord
[3];
155 /* HFS Plus extent record */
156 typedef HFSPlusExtentDescriptor HFSPlusExtentRecord
[8];
159 /* Finder information */
160 struct FndrFileInfo
{
161 u_int32_t fdType
; /* file type */
162 u_int32_t fdCreator
; /* file creator */
163 u_int16_t fdFlags
; /* Finder flags */
165 int16_t v
; /* file's location */
170 typedef struct FndrFileInfo FndrFileInfo
;
173 struct { /* folder's window rectangle */
179 unsigned short frFlags
; /* Finder flags */
181 u_int16_t v
; /* folder's location */
186 typedef struct FndrDirInfo FndrDirInfo
;
188 struct FndrOpaqueInfo
{
191 typedef struct FndrOpaqueInfo FndrOpaqueInfo
;
194 /* HFS Plus Fork data info - 80 bytes */
195 struct HFSPlusForkData
{
196 u_int64_t logicalSize
; /* fork's logical size in bytes */
197 u_int32_t clumpSize
; /* fork's clump size in bytes */
198 u_int32_t totalBlocks
; /* total blocks used by this fork */
199 HFSPlusExtentRecord extents
; /* initial set of extents */
201 typedef struct HFSPlusForkData HFSPlusForkData
;
204 /* Mac OS X has 16 bytes worth of "BSD" info.
206 * Note: Mac OS 9 implementations and applications
207 * should preserve, but not change, this information.
209 struct HFSPlusBSDInfo
{
210 u_int32_t ownerID
; /* user or group ID of file/folder owner */
211 u_int32_t groupID
; /* additional user of group ID */
212 u_int8_t adminFlags
; /* super-user changeable flags */
213 u_int8_t ownerFlags
; /* owner changeable flags */
214 u_int16_t fileMode
; /* file type and permission bits */
216 u_int32_t iNodeNum
; /* indirect node number (hard links only) */
217 u_int32_t linkCount
; /* links that refer to this indirect node */
218 u_int32_t rawDevice
; /* special file device (FBLK and FCHR only) */
221 typedef struct HFSPlusBSDInfo HFSPlusBSDInfo
;
224 /* Catalog file data structures */
227 kHFSRootParentID
= 1, /* Parent ID of the root folder */
228 kHFSRootFolderID
= 2, /* Folder ID of the root folder */
229 kHFSExtentsFileID
= 3, /* File ID of the extents file */
230 kHFSCatalogFileID
= 4, /* File ID of the catalog file */
231 kHFSBadBlockFileID
= 5, /* File ID of the bad allocation block file */
232 kHFSAllocationFileID
= 6, /* File ID of the allocation file (HFS Plus only) */
233 kHFSStartupFileID
= 7, /* File ID of the startup file (HFS Plus only) */
234 kHFSAttributesFileID
= 8, /* File ID of the attribute file (HFS Plus only) */
235 kHFSRepairCatalogFileID
= 14, /* Used when rebuilding Catalog B-tree */
236 kHFSBogusExtentFileID
= 15, /* Used for exchanging extents in extents file */
237 kHFSFirstUserCatalogNodeID
= 16
240 /* HFS catalog key */
241 struct HFSCatalogKey
{
242 u_int8_t keyLength
; /* key length (in bytes) */
243 u_int8_t reserved
; /* reserved (set to zero) */
244 u_int32_t parentID
; /* parent folder ID */
245 u_char nodeName
[kHFSMaxFileNameChars
+ 1]; /* catalog node name */
247 typedef struct HFSCatalogKey HFSCatalogKey
;
249 /* HFS Plus catalog key */
250 struct HFSPlusCatalogKey
{
251 u_int16_t keyLength
; /* key length (in bytes) */
252 u_int32_t parentID
; /* parent folder ID */
253 HFSUniStr255 nodeName
; /* catalog node name */
255 typedef struct HFSPlusCatalogKey HFSPlusCatalogKey
;
257 /* Catalog record types */
259 /* HFS Catalog Records */
260 kHFSFolderRecord
= 0x0100, /* Folder record */
261 kHFSFileRecord
= 0x0200, /* File record */
262 kHFSFolderThreadRecord
= 0x0300, /* Folder thread record */
263 kHFSFileThreadRecord
= 0x0400, /* File thread record */
265 /* HFS Plus Catalog Records */
266 kHFSPlusFolderRecord
= 1, /* Folder record */
267 kHFSPlusFileRecord
= 2, /* File record */
268 kHFSPlusFolderThreadRecord
= 3, /* Folder thread record */
269 kHFSPlusFileThreadRecord
= 4 /* File thread record */
273 /* Catalog file record flags */
275 kHFSFileLockedBit
= 0x0000, /* file is locked and cannot be written to */
276 kHFSFileLockedMask
= 0x0001,
277 kHFSThreadExistsBit
= 0x0001, /* a file thread record exists for this file */
278 kHFSThreadExistsMask
= 0x0002
282 /* HFS catalog folder record - 70 bytes */
283 struct HFSCatalogFolder
{
284 int16_t recordType
; /* == kHFSFolderRecord */
285 u_int16_t flags
; /* folder flags */
286 u_int16_t valence
; /* folder valence */
287 u_int32_t folderID
; /* folder ID */
288 u_int32_t createDate
; /* date and time of creation */
289 u_int32_t modifyDate
; /* date and time of last modification */
290 u_int32_t backupDate
; /* date and time of last backup */
291 FndrDirInfo userInfo
; /* Finder information */
292 FndrOpaqueInfo finderInfo
; /* additional Finder information */
293 u_int32_t reserved
[4]; /* reserved - initialized as zero */
295 typedef struct HFSCatalogFolder HFSCatalogFolder
;
297 /* HFS Plus catalog folder record - 88 bytes */
298 struct HFSPlusCatalogFolder
{
299 int16_t recordType
; /* == kHFSPlusFolderRecord */
300 u_int16_t flags
; /* file flags */
301 u_int32_t valence
; /* folder's valence (limited to 2^16 in Mac OS) */
302 u_int32_t folderID
; /* folder ID */
303 u_int32_t createDate
; /* date and time of creation */
304 u_int32_t contentModDate
; /* date and time of last content modification */
305 u_int32_t attributeModDate
; /* date and time of last attribute modification */
306 u_int32_t accessDate
; /* date and time of last access (MacOS X only) */
307 u_int32_t backupDate
; /* date and time of last backup */
308 HFSPlusBSDInfo bsdInfo
; /* permissions (for MacOS X) */
309 FndrDirInfo userInfo
; /* Finder information */
310 FndrOpaqueInfo finderInfo
; /* additional Finder information */
311 u_int32_t textEncoding
; /* hint for name conversions */
312 u_int32_t reserved
; /* reserved - initialized as zero */
314 typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder
;
316 /* HFS catalog file record - 102 bytes */
317 struct HFSCatalogFile
{
318 int16_t recordType
; /* == kHFSFileRecord */
319 u_int8_t flags
; /* file flags */
320 int8_t fileType
; /* file type (unused ?) */
321 FndrFileInfo userInfo
; /* Finder information */
322 u_int32_t fileID
; /* file ID */
323 u_int16_t dataStartBlock
; /* not used - set to zero */
324 int32_t dataLogicalSize
; /* logical EOF of data fork */
325 int32_t dataPhysicalSize
; /* physical EOF of data fork */
326 u_int16_t rsrcStartBlock
; /* not used - set to zero */
327 int32_t rsrcLogicalSize
; /* logical EOF of resource fork */
328 int32_t rsrcPhysicalSize
; /* physical EOF of resource fork */
329 u_int32_t createDate
; /* date and time of creation */
330 u_int32_t modifyDate
; /* date and time of last modification */
331 u_int32_t backupDate
; /* date and time of last backup */
332 FndrOpaqueInfo finderInfo
; /* additional Finder information */
333 u_int16_t clumpSize
; /* file clump size (not used) */
334 HFSExtentRecord dataExtents
; /* first data fork extent record */
335 HFSExtentRecord rsrcExtents
; /* first resource fork extent record */
336 u_int32_t reserved
; /* reserved - initialized as zero */
338 typedef struct HFSCatalogFile HFSCatalogFile
;
340 /* HFS Plus catalog file record - 248 bytes */
341 struct HFSPlusCatalogFile
{
342 int16_t recordType
; /* == kHFSPlusFileRecord */
343 u_int16_t flags
; /* file flags */
344 u_int32_t reserved1
; /* reserved - initialized as zero */
345 u_int32_t fileID
; /* file ID */
346 u_int32_t createDate
; /* date and time of creation */
347 u_int32_t contentModDate
; /* date and time of last content modification */
348 u_int32_t attributeModDate
; /* date and time of last attribute modification */
349 u_int32_t accessDate
; /* date and time of last access (MacOS X only) */
350 u_int32_t backupDate
; /* date and time of last backup */
351 HFSPlusBSDInfo bsdInfo
; /* permissions (for MacOS X) */
352 FndrFileInfo userInfo
; /* Finder information */
353 FndrOpaqueInfo finderInfo
; /* additional Finder information */
354 u_int32_t textEncoding
; /* hint for name conversions */
355 u_int32_t reserved2
; /* reserved - initialized as zero */
357 /* Note: these start on double long (64 bit) boundry */
358 HFSPlusForkData dataFork
; /* size and block data for data fork */
359 HFSPlusForkData resourceFork
; /* size and block data for resource fork */
361 typedef struct HFSPlusCatalogFile HFSPlusCatalogFile
;
363 /* HFS catalog thread record - 46 bytes */
364 struct HFSCatalogThread
{
365 int16_t recordType
; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */
366 int32_t reserved
[2]; /* reserved - initialized as zero */
367 u_int32_t parentID
; /* parent ID for this catalog node */
368 u_char nodeName
[kHFSMaxFileNameChars
+ 1]; /* name of this catalog node */
370 typedef struct HFSCatalogThread HFSCatalogThread
;
372 /* HFS Plus catalog thread record -- 264 bytes */
373 struct HFSPlusCatalogThread
{
374 int16_t recordType
; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
375 int16_t reserved
; /* reserved - initialized as zero */
376 u_int32_t parentID
; /* parent ID for this catalog node */
377 HFSUniStr255 nodeName
; /* name of this catalog node (variable length) */
379 typedef struct HFSPlusCatalogThread HFSPlusCatalogThread
;
381 #ifdef __APPLE_API_UNSTABLE
383 These are the types of records in the attribute B-tree. The values were
384 chosen so that they wouldn't conflict with the catalog record types.
387 kHFSPlusAttrInlineData
= 0x10, /* if size < kAttrOverflowSize */
388 kHFSPlusAttrForkData
= 0x20, /* if size >= kAttrOverflowSize */
389 kHFSPlusAttrExtents
= 0x30 /* overflow extents for large attributes */
394 HFSPlusAttrInlineData
395 For small attributes, whose entire value is stored within this one
397 There would not be any other records for this attribute.
399 struct HFSPlusAttrInlineData
{
400 u_int32_t recordType
; /* == kHFSPlusAttrInlineData*/
402 u_int32_t logicalSize
; /* size in bytes of userData*/
403 u_int8_t userData
[2]; /* variable length; space allocated is a multiple of 2 bytes*/
405 typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData
;
410 For larger attributes, whose value is stored in allocation blocks.
411 If the attribute has more than 8 extents, there will be additonal
412 records (of type HFSPlusAttrExtents) for this attribute.
414 struct HFSPlusAttrForkData
{
415 u_int32_t recordType
; /* == kHFSPlusAttrForkData*/
417 HFSPlusForkData theFork
; /* size and first extents of value*/
419 typedef struct HFSPlusAttrForkData HFSPlusAttrForkData
;
423 This record contains information about overflow extents for large,
424 fragmented attributes.
426 struct HFSPlusAttrExtents
{
427 u_int32_t recordType
; /* == kHFSPlusAttrExtents*/
429 HFSPlusExtentRecord extents
; /* additional extents*/
431 typedef struct HFSPlusAttrExtents HFSPlusAttrExtents
;
433 /* A generic Attribute Record*/
434 union HFSPlusAttrRecord
{
435 u_int32_t recordType
;
436 HFSPlusAttrInlineData inlineData
;
437 HFSPlusAttrForkData forkData
;
438 HFSPlusAttrExtents overflowExtents
;
440 typedef union HFSPlusAttrRecord HFSPlusAttrRecord
;
442 /* Key and node lengths */
444 kHFSPlusExtentKeyMaximumLength
= sizeof(HFSPlusExtentKey
) - sizeof(u_int16_t
),
445 kHFSExtentKeyMaximumLength
= sizeof(HFSExtentKey
) - sizeof(u_int8_t
),
446 kHFSPlusCatalogKeyMaximumLength
= sizeof(HFSPlusCatalogKey
) - sizeof(u_int16_t
),
447 kHFSPlusCatalogKeyMinimumLength
= kHFSPlusCatalogKeyMaximumLength
- sizeof(HFSUniStr255
) + sizeof(u_int16_t
),
448 kHFSCatalogKeyMaximumLength
= sizeof(HFSCatalogKey
) - sizeof(u_int8_t
),
449 kHFSCatalogKeyMinimumLength
= kHFSCatalogKeyMaximumLength
- (kHFSMaxFileNameChars
+ 1) + sizeof(u_int8_t
),
450 kHFSPlusCatalogMinNodeSize
= 4096,
451 kHFSPlusExtentMinNodeSize
= 512,
452 kHFSPlusAttrMinNodeSize
= 4096
454 #endif /* __APPLE_API_UNSTABLE */
456 /* HFS and HFS Plus volume attribute bits */
458 /* Bits 0-6 are reserved (always cleared by MountVol call) */
459 kHFSVolumeHardwareLockBit
= 7, /* volume is locked by hardware */
460 kHFSVolumeUnmountedBit
= 8, /* volume was successfully unmounted */
461 kHFSVolumeSparedBlocksBit
= 9, /* volume has bad blocks spared */
462 kHFSVolumeNoCacheRequiredBit
= 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */
463 kHFSBootVolumeInconsistentBit
= 11, /* boot volume is inconsistent (System 7.6 and later) */
464 kHFSCatalogNodeIDsReusedBit
= 12,
465 kHFSVolumeJournaledBit
= 13, /* this volume has a journal on it */
466 kHFSVolumeInconsistentBit
= 14, /* serious inconsistencies detected at runtime */
467 kHFSVolumeSoftwareLockBit
= 15, /* volume is locked by software */
469 kHFSVolumeHardwareLockMask
= 1 << kHFSVolumeHardwareLockBit
,
470 kHFSVolumeUnmountedMask
= 1 << kHFSVolumeUnmountedBit
,
471 kHFSVolumeSparedBlocksMask
= 1 << kHFSVolumeSparedBlocksBit
,
472 kHFSVolumeNoCacheRequiredMask
= 1 << kHFSVolumeNoCacheRequiredBit
,
473 kHFSBootVolumeInconsistentMask
= 1 << kHFSBootVolumeInconsistentBit
,
474 kHFSCatalogNodeIDsReusedMask
= 1 << kHFSCatalogNodeIDsReusedBit
,
475 kHFSVolumeJournaledMask
= 1 << kHFSVolumeJournaledBit
,
476 kHFSVolumeInconsistentMask
= 1 << kHFSVolumeInconsistentBit
,
477 kHFSVolumeSoftwareLockMask
= 1 << kHFSVolumeSoftwareLockBit
,
478 kHFSMDBAttributesMask
= 0x8380
482 /* HFS Master Directory Block - 162 bytes */
483 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
484 struct HFSMasterDirectoryBlock
{
485 u_int16_t drSigWord
; /* == kHFSSigWord */
486 u_int32_t drCrDate
; /* date and time of volume creation */
487 u_int32_t drLsMod
; /* date and time of last modification */
488 u_int16_t drAtrb
; /* volume attributes */
489 u_int16_t drNmFls
; /* number of files in root folder */
490 u_int16_t drVBMSt
; /* first block of volume bitmap */
491 u_int16_t drAllocPtr
; /* start of next allocation search */
492 u_int16_t drNmAlBlks
; /* number of allocation blocks in volume */
493 u_int32_t drAlBlkSiz
; /* size (in bytes) of allocation blocks */
494 u_int32_t drClpSiz
; /* default clump size */
495 u_int16_t drAlBlSt
; /* first allocation block in volume */
496 u_int32_t drNxtCNID
; /* next unused catalog node ID */
497 u_int16_t drFreeBks
; /* number of unused allocation blocks */
498 u_char drVN
[kHFSMaxVolumeNameChars
+ 1]; /* volume name */
499 u_int32_t drVolBkUp
; /* date and time of last backup */
500 u_int16_t drVSeqNum
; /* volume backup sequence number */
501 u_int32_t drWrCnt
; /* volume write count */
502 u_int32_t drXTClpSiz
; /* clump size for extents overflow file */
503 u_int32_t drCTClpSiz
; /* clump size for catalog file */
504 u_int16_t drNmRtDirs
; /* number of directories in root folder */
505 u_int32_t drFilCnt
; /* number of files in volume */
506 u_int32_t drDirCnt
; /* number of directories in volume */
507 u_int32_t drFndrInfo
[8]; /* information used by the Finder */
508 u_int16_t drEmbedSigWord
; /* embedded volume signature (formerly drVCSize) */
509 HFSExtentDescriptor drEmbedExtent
; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
510 u_int32_t drXTFlSize
; /* size of extents overflow file */
511 HFSExtentRecord drXTExtRec
; /* extent record for extents overflow file */
512 u_int32_t drCTFlSize
; /* size of catalog file */
513 HFSExtentRecord drCTExtRec
; /* extent record for catalog file */
515 typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock
;
518 #ifdef __APPLE_API_UNSTABLE
519 #define SET_HFS_TEXT_ENCODING(hint) \
520 (0x656e6300 | ((hint) & 0xff))
521 #define GET_HFS_TEXT_ENCODING(hint) \
522 (((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU)
523 #endif /* __APPLE_API_UNSTABLE */
526 /* HFS Plus Volume Header - 512 bytes */
527 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
528 struct HFSPlusVolumeHeader
{
529 u_int16_t signature
; /* == kHFSPlusSigWord */
530 u_int16_t version
; /* == kHFSPlusVersion */
531 u_int32_t attributes
; /* volume attributes */
532 u_int32_t lastMountedVersion
; /* implementation version which last mounted volume */
533 u_int32_t journalInfoBlock
; /* block addr of journal info (if volume is journaled, zero otherwise) */
535 u_int32_t createDate
; /* date and time of volume creation */
536 u_int32_t modifyDate
; /* date and time of last modification */
537 u_int32_t backupDate
; /* date and time of last backup */
538 u_int32_t checkedDate
; /* date and time of last disk check */
540 u_int32_t fileCount
; /* number of files in volume */
541 u_int32_t folderCount
; /* number of directories in volume */
543 u_int32_t blockSize
; /* size (in bytes) of allocation blocks */
544 u_int32_t totalBlocks
; /* number of allocation blocks in volume (includes this header and VBM*/
545 u_int32_t freeBlocks
; /* number of unused allocation blocks */
547 u_int32_t nextAllocation
; /* start of next allocation search */
548 u_int32_t rsrcClumpSize
; /* default resource fork clump size */
549 u_int32_t dataClumpSize
; /* default data fork clump size */
550 u_int32_t nextCatalogID
; /* next unused catalog node ID */
552 u_int32_t writeCount
; /* volume write count */
553 u_int64_t encodingsBitmap
; /* which encodings have been use on this volume */
555 u_int8_t finderInfo
[32]; /* information used by the Finder */
557 HFSPlusForkData allocationFile
; /* allocation bitmap file */
558 HFSPlusForkData extentsFile
; /* extents B-tree file */
559 HFSPlusForkData catalogFile
; /* catalog B-tree file */
560 HFSPlusForkData attributesFile
; /* extended attributes B-tree file */
561 HFSPlusForkData startupFile
; /* boot file (secondary loader) */
563 typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader
;
566 /* B-tree structures */
575 u_int8_t rawData
[kMaxKeyLength
+2];
577 typedef union BTreeKey BTreeKey
;
579 /* BTNodeDescriptor -- Every B-tree node starts with these fields. */
580 struct BTNodeDescriptor
{
581 u_int32_t fLink
; /* next node at this level*/
582 u_int32_t bLink
; /* previous node at this level*/
583 int8_t kind
; /* kind of node (leaf, index, header, map)*/
584 u_int8_t height
; /* zero for header, map; child is one more than parent*/
585 u_int16_t numRecords
; /* number of records in this node*/
586 u_int16_t reserved
; /* reserved - initialized as zero */
588 typedef struct BTNodeDescriptor BTNodeDescriptor
;
590 /* Constants for BTNodeDescriptor kind */
598 /* BTHeaderRec -- The first record of a B-tree header node */
600 u_int16_t treeDepth
; /* maximum height (usually leaf nodes) */
601 u_int32_t rootNode
; /* node number of root node */
602 u_int32_t leafRecords
; /* number of leaf records in all leaf nodes */
603 u_int32_t firstLeafNode
; /* node number of first leaf node */
604 u_int32_t lastLeafNode
; /* node number of last leaf node */
605 u_int16_t nodeSize
; /* size of a node, in bytes */
606 u_int16_t maxKeyLength
; /* reserved */
607 u_int32_t totalNodes
; /* total number of nodes in tree */
608 u_int32_t freeNodes
; /* number of unused (free) nodes in tree */
609 u_int16_t reserved1
; /* unused */
610 u_int32_t clumpSize
; /* reserved */
611 u_int8_t btreeType
; /* reserved */
612 u_int8_t keyCompareType
; /* Key string Comparison Type */
613 u_int32_t attributes
; /* persistent attributes about the tree */
614 u_int32_t reserved3
[16]; /* reserved */
616 typedef struct BTHeaderRec BTHeaderRec
;
618 /* Constants for BTHeaderRec attributes */
620 kBTBadCloseMask
= 0x00000001, /* reserved */
621 kBTBigKeysMask
= 0x00000002, /* key length field is 16 bits */
622 kBTVariableIndexKeysMask
= 0x00000004 /* keys in index nodes are variable length */
626 /* Catalog Key Name Comparison Type */
628 kHFSCaseFolding
= 0xCF, /* case folding (case-insensitive) */
629 kHFSBinaryCompare
= 0xBC, /* binary compare (case-sensitive) */
632 /* JournalInfoBlock - Structure that describes where our journal lives */
633 struct JournalInfoBlock
{
635 u_int32_t device_signature
[8]; // signature used to locate our device.
636 u_int64_t offset
; // byte offset to the journal on the device
637 u_int64_t size
; // size in bytes of the journal
638 u_int32_t reserved
[32];
640 typedef struct JournalInfoBlock JournalInfoBlock
;
643 kJIJournalInFSMask
= 0x00000001,
644 kJIJournalOnOtherDeviceMask
= 0x00000002,
645 kJIJournalNeedInitMask
= 0x00000004
649 #pragma options align=reset
656 #warning hfs_format.h is not compatible with HFSVolumes.h (include only one)
657 #endif /* __HFSVOLUMES__ */
659 #endif /* __HFS_FORMAT__ */