2 * Copyright (c) 2000 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__
28 * This file describes the on-disk format for HFS and HFS Plus volumes.
29 * The HFS Plus volume format is desciibed in detail in Apple Technote 1150.
31 * http://developer.apple.com/technotes/tn/tn1150.html
39 /* some on-disk hfs structures have 68K alignment (misaligned) */
40 #pragma options align=mac68k
42 /* Signatures used to differentiate between HFS and HFS Plus volumes */
44 kHFSSigWord
= 0x4244, /* 'BD' in ASCII */
45 kHFSPlusSigWord
= 0x482B, /* 'H+' in ASCII */
46 kHFSPlusVersion
= 0x0004, /* will change as format changes */
47 /* version 4 shipped with Mac OS 8.1 */
48 kHFSPlusMountVersion
= 0x31302E30 /* '10.0' for Mac OS X */
53 * Mac OS X has a special directory for linked and unlinked files (HFS Plus only).
54 * This directory and its contents are never exported from the filesystem under
57 * To make this folder name sort last, it has embedded null prefix.
58 * (0xC0, 0x80 in UTF-8)
60 #define HFSPLUSMETADATAFOLDER "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
63 * Files in the HFS Private Data folder have one of the following prefixes
64 * followed by a decimal number (no leading zeros). For indirect nodes this
65 * number is a 32 bit random number. For unlinked (deleted) files that are
66 * still open, the number is the file ID for that file.
68 * e.g. iNode7182000 and temp3296
70 #define HFS_INODE_PREFIX "iNode"
71 #define HFS_DELETE_PREFIX "temp"
74 * Indirect link files (hard links) have the following type/creator.
77 kHardLinkFileType
= 0x686C6E6B, /* 'hlnk' */
78 kHFSPlusCreator
= 0x6866732B /* 'hfs+' */
82 /* Unicode strings are used for HFS Plus file and folder names */
84 u_int16_t length
; /* number of unicode characters */
85 u_int16_t unicode
[255]; /* unicode characters */
87 typedef struct HFSUniStr255 HFSUniStr255
;
88 typedef const HFSUniStr255
*ConstHFSUniStr255Param
;
91 kHFSMaxVolumeNameChars
= 27,
92 kHFSMaxFileNameChars
= 31,
93 kHFSPlusMaxFileNameChars
= 255
97 /* Extent overflow file data structures */
100 struct HFSExtentKey
{
101 u_int8_t keyLength
; /* length of key, excluding this field */
102 u_int8_t forkType
; /* 0 = data fork, FF = resource fork */
103 u_int32_t fileID
; /* file ID */
104 u_int16_t startBlock
; /* first file allocation block number in this extent */
106 typedef struct HFSExtentKey HFSExtentKey
;
108 /* HFS Plus Extent key */
109 struct HFSPlusExtentKey
{
110 u_int16_t keyLength
; /* length of key, excluding this field */
111 u_int8_t forkType
; /* 0 = data fork, FF = resource fork */
112 u_int8_t pad
; /* make the other fields align on 32-bit boundary */
113 u_int32_t fileID
; /* file ID */
114 u_int32_t startBlock
; /* first file allocation block number in this extent */
116 typedef struct HFSPlusExtentKey HFSPlusExtentKey
;
118 /* Number of extent descriptors per extent record */
120 kHFSExtentDensity
= 3,
121 kHFSPlusExtentDensity
= 8
124 /* HFS extent descriptor */
125 struct HFSExtentDescriptor
{
126 u_int16_t startBlock
; /* first allocation block */
127 u_int16_t blockCount
; /* number of allocation blocks */
129 typedef struct HFSExtentDescriptor HFSExtentDescriptor
;
131 /* HFS Plus extent descriptor */
132 struct HFSPlusExtentDescriptor
{
133 u_int32_t startBlock
; /* first allocation block */
134 u_int32_t blockCount
; /* number of allocation blocks */
136 typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor
;
138 /* HFS extent record */
139 typedef HFSExtentDescriptor HFSExtentRecord
[3];
141 /* HFS Plus extent record */
142 typedef HFSPlusExtentDescriptor HFSPlusExtentRecord
[8];
145 /* Finder information */
146 struct FndrFileInfo
{
147 u_int32_t fdType
; /* file type */
148 u_int32_t fdCreator
; /* file creator */
149 u_int16_t fdFlags
; /* Finder flags */
151 int16_t v
; /* file's location */
156 typedef struct FndrFileInfo FndrFileInfo
;
159 struct { /* folder's window rectangle */
165 unsigned short frFlags
; /* Finder flags */
167 u_int16_t v
; /* folder's location */
172 typedef struct FndrDirInfo FndrDirInfo
;
174 struct FndrOpaqueInfo
{
177 typedef struct FndrOpaqueInfo FndrOpaqueInfo
;
180 /* HFS Plus Fork data info - 80 bytes */
181 struct HFSPlusForkData
{
182 u_int64_t logicalSize
; /* fork's logical size in bytes */
183 u_int32_t clumpSize
; /* fork's clump size in bytes */
184 u_int32_t totalBlocks
; /* total blocks used by this fork */
185 HFSPlusExtentRecord extents
; /* initial set of extents */
187 typedef struct HFSPlusForkData HFSPlusForkData
;
190 /* Mac OS X has 16 bytes worth of "BSD" info.
192 * Note: Mac OS 9 implementations and applications
193 * should preserve, but not change, this information.
195 struct HFSPlusBSDInfo
{
196 u_int32_t ownerID
; /* user or group ID of file/folder owner */
197 u_int32_t groupID
; /* additional user of group ID */
198 u_int8_t adminFlags
; /* super-user changeable flags */
199 u_int8_t ownerFlags
; /* owner changeable flags */
200 u_int16_t fileMode
; /* file type and permission bits */
202 u_int32_t iNodeNum
; /* indirect node number (hard links only) */
203 u_int32_t linkCount
; /* links that refer to this indirect node */
204 u_int32_t rawDevice
; /* special file device (FBLK and FCHR only) */
207 typedef struct HFSPlusBSDInfo HFSPlusBSDInfo
;
210 /* Catalog file data structures */
213 kHFSRootParentID
= 1, /* Parent ID of the root folder */
214 kHFSRootFolderID
= 2, /* Folder ID of the root folder */
215 kHFSExtentsFileID
= 3, /* File ID of the extents file */
216 kHFSCatalogFileID
= 4, /* File ID of the catalog file */
217 kHFSBadBlockFileID
= 5, /* File ID of the bad allocation block file */
218 kHFSAllocationFileID
= 6, /* File ID of the allocation file (HFS Plus only) */
219 kHFSStartupFileID
= 7, /* File ID of the startup file (HFS Plus only) */
220 kHFSAttributesFileID
= 8, /* File ID of the attribute file (HFS Plus only) */
221 kHFSBogusExtentFileID
= 15, /* Used for exchanging extents in extents file */
222 kHFSFirstUserCatalogNodeID
= 16
225 /* HFS catalog key */
226 struct HFSCatalogKey
{
227 u_int8_t keyLength
; /* key length (in bytes) */
228 u_int8_t reserved
; /* reserved (set to zero) */
229 u_int32_t parentID
; /* parent folder ID */
230 u_char nodeName
[kHFSMaxFileNameChars
+ 1]; /* catalog node name */
232 typedef struct HFSCatalogKey HFSCatalogKey
;
234 /* HFS Plus catalog key */
235 struct HFSPlusCatalogKey
{
236 u_int16_t keyLength
; /* key length (in bytes) */
237 u_int32_t parentID
; /* parent folder ID */
238 HFSUniStr255 nodeName
; /* catalog node name */
240 typedef struct HFSPlusCatalogKey HFSPlusCatalogKey
;
242 /* Catalog record types */
244 /* HFS Catalog Records */
245 kHFSFolderRecord
= 0x0100, /* Folder record */
246 kHFSFileRecord
= 0x0200, /* File record */
247 kHFSFolderThreadRecord
= 0x0300, /* Folder thread record */
248 kHFSFileThreadRecord
= 0x0400, /* File thread record */
250 /* HFS Plus Catalog Records */
251 kHFSPlusFolderRecord
= 1, /* Folder record */
252 kHFSPlusFileRecord
= 2, /* File record */
253 kHFSPlusFolderThreadRecord
= 3, /* Folder thread record */
254 kHFSPlusFileThreadRecord
= 4 /* File thread record */
258 /* Catalog file record flags */
260 kHFSFileLockedBit
= 0x0000, /* file is locked and cannot be written to */
261 kHFSFileLockedMask
= 0x0001,
262 kHFSThreadExistsBit
= 0x0001, /* a file thread record exists for this file */
263 kHFSThreadExistsMask
= 0x0002
267 /* HFS catalog folder record - 70 bytes */
268 struct HFSCatalogFolder
{
269 int16_t recordType
; /* == kHFSFolderRecord */
270 u_int16_t flags
; /* folder flags */
271 u_int16_t valence
; /* folder valence */
272 u_int32_t folderID
; /* folder ID */
273 u_int32_t createDate
; /* date and time of creation */
274 u_int32_t modifyDate
; /* date and time of last modification */
275 u_int32_t backupDate
; /* date and time of last backup */
276 FndrDirInfo userInfo
; /* Finder information */
277 FndrOpaqueInfo finderInfo
; /* additional Finder information */
278 u_int32_t reserved
[4]; /* reserved - initialized as zero */
280 typedef struct HFSCatalogFolder HFSCatalogFolder
;
282 /* HFS Plus catalog folder record - 88 bytes */
283 struct HFSPlusCatalogFolder
{
284 int16_t recordType
; /* == kHFSPlusFolderRecord */
285 u_int16_t flags
; /* file flags */
286 u_int32_t valence
; /* folder's valence (limited to 2^16 in Mac OS) */
287 u_int32_t folderID
; /* folder ID */
288 u_int32_t createDate
; /* date and time of creation */
289 u_int32_t contentModDate
; /* date and time of last content modification */
290 u_int32_t attributeModDate
; /* date and time of last attribute modification */
291 u_int32_t accessDate
; /* date and time of last access (MacOS X only) */
292 u_int32_t backupDate
; /* date and time of last backup */
293 HFSPlusBSDInfo bsdInfo
; /* permissions (for MacOS X) */
294 FndrDirInfo userInfo
; /* Finder information */
295 FndrOpaqueInfo finderInfo
; /* additional Finder information */
296 u_int32_t textEncoding
; /* hint for name conversions */
297 u_int32_t reserved
; /* reserved - initialized as zero */
299 typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder
;
301 /* HFS catalog file record - 102 bytes */
302 struct HFSCatalogFile
{
303 int16_t recordType
; /* == kHFSFileRecord */
304 u_int8_t flags
; /* file flags */
305 int8_t fileType
; /* file type (unused ?) */
306 FndrFileInfo userInfo
; /* Finder information */
307 u_int32_t fileID
; /* file ID */
308 u_int16_t dataStartBlock
; /* not used - set to zero */
309 int32_t dataLogicalSize
; /* logical EOF of data fork */
310 int32_t dataPhysicalSize
; /* physical EOF of data fork */
311 u_int16_t rsrcStartBlock
; /* not used - set to zero */
312 int32_t rsrcLogicalSize
; /* logical EOF of resource fork */
313 int32_t rsrcPhysicalSize
; /* physical EOF of resource fork */
314 u_int32_t createDate
; /* date and time of creation */
315 u_int32_t modifyDate
; /* date and time of last modification */
316 u_int32_t backupDate
; /* date and time of last backup */
317 FndrOpaqueInfo finderInfo
; /* additional Finder information */
318 u_int16_t clumpSize
; /* file clump size (not used) */
319 HFSExtentRecord dataExtents
; /* first data fork extent record */
320 HFSExtentRecord rsrcExtents
; /* first resource fork extent record */
321 u_int32_t reserved
; /* reserved - initialized as zero */
323 typedef struct HFSCatalogFile HFSCatalogFile
;
325 /* HFS Plus catalog file record - 248 bytes */
326 struct HFSPlusCatalogFile
{
327 int16_t recordType
; /* == kHFSPlusFileRecord */
328 u_int16_t flags
; /* file flags */
329 u_int32_t reserved1
; /* reserved - initialized as zero */
330 u_int32_t fileID
; /* file ID */
331 u_int32_t createDate
; /* date and time of creation */
332 u_int32_t contentModDate
; /* date and time of last content modification */
333 u_int32_t attributeModDate
; /* date and time of last attribute modification */
334 u_int32_t accessDate
; /* date and time of last access (MacOS X only) */
335 u_int32_t backupDate
; /* date and time of last backup */
336 HFSPlusBSDInfo bsdInfo
; /* permissions (for MacOS X) */
337 FndrFileInfo userInfo
; /* Finder information */
338 FndrOpaqueInfo finderInfo
; /* additional Finder information */
339 u_int32_t textEncoding
; /* hint for name conversions */
340 u_int32_t reserved2
; /* reserved - initialized as zero */
342 /* Note: these start on double long (64 bit) boundry */
343 HFSPlusForkData dataFork
; /* size and block data for data fork */
344 HFSPlusForkData resourceFork
; /* size and block data for resource fork */
346 typedef struct HFSPlusCatalogFile HFSPlusCatalogFile
;
348 /* HFS catalog thread record - 46 bytes */
349 struct HFSCatalogThread
{
350 int16_t recordType
; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */
351 int32_t reserved
[2]; /* reserved - initialized as zero */
352 u_int32_t parentID
; /* parent ID for this catalog node */
353 u_char nodeName
[kHFSMaxFileNameChars
+ 1]; /* name of this catalog node */
355 typedef struct HFSCatalogThread HFSCatalogThread
;
357 /* HFS Plus catalog thread record -- 264 bytes */
358 struct HFSPlusCatalogThread
{
359 int16_t recordType
; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
360 int16_t reserved
; /* reserved - initialized as zero */
361 u_int32_t parentID
; /* parent ID for this catalog node */
362 HFSUniStr255 nodeName
; /* name of this catalog node (variable length) */
364 typedef struct HFSPlusCatalogThread HFSPlusCatalogThread
;
368 These are the types of records in the attribute B-tree. The values were
369 chosen so that they wouldn't conflict with the catalog record types.
372 kHFSPlusAttrInlineData
= 0x10, /* if size < kAttrOverflowSize */
373 kHFSPlusAttrForkData
= 0x20, /* if size >= kAttrOverflowSize */
374 kHFSPlusAttrExtents
= 0x30 /* overflow extents for large attributes */
379 HFSPlusAttrInlineData
380 For small attributes, whose entire value is stored within this one
382 There would not be any other records for this attribute.
384 struct HFSPlusAttrInlineData
{
385 u_int32_t recordType
; /* == kHFSPlusAttrInlineData*/
387 u_int32_t logicalSize
; /* size in bytes of userData*/
388 u_int8_t userData
[2]; /* variable length; space allocated is a multiple of 2 bytes*/
390 typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData
;
395 For larger attributes, whose value is stored in allocation blocks.
396 If the attribute has more than 8 extents, there will be additonal
397 records (of type HFSPlusAttrExtents) for this attribute.
399 struct HFSPlusAttrForkData
{
400 u_int32_t recordType
; /* == kHFSPlusAttrForkData*/
402 HFSPlusForkData theFork
; /* size and first extents of value*/
404 typedef struct HFSPlusAttrForkData HFSPlusAttrForkData
;
408 This record contains information about overflow extents for large,
409 fragmented attributes.
411 struct HFSPlusAttrExtents
{
412 u_int32_t recordType
; /* == kHFSPlusAttrExtents*/
414 HFSPlusExtentRecord extents
; /* additional extents*/
416 typedef struct HFSPlusAttrExtents HFSPlusAttrExtents
;
418 /* A generic Attribute Record*/
419 union HFSPlusAttrRecord
{
420 u_int32_t recordType
;
421 HFSPlusAttrInlineData inlineData
;
422 HFSPlusAttrForkData forkData
;
423 HFSPlusAttrExtents overflowExtents
;
425 typedef union HFSPlusAttrRecord HFSPlusAttrRecord
;
427 /* Key and node lengths */
429 kHFSPlusExtentKeyMaximumLength
= sizeof(HFSPlusExtentKey
) - sizeof(u_int16_t
),
430 kHFSExtentKeyMaximumLength
= sizeof(HFSExtentKey
) - sizeof(u_int8_t
),
431 kHFSPlusCatalogKeyMaximumLength
= sizeof(HFSPlusCatalogKey
) - sizeof(u_int16_t
),
432 kHFSPlusCatalogKeyMinimumLength
= kHFSPlusCatalogKeyMaximumLength
- sizeof(HFSUniStr255
) + sizeof(u_int16_t
),
433 kHFSCatalogKeyMaximumLength
= sizeof(HFSCatalogKey
) - sizeof(u_int8_t
),
434 kHFSCatalogKeyMinimumLength
= kHFSCatalogKeyMaximumLength
- (kHFSMaxFileNameChars
+ 1) + sizeof(u_int8_t
),
435 kHFSPlusCatalogMinNodeSize
= 4096,
436 kHFSPlusExtentMinNodeSize
= 512,
437 kHFSPlusAttrMinNodeSize
= 4096
441 /* HFS and HFS Plus volume attribute bits */
443 /* Bits 0-6 are reserved (always cleared by MountVol call) */
444 kHFSVolumeHardwareLockBit
= 7, /* volume is locked by hardware */
445 kHFSVolumeUnmountedBit
= 8, /* volume was successfully unmounted */
446 kHFSVolumeSparedBlocksBit
= 9, /* volume has bad blocks spared */
447 kHFSVolumeNoCacheRequiredBit
= 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */
448 kHFSBootVolumeInconsistentBit
= 11, /* boot volume is inconsistent (System 7.6 and later) */
449 kHFSCatalogNodeIDsReusedBit
= 12,
450 /* Bits 13-14 are reserved for future use */
451 kHFSVolumeSoftwareLockBit
= 15, /* volume is locked by software */
453 kHFSVolumeHardwareLockMask
= 1 << kHFSVolumeHardwareLockBit
,
454 kHFSVolumeUnmountedMask
= 1 << kHFSVolumeUnmountedBit
,
455 kHFSVolumeSparedBlocksMask
= 1 << kHFSVolumeSparedBlocksBit
,
456 kHFSVolumeNoCacheRequiredMask
= 1 << kHFSVolumeNoCacheRequiredBit
,
457 kHFSBootVolumeInconsistentMask
= 1 << kHFSBootVolumeInconsistentBit
,
458 kHFSCatalogNodeIDsReusedMask
= 1 << kHFSCatalogNodeIDsReusedBit
,
459 kHFSVolumeSoftwareLockMask
= 1 << kHFSVolumeSoftwareLockBit
,
460 kHFSMDBAttributesMask
= 0x8380
464 /* HFS Master Directory Block - 162 bytes */
465 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
466 struct HFSMasterDirectoryBlock
{
467 u_int16_t drSigWord
; /* == kHFSSigWord */
468 u_int32_t drCrDate
; /* date and time of volume creation */
469 u_int32_t drLsMod
; /* date and time of last modification */
470 u_int16_t drAtrb
; /* volume attributes */
471 u_int16_t drNmFls
; /* number of files in root folder */
472 u_int16_t drVBMSt
; /* first block of volume bitmap */
473 u_int16_t drAllocPtr
; /* start of next allocation search */
474 u_int16_t drNmAlBlks
; /* number of allocation blocks in volume */
475 u_int32_t drAlBlkSiz
; /* size (in bytes) of allocation blocks */
476 u_int32_t drClpSiz
; /* default clump size */
477 u_int16_t drAlBlSt
; /* first allocation block in volume */
478 u_int32_t drNxtCNID
; /* next unused catalog node ID */
479 u_int16_t drFreeBks
; /* number of unused allocation blocks */
480 u_char drVN
[kHFSMaxVolumeNameChars
+ 1]; /* volume name */
481 u_int32_t drVolBkUp
; /* date and time of last backup */
482 u_int16_t drVSeqNum
; /* volume backup sequence number */
483 u_int32_t drWrCnt
; /* volume write count */
484 u_int32_t drXTClpSiz
; /* clump size for extents overflow file */
485 u_int32_t drCTClpSiz
; /* clump size for catalog file */
486 u_int16_t drNmRtDirs
; /* number of directories in root folder */
487 u_int32_t drFilCnt
; /* number of files in volume */
488 u_int32_t drDirCnt
; /* number of directories in volume */
489 u_int32_t drFndrInfo
[8]; /* information used by the Finder */
490 u_int16_t drEmbedSigWord
; /* embedded volume signature (formerly drVCSize) */
491 HFSExtentDescriptor drEmbedExtent
; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
492 u_int32_t drXTFlSize
; /* size of extents overflow file */
493 HFSExtentRecord drXTExtRec
; /* extent record for extents overflow file */
494 u_int32_t drCTFlSize
; /* size of catalog file */
495 HFSExtentRecord drCTExtRec
; /* extent record for catalog file */
497 typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock
;
500 /* HFS Plus Volume Header - 512 bytes */
501 /* Stored at sector #2 (3rd sector) and second-to-last sector. */
502 struct HFSPlusVolumeHeader
{
503 u_int16_t signature
; /* == kHFSPlusSigWord */
504 u_int16_t version
; /* == kHFSPlusVersion */
505 u_int32_t attributes
; /* volume attributes */
506 u_int32_t lastMountedVersion
; /* implementation version which last mounted volume */
507 u_int32_t reserved
; /* reserved - initialized as zero */
509 u_int32_t createDate
; /* date and time of volume creation */
510 u_int32_t modifyDate
; /* date and time of last modification */
511 u_int32_t backupDate
; /* date and time of last backup */
512 u_int32_t checkedDate
; /* date and time of last disk check */
514 u_int32_t fileCount
; /* number of files in volume */
515 u_int32_t folderCount
; /* number of directories in volume */
517 u_int32_t blockSize
; /* size (in bytes) of allocation blocks */
518 u_int32_t totalBlocks
; /* number of allocation blocks in volume (includes this header and VBM*/
519 u_int32_t freeBlocks
; /* number of unused allocation blocks */
521 u_int32_t nextAllocation
; /* start of next allocation search */
522 u_int32_t rsrcClumpSize
; /* default resource fork clump size */
523 u_int32_t dataClumpSize
; /* default data fork clump size */
524 u_int32_t nextCatalogID
; /* next unused catalog node ID */
526 u_int32_t writeCount
; /* volume write count */
527 u_int64_t encodingsBitmap
; /* which encodings have been use on this volume */
529 u_int8_t finderInfo
[32]; /* information used by the Finder */
531 HFSPlusForkData allocationFile
; /* allocation bitmap file */
532 HFSPlusForkData extentsFile
; /* extents B-tree file */
533 HFSPlusForkData catalogFile
; /* catalog B-tree file */
534 HFSPlusForkData attributesFile
; /* extended attributes B-tree file */
535 HFSPlusForkData startupFile
; /* boot file (secondary loader) */
537 typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader
;
540 /* B-tree structures */
549 u_int8_t rawData
[kMaxKeyLength
+2];
551 typedef union BTreeKey BTreeKey
;
553 /* BTNodeDescriptor -- Every B-tree node starts with these fields. */
554 struct BTNodeDescriptor
{
555 u_int32_t fLink
; /* next node at this level*/
556 u_int32_t bLink
; /* previous node at this level*/
557 int8_t kind
; /* kind of node (leaf, index, header, map)*/
558 u_int8_t height
; /* zero for header, map; child is one more than parent*/
559 u_int16_t numRecords
; /* number of records in this node*/
560 u_int16_t reserved
; /* reserved - initialized as zero */
562 typedef struct BTNodeDescriptor BTNodeDescriptor
;
564 /* Constants for BTNodeDescriptor kind */
572 /* BTHeaderRec -- The first record of a B-tree header node */
574 u_int16_t treeDepth
; /* maximum height (usually leaf nodes) */
575 u_int32_t rootNode
; /* node number of root node */
576 u_int32_t leafRecords
; /* number of leaf records in all leaf nodes */
577 u_int32_t firstLeafNode
; /* node number of first leaf node */
578 u_int32_t lastLeafNode
; /* node number of last leaf node */
579 u_int16_t nodeSize
; /* size of a node, in bytes */
580 u_int16_t maxKeyLength
; /* reserved */
581 u_int32_t totalNodes
; /* total number of nodes in tree */
582 u_int32_t freeNodes
; /* number of unused (free) nodes in tree */
583 u_int16_t reserved1
; /* unused */
584 u_int32_t clumpSize
; /* reserved */
585 u_int8_t btreeType
; /* reserved */
586 u_int8_t reserved2
; /* reserved */
587 u_int32_t attributes
; /* persistent attributes about the tree */
588 u_int32_t reserved3
[16]; /* reserved */
590 typedef struct BTHeaderRec BTHeaderRec
;
592 /* Constants for BTHeaderRec attributes */
594 kBTBadCloseMask
= 0x00000001, /* reserved */
595 kBTBigKeysMask
= 0x00000002, /* key length field is 16 bits */
596 kBTVariableIndexKeysMask
= 0x00000004 /* keys in index nodes are variable length */
599 #pragma options align=reset
605 #endif /* __HFS_FORMAT__ */