]> git.saurik.com Git - apple/xnu.git/blame - bsd/hfs/hfs_format.h
xnu-201.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_format.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22#ifndef __HFS_FORMAT__
23#define __HFS_FORMAT__
24
25/*
26 * hfs_format.c
27 *
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.
30 *
31 * http://developer.apple.com/technotes/tn/tn1150.html
32 *
33 */
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/* some on-disk hfs structures have 68K alignment (misaligned) */
40#pragma options align=mac68k
41
42/* Signatures used to differentiate between HFS and HFS Plus volumes */
43enum {
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 */
49};
50
51
52/*
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
55 * Mac OS X.
56 *
57 * To make this folder name sort last, it has embedded null prefix.
58 * (0xC0, 0x80 in UTF-8)
59 */
60#define HFSPLUSMETADATAFOLDER "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
61
62/*
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.
67 *
68 * e.g. iNode7182000 and temp3296
69 */
70#define HFS_INODE_PREFIX "iNode"
71#define HFS_DELETE_PREFIX "temp"
72
73/*
74 * Indirect link files (hard links) have the following type/creator.
75 */
76enum {
77 kHardLinkFileType = 0x686C6E6B, /* 'hlnk' */
78 kHFSPlusCreator = 0x6866732B /* 'hfs+' */
79};
80
81
82/* Unicode strings are used for HFS Plus file and folder names */
83struct HFSUniStr255 {
84 u_int16_t length; /* number of unicode characters */
85 u_int16_t unicode[255]; /* unicode characters */
86};
87typedef struct HFSUniStr255 HFSUniStr255;
88typedef const HFSUniStr255 *ConstHFSUniStr255Param;
89
90enum {
91 kHFSMaxVolumeNameChars = 27,
92 kHFSMaxFileNameChars = 31,
93 kHFSPlusMaxFileNameChars = 255
94};
95
96
97/* Extent overflow file data structures */
98
99/* HFS Extent key */
100struct 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 */
105};
106typedef struct HFSExtentKey HFSExtentKey;
107
108/* HFS Plus Extent key */
109struct 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 */
115};
116typedef struct HFSPlusExtentKey HFSPlusExtentKey;
117
118/* Number of extent descriptors per extent record */
119enum {
120 kHFSExtentDensity = 3,
121 kHFSPlusExtentDensity = 8
122};
123
124/* HFS extent descriptor */
125struct HFSExtentDescriptor {
126 u_int16_t startBlock; /* first allocation block */
127 u_int16_t blockCount; /* number of allocation blocks */
128};
129typedef struct HFSExtentDescriptor HFSExtentDescriptor;
130
131/* HFS Plus extent descriptor */
132struct HFSPlusExtentDescriptor {
133 u_int32_t startBlock; /* first allocation block */
134 u_int32_t blockCount; /* number of allocation blocks */
135};
136typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor;
137
138/* HFS extent record */
139typedef HFSExtentDescriptor HFSExtentRecord[3];
140
141/* HFS Plus extent record */
142typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
143
144
145/* Finder information */
146struct FndrFileInfo {
147 u_int32_t fdType; /* file type */
148 u_int32_t fdCreator; /* file creator */
149 u_int16_t fdFlags; /* Finder flags */
150 struct {
151 int16_t v; /* file's location */
152 int16_t h;
153 } fdLocation;
154 int16_t opaque;
155};
156typedef struct FndrFileInfo FndrFileInfo;
157
158struct FndrDirInfo {
159 struct { /* folder's window rectangle */
160 int16_t top;
161 int16_t left;
162 int16_t bottom;
163 int16_t right;
164 } frRect;
165 unsigned short frFlags; /* Finder flags */
166 struct {
167 u_int16_t v; /* folder's location */
168 u_int16_t h;
169 } frLocation;
170 int16_t opaque;
171};
172typedef struct FndrDirInfo FndrDirInfo;
173
174struct FndrOpaqueInfo {
175 int8_t opaque[16];
176};
177typedef struct FndrOpaqueInfo FndrOpaqueInfo;
178
179
180/* HFS Plus Fork data info - 80 bytes */
181struct 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 */
186};
187typedef struct HFSPlusForkData HFSPlusForkData;
188
189
190/* Mac OS X has 16 bytes worth of "BSD" info.
191 *
192 * Note: Mac OS 9 implementations and applications
193 * should preserve, but not change, this information.
194 */
195struct 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 */
201 union {
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) */
205 } special;
206};
207typedef struct HFSPlusBSDInfo HFSPlusBSDInfo;
208
209
210/* Catalog file data structures */
211
212enum {
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
223};
224
225/* HFS catalog key */
226struct 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 */
231};
232typedef struct HFSCatalogKey HFSCatalogKey;
233
234/* HFS Plus catalog key */
235struct HFSPlusCatalogKey {
236 u_int16_t keyLength; /* key length (in bytes) */
237 u_int32_t parentID; /* parent folder ID */
238 HFSUniStr255 nodeName; /* catalog node name */
239};
240typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
241
242/* Catalog record types */
243enum {
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 */
249
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 */
255};
256
257
258/* Catalog file record flags */
259enum {
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
264};
265
266
267/* HFS catalog folder record - 70 bytes */
268struct 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 */
279};
280typedef struct HFSCatalogFolder HFSCatalogFolder;
281
282/* HFS Plus catalog folder record - 88 bytes */
283struct 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 */
298};
299typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder;
300
301/* HFS catalog file record - 102 bytes */
302struct 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 */
322};
323typedef struct HFSCatalogFile HFSCatalogFile;
324
325/* HFS Plus catalog file record - 248 bytes */
326struct 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 */
341
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 */
345};
346typedef struct HFSPlusCatalogFile HFSPlusCatalogFile;
347
348/* HFS catalog thread record - 46 bytes */
349struct 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 */
354};
355typedef struct HFSCatalogThread HFSCatalogThread;
356
357/* HFS Plus catalog thread record -- 264 bytes */
358struct 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) */
363};
364typedef struct HFSPlusCatalogThread HFSPlusCatalogThread;
365
366
367/*
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.
370*/
371enum {
372 kHFSPlusAttrInlineData = 0x10, /* if size < kAttrOverflowSize */
373 kHFSPlusAttrForkData = 0x20, /* if size >= kAttrOverflowSize */
374 kHFSPlusAttrExtents = 0x30 /* overflow extents for large attributes */
375};
376
377
378/*
379 HFSPlusAttrInlineData
380 For small attributes, whose entire value is stored within this one
381 B-tree record.
382 There would not be any other records for this attribute.
383*/
384struct HFSPlusAttrInlineData {
385 u_int32_t recordType; /* == kHFSPlusAttrInlineData*/
386 u_int32_t reserved;
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*/
389};
390typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData;
391
392
393/*
394 HFSPlusAttrForkData
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.
398*/
399struct HFSPlusAttrForkData {
400 u_int32_t recordType; /* == kHFSPlusAttrForkData*/
401 u_int32_t reserved;
402 HFSPlusForkData theFork; /* size and first extents of value*/
403};
404typedef struct HFSPlusAttrForkData HFSPlusAttrForkData;
405
406/*
407 HFSPlusAttrExtents
408 This record contains information about overflow extents for large,
409 fragmented attributes.
410*/
411struct HFSPlusAttrExtents {
412 u_int32_t recordType; /* == kHFSPlusAttrExtents*/
413 u_int32_t reserved;
414 HFSPlusExtentRecord extents; /* additional extents*/
415};
416typedef struct HFSPlusAttrExtents HFSPlusAttrExtents;
417
418/* A generic Attribute Record*/
419union HFSPlusAttrRecord {
420 u_int32_t recordType;
421 HFSPlusAttrInlineData inlineData;
422 HFSPlusAttrForkData forkData;
423 HFSPlusAttrExtents overflowExtents;
424};
425typedef union HFSPlusAttrRecord HFSPlusAttrRecord;
426
427/* Key and node lengths */
428enum {
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
438};
439
440
441/* HFS and HFS Plus volume attribute bits */
442enum {
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 */
452
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
461};
462
463
464/* HFS Master Directory Block - 162 bytes */
465/* Stored at sector #2 (3rd sector) and second-to-last sector. */
466struct 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 */
496};
497typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock;
498
499
500/* HFS Plus Volume Header - 512 bytes */
501/* Stored at sector #2 (3rd sector) and second-to-last sector. */
502struct 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 */
508
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 */
513
514 u_int32_t fileCount; /* number of files in volume */
515 u_int32_t folderCount; /* number of directories in volume */
516
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 */
520
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 */
525
526 u_int32_t writeCount; /* volume write count */
527 u_int64_t encodingsBitmap; /* which encodings have been use on this volume */
528
529 u_int8_t finderInfo[32]; /* information used by the Finder */
530
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) */
536};
537typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader;
538
539
540/* B-tree structures */
541
542enum BTreeKeyLimits{
543 kMaxKeyLength = 520
544};
545
546union BTreeKey{
547 u_int8_t length8;
548 u_int16_t length16;
549 u_int8_t rawData [kMaxKeyLength+2];
550};
551typedef union BTreeKey BTreeKey;
552
553/* BTNodeDescriptor -- Every B-tree node starts with these fields. */
554struct 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 */
561};
562typedef struct BTNodeDescriptor BTNodeDescriptor;
563
564/* Constants for BTNodeDescriptor kind */
565enum {
566 kBTLeafNode = -1,
567 kBTIndexNode = 0,
568 kBTHeaderNode = 1,
569 kBTMapNode = 2
570};
571
572/* BTHeaderRec -- The first record of a B-tree header node */
573struct BTHeaderRec {
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 */
589};
590typedef struct BTHeaderRec BTHeaderRec;
591
592/* Constants for BTHeaderRec attributes */
593enum {
594 kBTBadCloseMask = 0x00000001, /* reserved */
595 kBTBigKeysMask = 0x00000002, /* key length field is 16 bits */
596 kBTVariableIndexKeysMask = 0x00000004 /* keys in index nodes are variable length */
597};
598
599#pragma options align=reset
600
601#ifdef __cplusplus
602}
603#endif
604
605#endif /* __HFS_FORMAT__ */