|
|
1.1 root 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: /*
23: File: HFSVolumes.h
24:
25: Contains: On-disk data structures for HFS and HFS Plus volumes.
26:
27: Version: Mac OS 8.1
28:
29: Copyright: � 1984-1999 by Apple Computer, Inc. All rights reserved.
30:
31: File Ownership:
32:
33: DRI: Mark Day
34:
35: Other Contacts: Deric Horn
36:
37: Technology: File Systems
38:
39: Writers:
40:
41: (ngk) Nick Kledzik
42: (gap) george puckett
43: (djb) Don Brady
44: (msd) Mark Day
45: (DSH) Deric Horn
46:
47: Change History (most recent first):
48:
49: From HFSVolumes.i:
50:
51: <MOSXS> 5/28/99 DJB Added on-disk B-tree structures.
52: <MOSXS> 4/9/98 djb Use a different kHFSPlusMountVersion for MacOS X.
53:
54: <2> 2/12/98 ngk Clean up: add version field in this header, change Types.i to
55: MacTypes.i, remove pragma comments, remove unnecesarry typedef
56: struct Foo Foo statements.
57: <1> 2/9/98 msd first checked in
58: <0> 2/5/98 msd Imported from HFSVolumesPriv.i. Added "HFS" to many names.
59: Added reserved field to HFSPlusAttrInlineData.
60:
61: From HFSVolumesPriv.i:
62:
63: <CS19> 11/16/97 djb Bump volume format version for Unicode changes.
64: <CS18> 10/23/97 msd Bug 1685113. Change kHFSPlusMountVersion to '8.10' to trigger
65: MountCheck; it also happens to be a more correct value.
66: <CS17> 10/19/97 msd Bug 1684586. Rename modifyDate to attributeModDate. GetCatInfo
67: and SetCatInfo use only contentModDate.
68: <CS16> 9/19/97 msd Fix bug 1679778. In the LargeCatalogFile structure, change the
69: name of the linkCount field to "reserved1" since we no longer
70: support hard links.
71: <CS15> 9/10/97 msd Make sure fork and extent information is 8-byte aligned in
72: attribute records.
73: <CS14> 9/4/97 msd Attributes are now identified by a single Unicode string (flags
74: and OSTypes are gone), and may have extents (allowing them to be
75: very large). Removed C define of bitmapFile. Removed
76: kVolumeHardLinksBit. Added field lastMountedVersion to
77: VolumeHeader; moved unused space near start of structure to make
78: following fields nicely aligned. LargeExtentKey's keyLength is
79: now a UInt16, like all the rest of the HFS Plus B-Trees. Change
80: kHFSPlusVersion to $0003.
81: <CS13> 9/2/97 DSH Moved the VolumeHeader to sector 2 of HFS+ partition, bumped
82: kHFSPlusVersion to 0X0002.
83: <CS12> 8/5/97 msd Change kHFSPlusSigWord to $482B ('H+'). Add enum for
84: kHFSPlusVersion (set to $0001).
85: <CS11> 6/24/97 djb Add link count to HFS Plus file record. Add kVolumeHardLinksBit.
86: <CS10> 6/20/97 msd Remove the define for contentModDate.
87: <CS9> 6/12/97 djb Removed rootFileCount and rootFolderCount. Added new dates,
88: permissions, and encodingBitmap, changed signature to "D8".
89: <CS8> 6/6/97 djb Removed enum names and #pragma enumsalwaysint.
90: <CS7> 6/4/97 gap Removed ForBride conditional. Caused problem in
91: HFSVolumesPriv.a.
92: <CS6> 6/4/97 gap Add #pragma enumsalwaysint so file will work with latest
93: Interfacer tool in Bride build.
94: <CS5> 5/30/97 djb Add constants for minimum key lengths.
95: <CS4> 5/28/97 msd Add AttributeKey and associated enums.
96: <CS3> 5/20/97 DSH Keep sigWord in sync with last build, D5.
97: <CS2> 5/15/97 msd Key length and fork type for extent records should be unsigned.
98: <CS1> 4/28/97 djb first checked in
99:
100: <HFS7> 4/7/97 msd Add FileID for attributes BTree.
101: <HFS6> 4/4/97 djb Major update to HFS Plus structures.
102: <HFS5> 3/17/97 DSH Adding kNumHFSPlusExtents, and kNumHFSExtents.
103: <HFS4> 2/19/97 djb Latest HFS Plus format changes. Removed B-Tree Manager data
104: structures since they're defined in BTreesPrivate.h.
105: <HFS3> 2/13/97 msd Add unions for extent key and data.
106: <HFS2> 1/16/97 djb Changed kLargeExtentKeyMaximumLength to 11.
107: <HFS1> 1/9/97 djb first checked in
108: <0> 1/7/97 djb Converted from HFSVolumePriv.h file.
109: */
110: #ifndef __HFSVOLUMES__
111: #define __HFSVOLUMES__
112:
113: #ifndef __MACOSTYPES__
114: #include "system/MacOSTypes.h"
115: #endif
116:
117: #ifndef __MACOSSTUBS__
118: #include "system/MacOSStubs.h"
119: #endif
120:
121: #if PRAGMA_ONCE
122: #pragma once
123: #endif
124:
125: #ifdef __cplusplus
126: extern "C" {
127: #endif
128:
129: #if PRAGMA_IMPORT
130: #pragma import on
131: #endif
132:
133: #if PRAGMA_STRUCT_ALIGN
134: #pragma options align=mac68k
135: #elif PRAGMA_STRUCT_PACKPUSH
136: #pragma pack(push, 2)
137: #elif PRAGMA_STRUCT_PACK
138: #pragma pack(2)
139: #endif
140:
141: /* Signatures used to differentiate between HFS and HFS Plus volumes */
142:
143: enum {
144: kHFSSigWord = 0x4244, /* 'BD' in ASCII */
145: kHFSPlusSigWord = 0x482B, /* 'H+' in ASCII */
146: kHFSPlusVersion = 0x0004, /* will change as format changes (version 4 shipped with Mac OS 8.1) */
147:
148: #if TARGET_API_MACOS_X
149: kHFSPlusMountVersion = FOUR_CHAR_CODE('8.10') /* will change as implementations change ('8.10' in Mac OS 8.1) */
150: #else
151: kHFSPlusMountVersion = FOUR_CHAR_CODE('9.00') /* will change as implementations change */
152: #endif
153:
154:
155: };
156:
157:
158: /* CatalogNodeID is used to track catalog objects */
159: typedef UInt32 HFSCatalogNodeID;
160: /* Unicode strings are used for file and folder names (HFS Plus only) */
161:
162: struct HFSUniStr255 {
163: UInt16 length; /* number of unicode characters */
164: UniChar unicode[255]; /* unicode characters */
165: };
166: typedef struct HFSUniStr255 HFSUniStr255;
167:
168: typedef const HFSUniStr255 * ConstHFSUniStr255Param;
169:
170: enum {
171: kHFSMaxVolumeNameChars = 27,
172: kHFSMaxFileNameChars = 31,
173: kHFSPlusMaxFileNameChars = 255
174: };
175:
176:
177: /* Extent overflow file data structures */
178: /* HFS Extent key */
179:
180: struct HFSExtentKey {
181: UInt8 keyLength; /* length of key, excluding this field */
182: UInt8 forkType; /* 0 = data fork, FF = resource fork */
183: HFSCatalogNodeID fileID; /* file ID */
184: UInt16 startBlock; /* first file allocation block number in this extent */
185: };
186: typedef struct HFSExtentKey HFSExtentKey;
187: /* HFS Plus Extent key */
188:
189: struct HFSPlusExtentKey {
190: UInt16 keyLength; /* length of key, excluding this field */
191: UInt8 forkType; /* 0 = data fork, FF = resource fork */
192: UInt8 pad; /* make the other fields align on 32-bit boundary */
193: HFSCatalogNodeID fileID; /* file ID */
194: UInt32 startBlock; /* first file allocation block number in this extent */
195: };
196: typedef struct HFSPlusExtentKey HFSPlusExtentKey;
197: /* Number of extent descriptors per extent record */
198:
199: enum {
200: kHFSExtentDensity = 3,
201: kHFSPlusExtentDensity = 8
202: };
203:
204: /* HFS extent descriptor */
205:
206: struct HFSExtentDescriptor {
207: UInt16 startBlock; /* first allocation block */
208: UInt16 blockCount; /* number of allocation blocks */
209: };
210: typedef struct HFSExtentDescriptor HFSExtentDescriptor;
211: /* HFS Plus extent descriptor */
212:
213: struct HFSPlusExtentDescriptor {
214: UInt32 startBlock; /* first allocation block */
215: UInt32 blockCount; /* number of allocation blocks */
216: };
217: typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor;
218: /* HFS extent record */
219:
220: typedef HFSExtentDescriptor HFSExtentRecord[3];
221: /* HFS Plus extent record */
222: typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
223:
224: /* Fork data info (HFS Plus only) - 80 bytes */
225:
226: struct HFSPlusForkData {
227: UInt64 logicalSize; /* fork's logical size in bytes */
228: UInt32 clumpSize; /* fork's clump size in bytes */
229: UInt32 totalBlocks; /* total blocks used by this fork */
230: HFSPlusExtentRecord extents; /* initial set of extents */
231: };
232: typedef struct HFSPlusForkData HFSPlusForkData;
233: /* Permissions info (HFS Plus only) - 16 bytes */
234:
235: struct HFSPlusPermissions {
236: UInt32 ownerID; /* user or group ID of file/folder owner */
237: UInt32 groupID; /* additional user of group ID */
238: UInt32 permissions; /* permissions (bytes: unused, owner, group, everyone) */
239: UInt32 specialDevice; /* UNIX: device for character or block special file */
240: };
241: typedef struct HFSPlusPermissions HFSPlusPermissions;
242: /* Catalog file data structures */
243:
244: enum {
245: kHFSRootParentID = 1, /* Parent ID of the root folder */
246: kHFSRootFolderID = 2, /* Folder ID of the root folder */
247: kHFSExtentsFileID = 3, /* File ID of the extents file */
248: kHFSCatalogFileID = 4, /* File ID of the catalog file */
249: kHFSBadBlockFileID = 5, /* File ID of the bad allocation block file */
250: kHFSAllocationFileID = 6, /* File ID of the allocation file (HFS Plus only) */
251: kHFSStartupFileID = 7, /* File ID of the startup file (HFS Plus only) */
252: kHFSAttributesFileID = 8, /* File ID of the attribute file (HFS Plus only) */
253: kHFSBogusExtentFileID = 15, /* Used for exchanging extents in extents file */
254: kHFSFirstUserCatalogNodeID = 16
255: };
256:
257:
258: /* HFS catalog key */
259:
260: struct HFSCatalogKey {
261: UInt8 keyLength; /* key length (in bytes) */
262: UInt8 reserved; /* reserved (set to zero) */
263: HFSCatalogNodeID parentID; /* parent folder ID */
264: Str31 nodeName; /* catalog node name */
265: };
266: typedef struct HFSCatalogKey HFSCatalogKey;
267: /* HFS Plus catalog key */
268:
269: struct HFSPlusCatalogKey {
270: UInt16 keyLength; /* key length (in bytes) */
271: HFSCatalogNodeID parentID; /* parent folder ID */
272: HFSUniStr255 nodeName; /* catalog node name */
273: };
274: typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
275:
276: /* Catalog record types */
277:
278: enum {
279: /* HFS Catalog Records */
280: kHFSFolderRecord = 0x0100, /* Folder record */
281: kHFSFileRecord = 0x0200, /* File record */
282: kHFSFolderThreadRecord = 0x0300, /* Folder thread record */
283: kHFSFileThreadRecord = 0x0400, /* File thread record */
284: /* HFS Plus Catalog Records */
285: kHFSPlusFolderRecord = 1, /* Folder record */
286: kHFSPlusFileRecord = 2, /* File record */
287: kHFSPlusFolderThreadRecord = 3, /* Folder thread record */
288: kHFSPlusFileThreadRecord = 4 /* File thread record */
289: };
290:
291:
292: /* Catalog file record flags */
293:
294: enum {
295: kHFSFileLockedBit = 0x0000, /* file is locked and cannot be written to */
296: kHFSFileLockedMask = 0x0001,
297: kHFSThreadExistsBit = 0x0001, /* a file thread record exists for this file */
298: kHFSThreadExistsMask = 0x0002
299: };
300:
301:
302: /* HFS catalog folder record - 70 bytes */
303:
304: struct HFSCatalogFolder {
305: SInt16 recordType; /* record type */
306: UInt16 flags; /* folder flags */
307: UInt16 valence; /* folder valence */
308: HFSCatalogNodeID folderID; /* folder ID */
309: UInt32 createDate; /* date and time of creation */
310: UInt32 modifyDate; /* date and time of last modification */
311: UInt32 backupDate; /* date and time of last backup */
312: DInfo userInfo; /* Finder information */
313: DXInfo finderInfo; /* additional Finder information */
314: UInt32 reserved[4]; /* reserved - set to zero */
315: };
316: typedef struct HFSCatalogFolder HFSCatalogFolder;
317: /* HFS Plus catalog folder record - 88 bytes */
318:
319: struct HFSPlusCatalogFolder {
320: SInt16 recordType; /* record type = HFS Plus folder record */
321: UInt16 flags; /* file flags */
322: UInt32 valence; /* folder's valence (limited to 2^16 in Mac OS) */
323: HFSCatalogNodeID folderID; /* folder ID */
324: UInt32 createDate; /* date and time of creation */
325: UInt32 contentModDate; /* date and time of last content modification */
326: UInt32 attributeModDate; /* date and time of last attribute modification */
327: UInt32 accessDate; /* date and time of last access (MacOS X only) */
328: UInt32 backupDate; /* date and time of last backup */
329: HFSPlusPermissions permissions; /* permissions (for MacOS X) */
330: DInfo userInfo; /* Finder information */
331: DXInfo finderInfo; /* additional Finder information */
332: UInt32 textEncoding; /* hint for name conversions */
333: UInt32 reserved; /* reserved - set to zero */
334: };
335: typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder;
336: /* HFS catalog file record - 102 bytes */
337:
338: struct HFSCatalogFile {
339: SInt16 recordType; /* record type */
340: UInt8 flags; /* file flags */
341: SInt8 fileType; /* file type (unused ?) */
342: FInfo userInfo; /* Finder information */
343: HFSCatalogNodeID fileID; /* file ID */
344: UInt16 dataStartBlock; /* not used - set to zero */
345: SInt32 dataLogicalSize; /* logical EOF of data fork */
346: SInt32 dataPhysicalSize; /* physical EOF of data fork */
347: UInt16 rsrcStartBlock; /* not used - set to zero */
348: SInt32 rsrcLogicalSize; /* logical EOF of resource fork */
349: SInt32 rsrcPhysicalSize; /* physical EOF of resource fork */
350: UInt32 createDate; /* date and time of creation */
351: UInt32 modifyDate; /* date and time of last modification */
352: UInt32 backupDate; /* date and time of last backup */
353: FXInfo finderInfo; /* additional Finder information */
354: UInt16 clumpSize; /* file clump size (not used) */
355: HFSExtentRecord dataExtents; /* first data fork extent record */
356: HFSExtentRecord rsrcExtents; /* first resource fork extent record */
357: UInt32 reserved; /* reserved - set to zero */
358: };
359: typedef struct HFSCatalogFile HFSCatalogFile;
360: /* HFS Plus catalog file record - 248 bytes */
361:
362: struct HFSPlusCatalogFile {
363: SInt16 recordType; /* record type = HFS Plus file record */
364: UInt16 flags; /* file flags */
365: UInt32 linkCount; /* reserved - set to zero */
366: HFSCatalogNodeID fileID; /* file ID */
367: UInt32 createDate; /* date and time of creation */
368: UInt32 contentModDate; /* date and time of last content modification */
369: UInt32 attributeModDate; /* date and time of last attribute modification */
370: UInt32 accessDate; /* date and time of last access (MacOS X only) */
371: UInt32 backupDate; /* date and time of last backup */
372: HFSPlusPermissions permissions; /* permissions (for MacOS X) */
373: FInfo userInfo; /* Finder information */
374: FXInfo finderInfo; /* additional Finder information */
375: UInt32 textEncoding; /* hint for name conversions */
376: UInt32 reserved2; /* reserved - set to zero */
377:
378: /* start on double long (64 bit) boundry */
379: HFSPlusForkData dataFork; /* size and block data for data fork */
380: HFSPlusForkData resourceFork; /* size and block data for resource fork */
381: };
382: typedef struct HFSPlusCatalogFile HFSPlusCatalogFile;
383: /* HFS catalog thread record - 46 bytes */
384:
385: struct HFSCatalogThread {
386: SInt16 recordType; /* record type */
387: SInt32 reserved[2]; /* reserved - set to zero */
388: HFSCatalogNodeID parentID; /* parent ID for this catalog node */
389: Str31 nodeName; /* name of this catalog node */
390: };
391: typedef struct HFSCatalogThread HFSCatalogThread;
392: /* HFS Plus catalog thread record -- 264 bytes */
393:
394: struct HFSPlusCatalogThread {
395: SInt16 recordType; /* record type */
396: SInt16 reserved; /* reserved - set to zero */
397: HFSCatalogNodeID parentID; /* parent ID for this catalog node */
398: HFSUniStr255 nodeName; /* name of this catalog node (variable length) */
399: };
400: typedef struct HFSPlusCatalogThread HFSPlusCatalogThread;
401:
402: /*
403: These are the types of records in the attribute B-tree. The values were chosen
404: so that they wouldn't conflict with the catalog record types.
405: */
406:
407: enum {
408: kHFSPlusAttrInlineData = 0x10, /* if size < kAttrOverflowSize */
409: kHFSPlusAttrForkData = 0x20, /* if size >= kAttrOverflowSize */
410: kHFSPlusAttrExtents = 0x30 /* overflow extents for large attributes */
411: };
412:
413:
414: /*
415: HFSPlusAttrInlineData
416: For small attributes, whose entire value is stored within this one
417: B-tree record.
418: There would not be any other records for this attribute.
419: */
420:
421: struct HFSPlusAttrInlineData {
422: UInt32 recordType; /* = kHFSPlusAttrInlineData*/
423: UInt32 reserved;
424: UInt32 logicalSize; /* size in bytes of userData*/
425: UInt8 userData[2]; /* variable length; space allocated is a multiple of 2 bytes*/
426: };
427: typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData;
428: /*
429: HFSPlusAttrForkData
430: For larger attributes, whose value is stored in allocation blocks.
431: If the attribute has more than 8 extents, there will be additonal
432: records (of type HFSPlusAttrExtents) for this attribute.
433: */
434:
435: struct HFSPlusAttrForkData {
436: UInt32 recordType; /* = kHFSPlusAttrForkData*/
437: UInt32 reserved;
438: HFSPlusForkData theFork; /* size and first extents of value*/
439: };
440: typedef struct HFSPlusAttrForkData HFSPlusAttrForkData;
441: /*
442: HFSPlusAttrExtents
443: This record contains information about overflow extents for large,
444: fragmented attributes.
445: */
446:
447: struct HFSPlusAttrExtents {
448: UInt32 recordType; /* = kHFSPlusAttrExtents*/
449: UInt32 reserved;
450: HFSPlusExtentRecord extents; /* additional extents*/
451: };
452: typedef struct HFSPlusAttrExtents HFSPlusAttrExtents;
453: /* A generic Attribute Record*/
454:
455: union HFSPlusAttrRecord {
456: UInt32 recordType;
457: HFSPlusAttrInlineData inlineData;
458: HFSPlusAttrForkData forkData;
459: HFSPlusAttrExtents overflowExtents;
460: };
461: typedef union HFSPlusAttrRecord HFSPlusAttrRecord;
462: /* Key and node lengths */
463:
464: enum {
465: kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(UInt16),
466: kHFSExtentKeyMaximumLength = sizeof(HFSExtentKey) - sizeof(UInt8),
467: kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(UInt16),
468: kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(UInt16),
469: kHFSCatalogKeyMaximumLength = sizeof(HFSCatalogKey) - sizeof(UInt8),
470: kHFSCatalogKeyMinimumLength = kHFSCatalogKeyMaximumLength - sizeof(Str31) + sizeof(UInt8),
471: kHFSPlusCatalogMinNodeSize = 4096,
472: kHFSPlusExtentMinNodeSize = 512,
473: kHFSPlusAttrMinNodeSize = 4096
474: };
475:
476:
477: /* HFS and HFS Plus volume attribute bits */
478:
479: enum {
480: /* Bits 0-6 are reserved (always cleared by MountVol call) */
481: kHFSVolumeHardwareLockBit = 7, /* volume is locked by hardware */
482: kHFSVolumeUnmountedBit = 8, /* volume was successfully unmounted */
483: kHFSVolumeSparedBlocksBit = 9, /* volume has bad blocks spared */
484: kHFSVolumeNoCacheRequiredBit = 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */
485: kHFSBootVolumeInconsistentBit = 11, /* boot volume is inconsistent (System 7.6 and later) */
486: /* Bits 12-14 are reserved for future use */
487: kHFSVolumeSoftwareLockBit = 15, /* volume is locked by software */
488: kHFSVolumeHardwareLockMask = 1 << kHFSVolumeHardwareLockBit,
489: kHFSVolumeUnmountedMask = 1 << kHFSVolumeUnmountedBit,
490: kHFSVolumeSparedBlocksMask = 1 << kHFSVolumeSparedBlocksBit,
491: kHFSVolumeNoCacheRequiredMask = 1 << kHFSVolumeNoCacheRequiredBit,
492: kHFSBootVolumeInconsistentMask = 1 << kHFSBootVolumeInconsistentBit,
493: kHFSVolumeSoftwareLockMask = 1 << kHFSVolumeSoftwareLockBit,
494: kHFSMDBAttributesMask = 0x8380
495: };
496:
497:
498: /* Master Directory Block (HFS only) - 162 bytes */
499: /* Stored at sector #2 (3rd sector) */
500:
501: struct HFSMasterDirectoryBlock {
502:
503: /* These first fields are also used by MFS */
504:
505: UInt16 drSigWord; /* volume signature */
506: UInt32 drCrDate; /* date and time of volume creation */
507: UInt32 drLsMod; /* date and time of last modification */
508: UInt16 drAtrb; /* volume attributes */
509: UInt16 drNmFls; /* number of files in root folder */
510: UInt16 drVBMSt; /* first block of volume bitmap */
511: UInt16 drAllocPtr; /* start of next allocation search */
512: UInt16 drNmAlBlks; /* number of allocation blocks in volume */
513: UInt32 drAlBlkSiz; /* size (in bytes) of allocation blocks */
514: UInt32 drClpSiz; /* default clump size */
515: UInt16 drAlBlSt; /* first allocation block in volume */
516: UInt32 drNxtCNID; /* next unused catalog node ID */
517: UInt16 drFreeBks; /* number of unused allocation blocks */
518: Str27 drVN; /* volume name */
519:
520: /* Master Directory Block extensions for HFS */
521:
522: UInt32 drVolBkUp; /* date and time of last backup */
523: UInt16 drVSeqNum; /* volume backup sequence number */
524: UInt32 drWrCnt; /* volume write count */
525: UInt32 drXTClpSiz; /* clump size for extents overflow file */
526: UInt32 drCTClpSiz; /* clump size for catalog file */
527: UInt16 drNmRtDirs; /* number of directories in root folder */
528: UInt32 drFilCnt; /* number of files in volume */
529: UInt32 drDirCnt; /* number of directories in volume */
530: UInt32 drFndrInfo[8]; /* information used by the Finder */
531: UInt16 drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */
532: HFSExtentDescriptor drEmbedExtent; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
533: UInt32 drXTFlSize; /* size of extents overflow file */
534: HFSExtentRecord drXTExtRec; /* extent record for extents overflow file */
535: UInt32 drCTFlSize; /* size of catalog file */
536: HFSExtentRecord drCTExtRec; /* extent record for catalog file */
537: };
538: typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock;
539:
540: /* HFSPlusVolumeHeader (HFS Plus only) - 512 bytes */
541: /* Stored at sector #2 (3rd sector) and second-to-last sector. */
542:
543: struct HFSPlusVolumeHeader {
544: UInt16 signature; /* volume signature == 'H+' */
545: UInt16 version; /* current version is kHFSPlusVersion */
546: UInt32 attributes; /* volume attributes */
547: UInt32 lastMountedVersion; /* implementation version which last mounted volume */
548: UInt32 reserved; /* reserved - set to zero */
549:
550: UInt32 createDate; /* date and time of volume creation */
551: UInt32 modifyDate; /* date and time of last modification */
552: UInt32 backupDate; /* date and time of last backup */
553: UInt32 checkedDate; /* date and time of last disk check */
554:
555: UInt32 fileCount; /* number of files in volume */
556: UInt32 folderCount; /* number of directories in volume */
557:
558: UInt32 blockSize; /* size (in bytes) of allocation blocks */
559: UInt32 totalBlocks; /* number of allocation blocks in volume (includes this header and VBM*/
560: UInt32 freeBlocks; /* number of unused allocation blocks */
561:
562: UInt32 nextAllocation; /* start of next allocation search */
563: UInt32 rsrcClumpSize; /* default resource fork clump size */
564: UInt32 dataClumpSize; /* default data fork clump size */
565: HFSCatalogNodeID nextCatalogID; /* next unused catalog node ID */
566:
567: UInt32 writeCount; /* volume write count */
568: UInt64 encodingsBitmap; /* which encodings have been use on this volume */
569:
570: UInt8 finderInfo[32]; /* information used by the Finder */
571:
572: HFSPlusForkData allocationFile; /* allocation bitmap file */
573: HFSPlusForkData extentsFile; /* extents B-tree file */
574: HFSPlusForkData catalogFile; /* catalog B-tree file */
575: HFSPlusForkData attributesFile; /* extended attributes B-tree file */
576: HFSPlusForkData startupFile; /* boot file */
577: };
578: typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader;
579:
580:
581: /* ---------- HFS and HFS Plus B-tree structures ---------- */
582: /* BTNodeDescriptor -- Every B-tree node starts with these fields. */
583:
584: struct BTNodeDescriptor {
585: UInt32 fLink; /* next node at this level*/
586: UInt32 bLink; /* previous node at this level*/
587: SInt8 kind; /* kind of node (leaf, index, header, map)*/
588: UInt8 height; /* zero for header, map; child is one more than parent*/
589: UInt16 numRecords; /* number of records in this node*/
590: UInt16 reserved; /* reserved; set to zero*/
591: };
592: typedef struct BTNodeDescriptor BTNodeDescriptor;
593: /* Constants for BTNodeDescriptor kind */
594: enum {
595: kBTLeafNode = -1,
596: kBTIndexNode = 0,
597: kBTHeaderNode = 1,
598: kBTMapNode = 2
599: };
600:
601: /* BTHeaderRec -- The first record of a B-tree header node */
602:
603: struct BTHeaderRec {
604: UInt16 treeDepth; /* maximum height (usually leaf nodes) */
605: UInt32 rootNode; /* node number of root node */
606: UInt32 leafRecords; /* number of leaf records in all leaf nodes */
607: UInt32 firstLeafNode; /* node number of first leaf node */
608: UInt32 lastLeafNode; /* node number of last leaf node */
609: UInt16 nodeSize; /* size of a node, in bytes */
610: UInt16 maxKeyLength; /* reserved */
611: UInt32 totalNodes; /* total number of nodes in tree */
612: UInt32 freeNodes; /* number of unused (free) nodes in tree */
613: UInt16 reserved1; /* unused */
614: UInt32 clumpSize; /* reserved */
615: UInt8 btreeType; /* reserved */
616: UInt8 reserved2; /* reserved */
617: UInt32 attributes; /* persistent attributes about the tree */
618: UInt32 reserved3[16]; /* reserved */
619: };
620: typedef struct BTHeaderRec BTHeaderRec;
621: /* Constants for BTHeaderRec attributes */
622: enum {
623: kBTBadCloseMask = 0x00000001, /* reserved */
624: kBTBigKeysMask = 0x00000002, /* key length field is 16 bits */
625: kBTVariableIndexKeysMask = 0x00000004 /* keys in index nodes are variable length */
626: };
627:
628:
629: #if PRAGMA_STRUCT_ALIGN
630: #pragma options align=reset
631: #elif PRAGMA_STRUCT_PACKPUSH
632: #pragma pack(pop)
633: #elif PRAGMA_STRUCT_PACK
634: #pragma pack()
635: #endif
636:
637: #ifdef PRAGMA_IMPORT_OFF
638: #pragma import off
639: #elif PRAGMA_IMPORT
640: #pragma import reset
641: #endif
642:
643: #ifdef __cplusplus
644: }
645: #endif
646:
647: #endif /* __HFSVOLUMES__ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.