2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 #ifndef __HFS_FORMAT__
29 #define __HFS_FORMAT__
31 #include <sys/types.h>
32 #include <sys/appleapiopts.h>
37 * This file describes the on-disk format for HFS and HFS Plus volumes.
38 * The HFS Plus volume format is desciibed in detail in Apple Technote 1150.
40 * http://developer.apple.com/technotes/tn/tn1150.html
48 /* some on-disk hfs structures have 68K alignment (misaligned) */
49 #pragma options align=mac68k
51 /* Signatures used to differentiate between HFS and HFS Plus volumes */
53 kHFSSigWord
= 0x4244, /* 'BD' in ASCII */
54 kHFSPlusSigWord
= 0x482B, /* 'H+' in ASCII */
55 kHFSXSigWord
= 0x4858, /* 'HX' in ASCII */
57 kHFSPlusVersion
= 0x0004, /* 'H+' volumes are version 4 only */
58 kHFSXVersion
= 0x0005, /* 'HX' volumes start with version 5 */
60 kHFSPlusMountVersion
= 0x31302E30, /* '10.0' for Mac OS X */
61 kHFSJMountVersion
= 0x4846534a, /* 'HFSJ' for journaled HFS+ on OS X */
62 kFSKMountVersion
= 0x46534b21 /* 'FSK!' for failed journal replay */
66 #ifdef __APPLE_API_PRIVATE
68 * Mac OS X has a special directory for linked and unlinked files (HFS Plus only).
69 * This directory and its contents are never exported from the filesystem under
72 * To make this folder name sort last, it has embedded null prefix.
73 * (0xC0, 0x80 in UTF-8)
75 #define HFSPLUSMETADATAFOLDER "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
78 * Files in the HFS Private Data folder have one of the following prefixes
79 * followed by a decimal number (no leading zeros). For indirect nodes this
80 * number is a 32 bit random number. For unlinked (deleted) files that are
81 * still open, the number is the file ID for that file.
83 * e.g. iNode7182000 and temp3296
85 #define HFS_INODE_PREFIX "iNode"
86 #define HFS_DELETE_PREFIX "temp"
88 #endif /* __APPLE_API_PRIVATE */
91 * Indirect link files (hard links) have the following type/creator.
94 kHardLinkFileType
= 0x686C6E6B, /* 'hlnk' */
95 kHFSPlusCreator
= 0x6866732B /* 'hfs+' */
99 #ifndef _HFSUNISTR255_DEFINED_
100 #define _HFSUNISTR255_DEFINED_
101 /* Unicode strings are used for HFS Plus file and folder names */
102 struct HFSUniStr255
{
103 u_int16_t length
; /* number of unicode characters */
104 u_int16_t unicode
[255]; /* unicode characters */
106 typedef struct HFSUniStr255 HFSUniStr255
;
107 typedef const HFSUniStr255
*ConstHFSUniStr255Param
;
108 #endif /* _HFSUNISTR255_DEFINED_ */
111 kHFSMaxVolumeNameChars
= 27,
112 kHFSMaxFileNameChars
= 31,
113 kHFSPlusMaxFileNameChars
= 255
117 /* Extent overflow file data structures */
120 struct HFSExtentKey
{
121 u_int8_t keyLength
; /* length of key, excluding this field */
122 u_int8_t forkType
; /* 0 = data fork, FF = resource fork */
123 u_int32_t fileID
; /* file ID */
124 u_int16_t startBlock
; /* first file allocation block number in this extent */
126 typedef struct HFSExtentKey HFSExtentKey
;
128 /* HFS Plus Extent key */
129 struct HFSPlusExtentKey
{
130 u_int16_t keyLength
; /* length of key, excluding this field */
131 u_int8_t forkType
; /* 0 = data fork, FF = resource fork */
132 u_int8_t pad
; /* make the other fields align on 32-bit boundary */
133 u_int32_t fileID
; /* file ID */
134 u_int32_t startBlock
; /* first file allocation block number in this extent */
136 typedef struct HFSPlusExtentKey HFSPlusExtentKey
;
138 /* Number of extent descriptors per extent record */
140 kHFSExtentDensity
= 3,
141 kHFSPlusExtentDensity
= 8
144 /* HFS extent descriptor */
145 struct HFSExtentDescriptor
{
146 u_int16_t startBlock
; /* first allocation block */
147 u_int16_t blockCount
; /* number of allocation blocks */
149 typedef struct HFSExtentDescriptor HFSExtentDescriptor
;
151 /* HFS Plus extent descriptor */
152 struct HFSPlusExtentDescriptor
{
153 u_int32_t startBlock
; /* first allocation block */
154 u_int32_t blockCount
; /* number of allocation blocks */
156 typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor
;
158 /* HFS extent record */
159 typedef HFSExtentDescriptor HFSExtentRecord
[3];
161 /* HFS Plus extent record */
162 typedef HFSPlusExtentDescriptor HFSPlusExtentRecord
[8];
165 /* Finder information */
166 struct FndrFileInfo
{
167 u_int32_t fdType
; /* file type */
168 u_int32_t fdCreator
; /* file creator */
169 u_int16_t fdFlags
; /* Finder flags */
171 int16_t v
; /* file's location */
176 typedef struct FndrFileInfo FndrFileInfo
;
179 struct { /* folder's window rectangle */
185 unsigned short frFlags
; /* Finder flags */
187 u_int16_t v
; /* folder's location */
192 typedef struct FndrDirInfo FndrDirInfo
;
194 struct FndrOpaqueInfo
{
197 typedef struct FndrOpaqueInfo FndrOpaqueInfo
;
200 /* HFS Plus Fork data info - 80 bytes */
201 struct HFSPlusForkData
{
202 u_int64_t logicalSize
; /* fork's logical size in bytes */
203 u_int32_t clumpSize
; /* fork's clump size in bytes */
204 u_int32_t totalBlocks
; /* total blocks used by this fork */
205 HFSPlusExtentRecord extents
; /* initial set of extents */
207 typedef struct HFSPlusForkData HFSPlusForkData
;
210 /* Mac OS X has 16 bytes worth of "BSD" info.
212 * Note: Mac OS 9 implementations and applications
213 * should preserve, but not change, this information.
215 struct HFSPlusBSDInfo
{
216 u_int32_t ownerID
; /* user or group ID of file/folder owner */
217 u_int32_t groupID
; /* additional user of group ID */
218 u_int8_t adminFlags
; /* super-user changeable flags */
219 u_int8_t ownerFlags
; /* owner changeable flags */
220 u_int16_t fileMode
; /* file type and permission bits */
222 u_int32_t iNodeNum
; /* indirect node number (hard links only) */
223 u_int32_t linkCount
; /* links that refer to this indirect node */
224 u_int32_t rawDevice
; /* special file device (FBLK and FCHR only) */
227 typedef struct HFSPlusBSDInfo HFSPlusBSDInfo
;
230 /* Catalog file data structures */
233 kHFSRootParentID
= 1, /* Parent ID of the root folder */
234 kHFSRootFolderID
= 2, /* Folder ID of the root folder */
235 kHFSExtentsFileID
= 3, /* File ID of the extents file */
236 kHFSCatalogFileID
= 4, /* File ID of the catalog file */
237 kHFSBadBlockFileID
= 5, /* File ID of the bad allocation block file */
238 kHFSAllocationFileID
= 6, /* File ID of the allocation file (HFS Plus only) */
239 kHFSStartupFileID
= 7, /* File ID of the startup file (HFS Plus only) */
240 kHFSAttributesFileID
= 8, /* File ID of the attribute file (HFS Plus only) */
241 kHFSRepairCatalogFileID
= 14, /* Used when rebuilding Catalog B-tree */
242 kHFSBogusExtentFileID
= 15, /* Used for exchanging extents in extents file */
243 kHFSFirstUserCatalogNodeID
= 16
246 /* HFS catalog key */
247 struct HFSCatalogKey
{
248 u_int8_t keyLength
; /* key length (in bytes) */
249 u_int8_t reserved
; /* reserved (set to zero) */
250 u_int32_t parentID
; /* parent folder ID */
251 u_int8_t nodeName
[kHFSMaxFileNameChars
+ 1]; /* catalog node name */
253 typedef struct HFSCatalogKey HFSCatalogKey
;
255 /* HFS Plus catalog key */
256 struct HFSPlusCatalogKey
{
257 u_int16_t keyLength
; /* key length (in bytes) */
258 u_int32_t parentID
; /* parent folder ID */
259 HFSUniStr255 nodeName
; /* catalog node name */
261 typedef struct HFSPlusCatalogKey HFSPlusCatalogKey
;
263 /* Catalog record types */
265 /* HFS Catalog Records */
266 kHFSFolderRecord
= 0x0100, /* Folder record */
267 kHFSFileRecord
= 0x0200, /* File record */
268 kHFSFolderThreadRecord
= 0x0300, /* Folder thread record */
269 kHFSFileThreadRecord
= 0x0400, /* File thread record */
271 /* HFS Plus Catalog Records */
272 kHFSPlusFolderRecord
= 1, /* Folder record */
273 kHFSPlusFileRecord
= 2, /* File record */
274 kHFSPlusFolderThreadRecord
= 3, /* Folder thread record */
275 kHFSPlusFileThreadRecord
= 4 /* File thread record */
279 /* Catalog file record flags */
281 kHFSFileLockedBit
= 0x0000, /* file is locked and cannot be written to */
282 kHFSFileLockedMask
= 0x0001,
284 kHFSThreadExistsBit
= 0x0001, /* a file thread record exists for this file */
285 kHFSThreadExistsMask
= 0x0002,
287 kHFSHasAttributesBit
= 0x0002, /* object has extended attributes */
288 kHFSHasAttributesMask
= 0x0004,
290 kHFSHasSecurityBit
= 0x0003, /* object has security data (ACLs) */
291 kHFSHasSecurityMask
= 0x0008
295 /* HFS catalog folder record - 70 bytes */
296 struct HFSCatalogFolder
{
297 int16_t recordType
; /* == kHFSFolderRecord */
298 u_int16_t flags
; /* folder flags */
299 u_int16_t valence
; /* folder valence */
300 u_int32_t folderID
; /* folder ID */
301 u_int32_t createDate
; /* date and time of creation */
302 u_int32_t modifyDate
; /* date and time of last modification */
303 u_int32_t backupDate
; /* date and time of last backup */
304 FndrDirInfo userInfo
; /* Finder information */
305 FndrOpaqueInfo finderInfo
; /* additional Finder information */
306 u_int32_t reserved
[4]; /* reserved - initialized as zero */
308 typedef struct HFSCatalogFolder HFSCatalogFolder
;
310 /* HFS Plus catalog folder record - 88 bytes */
311 struct HFSPlusCatalogFolder
{
312 int16_t recordType
; /* == kHFSPlusFolderRecord */
313 u_int16_t flags
; /* file flags */
314 u_int32_t valence
; /* folder's valence (limited to 2^16 in Mac OS) */
315 u_int32_t folderID
; /* folder ID */
316 u_int32_t createDate
; /* date and time of creation */
317 u_int32_t contentModDate
; /* date and time of last content modification */
318 u_int32_t attributeModDate
; /* date and time of last attribute modification */
319 u_int32_t accessDate
; /* date and time of last access (MacOS X only) */
320 u_int32_t backupDate
; /* date and time of last backup */
321 HFSPlusBSDInfo bsdInfo
; /* permissions (for MacOS X) */
322 FndrDirInfo userInfo
; /* Finder information */
323 FndrOpaqueInfo finderInfo
; /* additional Finder information */
324 u_int32_t textEncoding
; /* hint for name conversions */
325 u_int32_t attrBlocks
; /* cached count of attribute data blocks */
327 typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder
;
329 /* HFS catalog file record - 102 bytes */
330 struct HFSCatalogFile
{
331 int16_t recordType
; /* == kHFSFileRecord */
332 u_int8_t flags
; /* file flags */
333 int8_t fileType
; /* file type (unused ?) */
334 FndrFileInfo userInfo
; /* Finder information */
335 u_int32_t fileID
; /* file ID */
336 u_int16_t dataStartBlock
; /* not used - set to zero */
337 int32_t dataLogicalSize
; /* logical EOF of data fork */
338 int32_t dataPhysicalSize
; /* physical EOF of data fork */
339 u_int16_t rsrcStartBlock
; /* not used - set to zero */
340 int32_t rsrcLogicalSize
; /* logical EOF of resource fork */
341 int32_t rsrcPhysicalSize
; /* physical EOF of resource fork */
342 u_int32_t createDate
; /* date and time of creation */
343 u_int32_t modifyDate
; /* date and time of last modification */
344 u_int32_t backupDate
; /* date and time of last backup */
345 FndrOpaqueInfo finderInfo
; /* additional Finder information */
346 u_int16_t clumpSize
; /* file clump size (not used) */
347 HFSExtentRecord dataExtents
; /* first data fork extent record */
348 HFSExtentRecord rsrcExtents
; /* first resource fork extent record */
349 u_int32_t reserved
; /* reserved - initialized as zero */
351 typedef struct HFSCatalogFile HFSCatalogFile
;
353 /* HFS Plus catalog file record - 248 bytes */
354 struct HFSPlusCatalogFile
{
355 int16_t recordType
; /* == kHFSPlusFileRecord */
356 u_int16_t flags
; /* file flags */
357 u_int32_t reserved1
; /* reserved - initialized as zero */
358 u_int32_t fileID
; /* file ID */
359 u_int32_t createDate
; /* date and time of creation */
360 u_int32_t contentModDate
; /* date and time of last content modification */
361 u_int32_t attributeModDate
; /* date and time of last attribute modification */
362 u_int32_t accessDate
; /* date and time of last access (MacOS X only) */
363 u_int32_t backupDate
; /* date and time of last backup */
364 HFSPlusBSDInfo bsdInfo
; /* permissions (for MacOS X) */
365 FndrFileInfo userInfo
; /* Finder information */
366 FndrOpaqueInfo finderInfo
; /* additional Finder information */
367 u_int32_t textEncoding
; /* hint for name conversions */
368 u_int32_t attrBlocks
; /* cached count of attribute data blocks */
370 /* Note: these start on double long (64 bit) boundry */
371 HFSPlusForkData dataFork
; /* size and block data for data fork */
372 HFSPlusForkData resourceFork
; /* size and block data for resource fork */
374 typedef struct HFSPlusCatalogFile HFSPlusCatalogFile
;
376 /* HFS catalog thread record - 46 bytes */
377 struct HFSCatalogThread
{
378 int16_t recordType
; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */
379 int32_t reserved
[2]; /* reserved - initialized as zero */
380 u_int32_t parentID
; /* parent ID for this catalog node */
381 u_int8_t nodeName
[kHFSMaxFileNameChars
+ 1]; /* name of this catalog node */
383 typedef struct HFSCatalogThread HFSCatalogThread
;
385 /* HFS Plus catalog thread record -- 264 bytes */
386 struct HFSPlusCatalogThread
{
387 int16_t recordType
; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
388 int16_t reserved
; /* reserved - initialized as zero */
389 u_int32_t parentID
; /* parent ID for this catalog node */
390 HFSUniStr255 nodeName
; /* name of this catalog node (variable length) */
392 typedef struct HFSPlusCatalogThread HFSPlusCatalogThread
;
394 #ifdef __APPLE_API_UNSTABLE
396 These are the types of records in the attribute B-tree. The values were
397 chosen so that they wouldn't conflict with the catalog record types.
400 kHFSPlusAttrInlineData
= 0x10, /* if size < kAttrOverflowSize */
401 kHFSPlusAttrForkData
= 0x20, /* if size >= kAttrOverflowSize */
402 kHFSPlusAttrExtents
= 0x30 /* overflow extents for large attributes */
408 For larger attributes, whose value is stored in allocation blocks.
409 If the attribute has more than 8 extents, there will be additonal
410 records (of type HFSPlusAttrExtents) for this attribute.
412 struct HFSPlusAttrForkData
{
413 u_int32_t recordType
; /* == kHFSPlusAttrForkData*/
415 HFSPlusForkData theFork
; /* size and first extents of value*/
417 typedef struct HFSPlusAttrForkData HFSPlusAttrForkData
;
421 This record contains information about overflow extents for large,
422 fragmented attributes.
424 struct HFSPlusAttrExtents
{
425 u_int32_t recordType
; /* == kHFSPlusAttrExtents*/
427 HFSPlusExtentRecord extents
; /* additional extents*/
429 typedef struct HFSPlusAttrExtents HFSPlusAttrExtents
;
432 * Atrributes B-tree Data Record
434 * For small attributes, whose entire value is stored
435 * within a single B-tree record.
437 struct HFSPlusAttrData
{
438 u_int32_t recordType
; /* == kHFSPlusAttrInlineData */
439 u_int32_t reserved
[2];
440 u_int32_t attrSize
; /* size of attribute data in bytes */
441 u_int8_t attrData
[2]; /* variable length */
443 typedef struct HFSPlusAttrData HFSPlusAttrData
;
446 /* HFSPlusAttrInlineData is obsolete use HFSPlusAttrData instead */
447 struct HFSPlusAttrInlineData
{
448 u_int32_t recordType
;
450 u_int32_t logicalSize
;
451 u_int8_t userData
[2];
453 typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData
;
456 /* A generic Attribute Record*/
457 union HFSPlusAttrRecord
{
458 u_int32_t recordType
;
459 HFSPlusAttrInlineData inlineData
; /* NOT USED */
460 HFSPlusAttrData attrData
;
461 HFSPlusAttrForkData forkData
;
462 HFSPlusAttrExtents overflowExtents
;
464 typedef union HFSPlusAttrRecord HFSPlusAttrRecord
;
467 enum { kHFSMaxAttrNameLen
= 127 };
468 struct HFSPlusAttrKey
{
469 u_int16_t keyLength
; /* key length (in bytes) */
470 u_int16_t pad
; /* set to zero */
471 u_int32_t fileID
; /* file associated with attribute */
472 u_int32_t startBlock
; /* first attribue allocation block number for extents */
473 u_int16_t attrNameLen
; /* number of unicode characters */
474 u_int16_t attrName
[kHFSMaxAttrNameLen
]; /* attribute name (Unicode) */
476 typedef struct HFSPlusAttrKey HFSPlusAttrKey
;
478 #define kHFSPlusAttrKeyMaximumLength (sizeof(HFSPlusAttrKey) - sizeof(u_int16_t))
479 #define kHFSPlusAttrKeyMinimumLength (kHFSPlusAttrKeyMaximumLength - kHFSMaxAttrNameLen*sizeof(u_int16_t))
481 #endif /* __APPLE_API_UNSTABLE */
484 /* Key and node lengths */
486 kHFSPlusExtentKeyMaximumLength
= sizeof(HFSPlusExtentKey
) - sizeof(u_int16_t
),
487 kHFSExtentKeyMaximumLength
= sizeof(HFSExtentKey
) - sizeof(u_int8_t
),
488 kHFSPlusCatalogKeyMaximumLength
= sizeof(HFSPlusCatalogKey
) - sizeof(u_int16_t
),
489 kHFSPlusCatalogKeyMinimumLength
= kHFSPlusCatalogKeyMaximumLength
- sizeof(HFSUniStr255
) + sizeof(u_int16_t
),
490 kHFSCatalogKeyMaximumLength
= sizeof(HFSCatalogKey
) - sizeof(u_int8_t
),
491 kHFSCatalogKeyMinimumLength
= kHFSCatalogKeyMaximumLength
- (kHFSMaxFileNameChars
+ 1) + sizeof(u_int8_t
),
492 kHFSPlusCatalogMinNodeSize
= 4096,
493 kHFSPlusExtentMinNodeSize
= 512,
494 kHFSPlusAttrMinNodeSize
= 4096
497 /* HFS and HFS Plus volume attribute bits */
499 /* Bits 0-6 are reserved (always cleared by MountVol call) */
500 kHFSVolumeHardwareLockBit
= 7, /* volume is locked by hardware */
501 kHFSVolumeUnmountedBit
= 8, /* volume was successfully unmounted */
502 kHFSVolumeSparedBlocksBit
= 9, /* volume has bad blocks spared */
503 kHFSVolumeNoCacheRequiredBit
= 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */
504 kHFSBootVolumeInconsistentBit
= 11, /* boot volume is inconsistent (System 7.6 and later) */
505 kHFSCatalogNodeIDsReusedBit
= 12,
506 kHFSVolumeJournaledBit
= 13, /* this volume has a journal on it */
507 kHFSVolumeInconsistentBit
= 14, /* serious inconsistencies detected at runtime */
508 kHFSVolumeSoftwareLockBit
= 15, /* volume is locked by software */
510 kHFSVolumeHardwareLockMask
= 1 << kHFSVolumeHardwareLockBit
,
511 kHFSVolumeUnmountedMask
= 1 << kHFSVolumeUnmountedBit
,
512 kHFSVolumeSparedBlocksMask
= 1 << kHFSVolumeSparedBlocksBit
,
513 kHFSVolumeNoCacheRequiredMask
= 1 << kHFSVolumeNoCacheRequiredBit
,
514 kHFSBootVolumeInconsistentMask
= 1 << kHFSBootVolumeInconsistentBit
,
515 kHFSCatalogNodeIDsReusedMask
= 1 << kHFSCatalogNodeIDsReusedBit
,
516 kHFSVolumeJournaledMask
= 1 << kHFSVolumeJournaledBit
,
517 kHFSVolumeInconsistentMask
= 1 << kHFSVolumeInconsistentBit
,
518 kHFSVolumeSoftwareLockMask
= 1 << kHFSVolumeSoftwareLockBit
,
519 kHFSMDBAttributesMask
= 0x8380
523 /* HFS Master Directory Block - 162 bytes */
524 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
525 struct HFSMasterDirectoryBlock
{
526 u_int16_t drSigWord
; /* == kHFSSigWord */
527 u_int32_t drCrDate
; /* date and time of volume creation */
528 u_int32_t drLsMod
; /* date and time of last modification */
529 u_int16_t drAtrb
; /* volume attributes */
530 u_int16_t drNmFls
; /* number of files in root folder */
531 u_int16_t drVBMSt
; /* first block of volume bitmap */
532 u_int16_t drAllocPtr
; /* start of next allocation search */
533 u_int16_t drNmAlBlks
; /* number of allocation blocks in volume */
534 u_int32_t drAlBlkSiz
; /* size (in bytes) of allocation blocks */
535 u_int32_t drClpSiz
; /* default clump size */
536 u_int16_t drAlBlSt
; /* first allocation block in volume */
537 u_int32_t drNxtCNID
; /* next unused catalog node ID */
538 u_int16_t drFreeBks
; /* number of unused allocation blocks */
539 u_int8_t drVN
[kHFSMaxVolumeNameChars
+ 1]; /* volume name */
540 u_int32_t drVolBkUp
; /* date and time of last backup */
541 u_int16_t drVSeqNum
; /* volume backup sequence number */
542 u_int32_t drWrCnt
; /* volume write count */
543 u_int32_t drXTClpSiz
; /* clump size for extents overflow file */
544 u_int32_t drCTClpSiz
; /* clump size for catalog file */
545 u_int16_t drNmRtDirs
; /* number of directories in root folder */
546 u_int32_t drFilCnt
; /* number of files in volume */
547 u_int32_t drDirCnt
; /* number of directories in volume */
548 u_int32_t drFndrInfo
[8]; /* information used by the Finder */
549 u_int16_t drEmbedSigWord
; /* embedded volume signature (formerly drVCSize) */
550 HFSExtentDescriptor drEmbedExtent
; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
551 u_int32_t drXTFlSize
; /* size of extents overflow file */
552 HFSExtentRecord drXTExtRec
; /* extent record for extents overflow file */
553 u_int32_t drCTFlSize
; /* size of catalog file */
554 HFSExtentRecord drCTExtRec
; /* extent record for catalog file */
556 typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock
;
559 #ifdef __APPLE_API_UNSTABLE
560 #define SET_HFS_TEXT_ENCODING(hint) \
561 (0x656e6300 | ((hint) & 0xff))
562 #define GET_HFS_TEXT_ENCODING(hint) \
563 (((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU)
564 #endif /* __APPLE_API_UNSTABLE */
567 /* HFS Plus Volume Header - 512 bytes */
568 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
569 struct HFSPlusVolumeHeader
{
570 u_int16_t signature
; /* == kHFSPlusSigWord */
571 u_int16_t version
; /* == kHFSPlusVersion */
572 u_int32_t attributes
; /* volume attributes */
573 u_int32_t lastMountedVersion
; /* implementation version which last mounted volume */
574 u_int32_t journalInfoBlock
; /* block addr of journal info (if volume is journaled, zero otherwise) */
576 u_int32_t createDate
; /* date and time of volume creation */
577 u_int32_t modifyDate
; /* date and time of last modification */
578 u_int32_t backupDate
; /* date and time of last backup */
579 u_int32_t checkedDate
; /* date and time of last disk check */
581 u_int32_t fileCount
; /* number of files in volume */
582 u_int32_t folderCount
; /* number of directories in volume */
584 u_int32_t blockSize
; /* size (in bytes) of allocation blocks */
585 u_int32_t totalBlocks
; /* number of allocation blocks in volume (includes this header and VBM*/
586 u_int32_t freeBlocks
; /* number of unused allocation blocks */
588 u_int32_t nextAllocation
; /* start of next allocation search */
589 u_int32_t rsrcClumpSize
; /* default resource fork clump size */
590 u_int32_t dataClumpSize
; /* default data fork clump size */
591 u_int32_t nextCatalogID
; /* next unused catalog node ID */
593 u_int32_t writeCount
; /* volume write count */
594 u_int64_t encodingsBitmap
; /* which encodings have been use on this volume */
596 u_int8_t finderInfo
[32]; /* information used by the Finder */
598 HFSPlusForkData allocationFile
; /* allocation bitmap file */
599 HFSPlusForkData extentsFile
; /* extents B-tree file */
600 HFSPlusForkData catalogFile
; /* catalog B-tree file */
601 HFSPlusForkData attributesFile
; /* extended attributes B-tree file */
602 HFSPlusForkData startupFile
; /* boot file (secondary loader) */
604 typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader
;
607 /* B-tree structures */
616 u_int8_t rawData
[kMaxKeyLength
+2];
618 typedef union BTreeKey BTreeKey
;
620 /* BTNodeDescriptor -- Every B-tree node starts with these fields. */
621 struct BTNodeDescriptor
{
622 u_int32_t fLink
; /* next node at this level*/
623 u_int32_t bLink
; /* previous node at this level*/
624 int8_t kind
; /* kind of node (leaf, index, header, map)*/
625 u_int8_t height
; /* zero for header, map; child is one more than parent*/
626 u_int16_t numRecords
; /* number of records in this node*/
627 u_int16_t reserved
; /* reserved - initialized as zero */
629 typedef struct BTNodeDescriptor BTNodeDescriptor
;
631 /* Constants for BTNodeDescriptor kind */
639 /* BTHeaderRec -- The first record of a B-tree header node */
641 u_int16_t treeDepth
; /* maximum height (usually leaf nodes) */
642 u_int32_t rootNode
; /* node number of root node */
643 u_int32_t leafRecords
; /* number of leaf records in all leaf nodes */
644 u_int32_t firstLeafNode
; /* node number of first leaf node */
645 u_int32_t lastLeafNode
; /* node number of last leaf node */
646 u_int16_t nodeSize
; /* size of a node, in bytes */
647 u_int16_t maxKeyLength
; /* reserved */
648 u_int32_t totalNodes
; /* total number of nodes in tree */
649 u_int32_t freeNodes
; /* number of unused (free) nodes in tree */
650 u_int16_t reserved1
; /* unused */
651 u_int32_t clumpSize
; /* reserved */
652 u_int8_t btreeType
; /* reserved */
653 u_int8_t keyCompareType
; /* Key string Comparison Type */
654 u_int32_t attributes
; /* persistent attributes about the tree */
655 u_int32_t reserved3
[16]; /* reserved */
657 typedef struct BTHeaderRec BTHeaderRec
;
659 /* Constants for BTHeaderRec attributes */
661 kBTBadCloseMask
= 0x00000001, /* reserved */
662 kBTBigKeysMask
= 0x00000002, /* key length field is 16 bits */
663 kBTVariableIndexKeysMask
= 0x00000004 /* keys in index nodes are variable length */
667 /* Catalog Key Name Comparison Type */
669 kHFSCaseFolding
= 0xCF, /* case folding (case-insensitive) */
670 kHFSBinaryCompare
= 0xBC /* binary compare (case-sensitive) */
673 /* JournalInfoBlock - Structure that describes where our journal lives */
674 struct JournalInfoBlock
{
676 u_int32_t device_signature
[8]; // signature used to locate our device.
677 u_int64_t offset
; // byte offset to the journal on the device
678 u_int64_t size
; // size in bytes of the journal
679 u_int32_t reserved
[32];
681 typedef struct JournalInfoBlock JournalInfoBlock
;
684 kJIJournalInFSMask
= 0x00000001,
685 kJIJournalOnOtherDeviceMask
= 0x00000002,
686 kJIJournalNeedInitMask
= 0x00000004
690 #pragma options align=reset
696 #endif /* __HFS_FORMAT__ */