|
|
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: #ifndef __HFS_FORMAT__ ! 23: #define __HFS_FORMAT__ ! 24: ! 25: /* ! 26: * hfs_format.c ! 27: * ! 28: * This file describes the on-disk format for hfs/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 ! 36: extern "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 */ ! 43: enum { ! 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: ! 49: kHFSPlusMountVersion = 0x31302E30 /* '10.0' for Mac OS X */ ! 50: }; ! 51: ! 52: ! 53: /* ! 54: * Mac OS X special directory for linked and/or deleted files (HFS Plus only) ! 55: * ! 56: * to make this folder name sort last... ! 57: * it has 0xFFE5 Unicode prefix (0xEF, 0xBF, 0xA5 in UTF-8) ! 58: */ ! 59: #define HFSPLUSMETADATAFOLDER "\xEF\xBF\xA5\xEF\xBF\xA5\xEF\xBF\xA5 HFS Private Meta Data" ! 60: ! 61: /* ! 62: * Files in the HFS Private Meta Data folder have one of the following ! 63: * prefixes followed by the file ID in decimal (no leading zeros). ! 64: * e.g. FileNodeData3296 ! 65: */ ! 66: #define HFS_LINK_PREFIX "FileNodeData" ! 67: #define HFS_DELETE_PREFIX "DeletedFile" ! 68: ! 69: /* Unicode strings are used for HFS Plus file and folder names */ ! 70: struct HFSUniStr255 { ! 71: u_int16_t length; /* number of unicode characters */ ! 72: u_int16_t unicode[255]; /* unicode characters */ ! 73: }; ! 74: typedef struct HFSUniStr255 HFSUniStr255; ! 75: typedef const HFSUniStr255 *ConstHFSUniStr255Param; ! 76: ! 77: enum { ! 78: kHFSMaxVolumeNameChars = 27, ! 79: kHFSMaxFileNameChars = 31, ! 80: kHFSPlusMaxFileNameChars = 255 ! 81: }; ! 82: ! 83: ! 84: /* Extent overflow file data structures */ ! 85: ! 86: /* HFS Extent key */ ! 87: struct HFSExtentKey { ! 88: u_int8_t keyLength; /* length of key, excluding this field */ ! 89: u_int8_t forkType; /* 0 = data fork, FF = resource fork */ ! 90: u_int32_t fileID; /* file ID */ ! 91: u_int16_t startBlock; /* first file allocation block number in this extent */ ! 92: }; ! 93: typedef struct HFSExtentKey HFSExtentKey; ! 94: ! 95: /* HFS Plus Extent key */ ! 96: struct HFSPlusExtentKey { ! 97: u_int16_t keyLength; /* length of key, excluding this field */ ! 98: u_int8_t forkType; /* 0 = data fork, FF = resource fork */ ! 99: u_int8_t pad; /* make the other fields align on 32-bit boundary */ ! 100: u_int32_t fileID; /* file ID */ ! 101: u_int32_t startBlock; /* first file allocation block number in this extent */ ! 102: }; ! 103: typedef struct HFSPlusExtentKey HFSPlusExtentKey; ! 104: ! 105: /* Number of extent descriptors per extent record */ ! 106: enum { ! 107: kHFSExtentDensity = 3, ! 108: kHFSPlusExtentDensity = 8 ! 109: }; ! 110: ! 111: /* HFS extent descriptor */ ! 112: struct HFSExtentDescriptor { ! 113: u_int16_t startBlock; /* first allocation block */ ! 114: u_int16_t blockCount; /* number of allocation blocks */ ! 115: }; ! 116: typedef struct HFSExtentDescriptor HFSExtentDescriptor; ! 117: ! 118: /* HFS Plus extent descriptor */ ! 119: struct HFSPlusExtentDescriptor { ! 120: u_int32_t startBlock; /* first allocation block */ ! 121: u_int32_t blockCount; /* number of allocation blocks */ ! 122: }; ! 123: typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor; ! 124: ! 125: /* HFS extent record */ ! 126: typedef HFSExtentDescriptor HFSExtentRecord[3]; ! 127: ! 128: /* HFS Plus extent record */ ! 129: typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8]; ! 130: ! 131: ! 132: /* Finder information */ ! 133: struct FndrFileInfo { ! 134: u_int32_t fdType; /* file type */ ! 135: u_int32_t fdCreator; /* file creator */ ! 136: u_int16_t fdFlags; /* Finder flags */ ! 137: struct { ! 138: int16_t v; /* file's location */ ! 139: int16_t h; ! 140: } fdLocation; ! 141: int16_t opaque; ! 142: }; ! 143: typedef struct FndrFileInfo FndrFileInfo; ! 144: ! 145: struct FndrDirInfo { ! 146: struct { /* folder's window rectangle */ ! 147: int16_t top; ! 148: int16_t left; ! 149: int16_t bottom; ! 150: int16_t right; ! 151: } frRect; ! 152: unsigned short frFlags; /* Finder flags */ ! 153: struct { ! 154: u_int16_t v; /* folder's location */ ! 155: u_int16_t h; ! 156: } frLocation; ! 157: int16_t opaque; ! 158: }; ! 159: typedef struct FndrDirInfo FndrDirInfo; ! 160: ! 161: struct FndrOpaqueInfo { ! 162: int8_t opaque[16]; ! 163: }; ! 164: typedef struct FndrOpaqueInfo FndrOpaqueInfo; ! 165: ! 166: ! 167: /* HFS Plus Fork data info - 80 bytes */ ! 168: struct HFSPlusForkData { ! 169: u_int64_t logicalSize; /* fork's logical size in bytes */ ! 170: u_int32_t clumpSize; /* fork's clump size in bytes */ ! 171: u_int32_t totalBlocks; /* total blocks used by this fork */ ! 172: HFSPlusExtentRecord extents; /* initial set of extents */ ! 173: }; ! 174: typedef struct HFSPlusForkData HFSPlusForkData; ! 175: ! 176: /* HFS Plus Permissions info - 16 bytes */ ! 177: struct HFSPlusPermissions { ! 178: u_int32_t ownerID; /* user or group ID of file/folder owner */ ! 179: u_int32_t groupID; /* additional user of group ID */ ! 180: u_int32_t permissions; /* permissions (bytes: unused, owner, group, everyone) */ ! 181: u_int32_t specialDevice; /* UNIX: device for character or block special file */ ! 182: }; ! 183: typedef struct HFSPlusPermissions HFSPlusPermissions; ! 184: ! 185: ! 186: /* Catalog file data structures */ ! 187: ! 188: enum { ! 189: kHFSRootParentID = 1, /* Parent ID of the root folder */ ! 190: kHFSRootFolderID = 2, /* Folder ID of the root folder */ ! 191: kHFSExtentsFileID = 3, /* File ID of the extents file */ ! 192: kHFSCatalogFileID = 4, /* File ID of the catalog file */ ! 193: kHFSBadBlockFileID = 5, /* File ID of the bad allocation block file */ ! 194: kHFSAllocationFileID = 6, /* File ID of the allocation file (HFS Plus only) */ ! 195: kHFSStartupFileID = 7, /* File ID of the startup file (HFS Plus only) */ ! 196: kHFSAttributesFileID = 8, /* File ID of the attribute file (HFS Plus only) */ ! 197: kHFSBogusExtentFileID = 15, /* Used for exchanging extents in extents file */ ! 198: kHFSFirstUserCatalogNodeID = 16 ! 199: }; ! 200: ! 201: /* HFS catalog key */ ! 202: struct HFSCatalogKey { ! 203: u_int8_t keyLength; /* key length (in bytes) */ ! 204: u_int8_t reserved; /* reserved (set to zero) */ ! 205: u_int32_t parentID; /* parent folder ID */ ! 206: u_char nodeName[kHFSMaxFileNameChars + 1]; /* catalog node name */ ! 207: }; ! 208: typedef struct HFSCatalogKey HFSCatalogKey; ! 209: ! 210: /* HFS Plus catalog key */ ! 211: struct HFSPlusCatalogKey { ! 212: u_int16_t keyLength; /* key length (in bytes) */ ! 213: u_int32_t parentID; /* parent folder ID */ ! 214: HFSUniStr255 nodeName; /* catalog node name */ ! 215: }; ! 216: typedef struct HFSPlusCatalogKey HFSPlusCatalogKey; ! 217: ! 218: /* Catalog record types */ ! 219: enum { ! 220: /* HFS Catalog Records */ ! 221: kHFSFolderRecord = 0x0100, /* Folder record */ ! 222: kHFSFileRecord = 0x0200, /* File record */ ! 223: kHFSFolderThreadRecord = 0x0300, /* Folder thread record */ ! 224: kHFSFileThreadRecord = 0x0400, /* File thread record */ ! 225: ! 226: /* HFS Plus Catalog Records */ ! 227: kHFSPlusFolderRecord = 1, /* Folder record */ ! 228: kHFSPlusFileRecord = 2, /* File record */ ! 229: kHFSPlusFolderThreadRecord = 3, /* Folder thread record */ ! 230: kHFSPlusFileThreadRecord = 4 /* File thread record */ ! 231: }; ! 232: ! 233: ! 234: /* Catalog file record flags */ ! 235: enum { ! 236: kHFSFileLockedBit = 0x0000, /* file is locked and cannot be written to */ ! 237: kHFSFileLockedMask = 0x0001, ! 238: kHFSThreadExistsBit = 0x0001, /* a file thread record exists for this file */ ! 239: kHFSThreadExistsMask = 0x0002 ! 240: }; ! 241: ! 242: ! 243: /* HFS catalog folder record - 70 bytes */ ! 244: struct HFSCatalogFolder { ! 245: int16_t recordType; /* == kHFSFolderRecord */ ! 246: u_int16_t flags; /* folder flags */ ! 247: u_int16_t valence; /* folder valence */ ! 248: u_int32_t folderID; /* folder ID */ ! 249: u_int32_t createDate; /* date and time of creation */ ! 250: u_int32_t modifyDate; /* date and time of last modification */ ! 251: u_int32_t backupDate; /* date and time of last backup */ ! 252: FndrDirInfo userInfo; /* Finder information */ ! 253: FndrOpaqueInfo finderInfo; /* additional Finder information */ ! 254: u_int32_t reserved[4]; /* reserved - initialized as zero */ ! 255: }; ! 256: typedef struct HFSCatalogFolder HFSCatalogFolder; ! 257: ! 258: /* HFS Plus catalog folder record - 88 bytes */ ! 259: struct HFSPlusCatalogFolder { ! 260: int16_t recordType; /* == kHFSPlusFolderRecord */ ! 261: u_int16_t flags; /* file flags */ ! 262: u_int32_t valence; /* folder's valence (limited to 2^16 in Mac OS) */ ! 263: u_int32_t folderID; /* folder ID */ ! 264: u_int32_t createDate; /* date and time of creation */ ! 265: u_int32_t contentModDate; /* date and time of last content modification */ ! 266: u_int32_t attributeModDate; /* date and time of last attribute modification */ ! 267: u_int32_t accessDate; /* date and time of last access (MacOS X only) */ ! 268: u_int32_t backupDate; /* date and time of last backup */ ! 269: HFSPlusPermissions permissions; /* permissions (for MacOS X) */ ! 270: FndrDirInfo userInfo; /* Finder information */ ! 271: FndrOpaqueInfo finderInfo; /* additional Finder information */ ! 272: u_int32_t textEncoding; /* hint for name conversions */ ! 273: u_int32_t reserved; /* reserved - initialized as zero */ ! 274: }; ! 275: typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder; ! 276: ! 277: /* HFS catalog file record - 102 bytes */ ! 278: struct HFSCatalogFile { ! 279: int16_t recordType; /* == kHFSFileRecord */ ! 280: u_int8_t flags; /* file flags */ ! 281: int8_t fileType; /* file type (unused ?) */ ! 282: FndrFileInfo userInfo; /* Finder information */ ! 283: u_int32_t fileID; /* file ID */ ! 284: u_int16_t dataStartBlock; /* not used - set to zero */ ! 285: int32_t dataLogicalSize; /* logical EOF of data fork */ ! 286: int32_t dataPhysicalSize; /* physical EOF of data fork */ ! 287: u_int16_t rsrcStartBlock; /* not used - set to zero */ ! 288: int32_t rsrcLogicalSize; /* logical EOF of resource fork */ ! 289: int32_t rsrcPhysicalSize; /* physical EOF of resource fork */ ! 290: u_int32_t createDate; /* date and time of creation */ ! 291: u_int32_t modifyDate; /* date and time of last modification */ ! 292: u_int32_t backupDate; /* date and time of last backup */ ! 293: FndrOpaqueInfo finderInfo; /* additional Finder information */ ! 294: u_int16_t clumpSize; /* file clump size (not used) */ ! 295: HFSExtentRecord dataExtents; /* first data fork extent record */ ! 296: HFSExtentRecord rsrcExtents; /* first resource fork extent record */ ! 297: u_int32_t reserved; /* reserved - initialized as zero */ ! 298: }; ! 299: typedef struct HFSCatalogFile HFSCatalogFile; ! 300: ! 301: /* HFS Plus catalog file record - 248 bytes */ ! 302: struct HFSPlusCatalogFile { ! 303: int16_t recordType; /* == kHFSPlusFileRecord */ ! 304: u_int16_t flags; /* file flags */ ! 305: u_int32_t linkCount; /* used by Mac OS X */ ! 306: u_int32_t fileID; /* file ID */ ! 307: u_int32_t createDate; /* date and time of creation */ ! 308: u_int32_t contentModDate; /* date and time of last content modification */ ! 309: u_int32_t attributeModDate; /* date and time of last attribute modification */ ! 310: u_int32_t accessDate; /* date and time of last access (MacOS X only) */ ! 311: u_int32_t backupDate; /* date and time of last backup */ ! 312: HFSPlusPermissions permissions; /* permissions (for MacOS X) */ ! 313: FndrFileInfo userInfo; /* Finder information */ ! 314: FndrOpaqueInfo finderInfo; /* additional Finder information */ ! 315: u_int32_t textEncoding; /* hint for name conversions */ ! 316: u_int32_t reserved2; /* reserved - initialized as zero */ ! 317: ! 318: /* Note: these start on double long (64 bit) boundry */ ! 319: HFSPlusForkData dataFork; /* size and block data for data fork */ ! 320: HFSPlusForkData resourceFork; /* size and block data for resource fork */ ! 321: }; ! 322: typedef struct HFSPlusCatalogFile HFSPlusCatalogFile; ! 323: ! 324: /* HFS catalog thread record - 46 bytes */ ! 325: struct HFSCatalogThread { ! 326: int16_t recordType; /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */ ! 327: int32_t reserved[2]; /* reserved - initialized as zero */ ! 328: u_int32_t parentID; /* parent ID for this catalog node */ ! 329: u_char nodeName[kHFSMaxFileNameChars + 1]; /* name of this catalog node */ ! 330: }; ! 331: typedef struct HFSCatalogThread HFSCatalogThread; ! 332: ! 333: /* HFS Plus catalog thread record -- 264 bytes */ ! 334: struct HFSPlusCatalogThread { ! 335: int16_t recordType; /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */ ! 336: int16_t reserved; /* reserved - initialized as zero */ ! 337: u_int32_t parentID; /* parent ID for this catalog node */ ! 338: HFSUniStr255 nodeName; /* name of this catalog node (variable length) */ ! 339: }; ! 340: typedef struct HFSPlusCatalogThread HFSPlusCatalogThread; ! 341: ! 342: ! 343: /* ! 344: These are the types of records in the attribute B-tree. The values were ! 345: chosen so that they wouldn't conflict with the catalog record types. ! 346: */ ! 347: enum { ! 348: kHFSPlusAttrInlineData = 0x10, /* if size < kAttrOverflowSize */ ! 349: kHFSPlusAttrForkData = 0x20, /* if size >= kAttrOverflowSize */ ! 350: kHFSPlusAttrExtents = 0x30 /* overflow extents for large attributes */ ! 351: }; ! 352: ! 353: ! 354: /* ! 355: HFSPlusAttrInlineData ! 356: For small attributes, whose entire value is stored within this one ! 357: B-tree record. ! 358: There would not be any other records for this attribute. ! 359: */ ! 360: struct HFSPlusAttrInlineData { ! 361: u_int32_t recordType; /* == kHFSPlusAttrInlineData*/ ! 362: u_int32_t reserved; ! 363: u_int32_t logicalSize; /* size in bytes of userData*/ ! 364: u_int8_t userData[2]; /* variable length; space allocated is a multiple of 2 bytes*/ ! 365: }; ! 366: typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData; ! 367: ! 368: ! 369: /* ! 370: HFSPlusAttrForkData ! 371: For larger attributes, whose value is stored in allocation blocks. ! 372: If the attribute has more than 8 extents, there will be additonal ! 373: records (of type HFSPlusAttrExtents) for this attribute. ! 374: */ ! 375: struct HFSPlusAttrForkData { ! 376: u_int32_t recordType; /* == kHFSPlusAttrForkData*/ ! 377: u_int32_t reserved; ! 378: HFSPlusForkData theFork; /* size and first extents of value*/ ! 379: }; ! 380: typedef struct HFSPlusAttrForkData HFSPlusAttrForkData; ! 381: ! 382: /* ! 383: HFSPlusAttrExtents ! 384: This record contains information about overflow extents for large, ! 385: fragmented attributes. ! 386: */ ! 387: struct HFSPlusAttrExtents { ! 388: u_int32_t recordType; /* == kHFSPlusAttrExtents*/ ! 389: u_int32_t reserved; ! 390: HFSPlusExtentRecord extents; /* additional extents*/ ! 391: }; ! 392: typedef struct HFSPlusAttrExtents HFSPlusAttrExtents; ! 393: ! 394: /* A generic Attribute Record*/ ! 395: union HFSPlusAttrRecord { ! 396: u_int32_t recordType; ! 397: HFSPlusAttrInlineData inlineData; ! 398: HFSPlusAttrForkData forkData; ! 399: HFSPlusAttrExtents overflowExtents; ! 400: }; ! 401: typedef union HFSPlusAttrRecord HFSPlusAttrRecord; ! 402: ! 403: /* Key and node lengths */ ! 404: enum { ! 405: kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(u_int16_t), ! 406: kHFSExtentKeyMaximumLength = sizeof(HFSExtentKey) - sizeof(u_int8_t), ! 407: kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(u_int16_t), ! 408: kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(u_int16_t), ! 409: kHFSCatalogKeyMaximumLength = sizeof(HFSCatalogKey) - sizeof(u_int8_t), ! 410: kHFSCatalogKeyMinimumLength = kHFSCatalogKeyMaximumLength - (kHFSMaxFileNameChars + 1 + sizeof(u_int8_t)), ! 411: kHFSPlusCatalogMinNodeSize = 4096, ! 412: kHFSPlusExtentMinNodeSize = 512, ! 413: kHFSPlusAttrMinNodeSize = 4096 ! 414: }; ! 415: ! 416: ! 417: /* HFS and HFS Plus volume attribute bits */ ! 418: enum { ! 419: /* Bits 0-6 are reserved (always cleared by MountVol call) */ ! 420: kHFSVolumeHardwareLockBit = 7, /* volume is locked by hardware */ ! 421: kHFSVolumeUnmountedBit = 8, /* volume was successfully unmounted */ ! 422: kHFSVolumeSparedBlocksBit = 9, /* volume has bad blocks spared */ ! 423: kHFSVolumeNoCacheRequiredBit = 10, /* don't cache volume blocks (i.e. RAM or ROM disk) */ ! 424: kHFSBootVolumeInconsistentBit = 11, /* boot volume is inconsistent (System 7.6 and later) */ ! 425: /* Bits 12-14 are reserved for future use */ ! 426: kHFSVolumeSoftwareLockBit = 15, /* volume is locked by software */ ! 427: ! 428: kHFSVolumeHardwareLockMask = 1 << kHFSVolumeHardwareLockBit, ! 429: kHFSVolumeUnmountedMask = 1 << kHFSVolumeUnmountedBit, ! 430: kHFSVolumeSparedBlocksMask = 1 << kHFSVolumeSparedBlocksBit, ! 431: kHFSVolumeNoCacheRequiredMask = 1 << kHFSVolumeNoCacheRequiredBit, ! 432: kHFSBootVolumeInconsistentMask = 1 << kHFSBootVolumeInconsistentBit, ! 433: kHFSVolumeSoftwareLockMask = 1 << kHFSVolumeSoftwareLockBit, ! 434: kHFSMDBAttributesMask = 0x8380 ! 435: }; ! 436: ! 437: ! 438: /* HFS Master Directory Block - 162 bytes */ ! 439: /* Stored at sector #2 (3rd sector) and second-to-last sector. */ ! 440: struct HFSMasterDirectoryBlock { ! 441: u_int16_t drSigWord; /* == kHFSSigWord */ ! 442: u_int32_t drCrDate; /* date and time of volume creation */ ! 443: u_int32_t drLsMod; /* date and time of last modification */ ! 444: u_int16_t drAtrb; /* volume attributes */ ! 445: u_int16_t drNmFls; /* number of files in root folder */ ! 446: u_int16_t drVBMSt; /* first block of volume bitmap */ ! 447: u_int16_t drAllocPtr; /* start of next allocation search */ ! 448: u_int16_t drNmAlBlks; /* number of allocation blocks in volume */ ! 449: u_int32_t drAlBlkSiz; /* size (in bytes) of allocation blocks */ ! 450: u_int32_t drClpSiz; /* default clump size */ ! 451: u_int16_t drAlBlSt; /* first allocation block in volume */ ! 452: u_int32_t drNxtCNID; /* next unused catalog node ID */ ! 453: u_int16_t drFreeBks; /* number of unused allocation blocks */ ! 454: u_char drVN[kHFSMaxVolumeNameChars + 1]; /* volume name */ ! 455: u_int32_t drVolBkUp; /* date and time of last backup */ ! 456: u_int16_t drVSeqNum; /* volume backup sequence number */ ! 457: u_int32_t drWrCnt; /* volume write count */ ! 458: u_int32_t drXTClpSiz; /* clump size for extents overflow file */ ! 459: u_int32_t drCTClpSiz; /* clump size for catalog file */ ! 460: u_int16_t drNmRtDirs; /* number of directories in root folder */ ! 461: u_int32_t drFilCnt; /* number of files in volume */ ! 462: u_int32_t drDirCnt; /* number of directories in volume */ ! 463: u_int32_t drFndrInfo[8]; /* information used by the Finder */ ! 464: u_int16_t drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */ ! 465: HFSExtentDescriptor drEmbedExtent; /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */ ! 466: u_int32_t drXTFlSize; /* size of extents overflow file */ ! 467: HFSExtentRecord drXTExtRec; /* extent record for extents overflow file */ ! 468: u_int32_t drCTFlSize; /* size of catalog file */ ! 469: HFSExtentRecord drCTExtRec; /* extent record for catalog file */ ! 470: }; ! 471: typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock; ! 472: ! 473: ! 474: /* HFS Plus Volume Header - 512 bytes */ ! 475: /* Stored at sector #2 (3rd sector) and second-to-last sector. */ ! 476: struct HFSPlusVolumeHeader { ! 477: u_int16_t signature; /* == kHFSPlusSigWord */ ! 478: u_int16_t version; /* == kHFSPlusVersion */ ! 479: u_int32_t attributes; /* volume attributes */ ! 480: u_int32_t lastMountedVersion; /* implementation version which last mounted volume */ ! 481: u_int32_t reserved; /* reserved - initialized as zero */ ! 482: ! 483: u_int32_t createDate; /* date and time of volume creation */ ! 484: u_int32_t modifyDate; /* date and time of last modification */ ! 485: u_int32_t backupDate; /* date and time of last backup */ ! 486: u_int32_t checkedDate; /* date and time of last disk check */ ! 487: ! 488: u_int32_t fileCount; /* number of files in volume */ ! 489: u_int32_t folderCount; /* number of directories in volume */ ! 490: ! 491: u_int32_t blockSize; /* size (in bytes) of allocation blocks */ ! 492: u_int32_t totalBlocks; /* number of allocation blocks in volume (includes this header and VBM*/ ! 493: u_int32_t freeBlocks; /* number of unused allocation blocks */ ! 494: ! 495: u_int32_t nextAllocation; /* start of next allocation search */ ! 496: u_int32_t rsrcClumpSize; /* default resource fork clump size */ ! 497: u_int32_t dataClumpSize; /* default data fork clump size */ ! 498: u_int32_t nextCatalogID; /* next unused catalog node ID */ ! 499: ! 500: u_int32_t writeCount; /* volume write count */ ! 501: u_int64_t encodingsBitmap; /* which encodings have been use on this volume */ ! 502: ! 503: u_int8_t finderInfo[32]; /* information used by the Finder */ ! 504: ! 505: HFSPlusForkData allocationFile; /* allocation bitmap file */ ! 506: HFSPlusForkData extentsFile; /* extents B-tree file */ ! 507: HFSPlusForkData catalogFile; /* catalog B-tree file */ ! 508: HFSPlusForkData attributesFile; /* extended attributes B-tree file */ ! 509: HFSPlusForkData startupFile; /* boot file (secondary loader) */ ! 510: }; ! 511: typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader; ! 512: ! 513: ! 514: /* B-tree structures */ ! 515: ! 516: enum BTreeKeyLimits{ ! 517: kMaxKeyLength = 520 ! 518: }; ! 519: ! 520: union BTreeKey{ ! 521: u_int8_t length8; ! 522: u_int16_t length16; ! 523: u_int8_t rawData [kMaxKeyLength+2]; ! 524: }; ! 525: typedef union BTreeKey BTreeKey; ! 526: ! 527: /* BTNodeDescriptor -- Every B-tree node starts with these fields. */ ! 528: struct BTNodeDescriptor { ! 529: u_int32_t fLink; /* next node at this level*/ ! 530: u_int32_t bLink; /* previous node at this level*/ ! 531: int8_t kind; /* kind of node (leaf, index, header, map)*/ ! 532: u_int8_t height; /* zero for header, map; child is one more than parent*/ ! 533: u_int16_t numRecords; /* number of records in this node*/ ! 534: u_int16_t reserved; /* reserved - initialized as zero */ ! 535: }; ! 536: typedef struct BTNodeDescriptor BTNodeDescriptor; ! 537: ! 538: /* Constants for BTNodeDescriptor kind */ ! 539: enum { ! 540: kBTLeafNode = -1, ! 541: kBTIndexNode = 0, ! 542: kBTHeaderNode = 1, ! 543: kBTMapNode = 2 ! 544: }; ! 545: ! 546: /* BTHeaderRec -- The first record of a B-tree header node */ ! 547: struct BTHeaderRec { ! 548: u_int16_t treeDepth; /* maximum height (usually leaf nodes) */ ! 549: u_int32_t rootNode; /* node number of root node */ ! 550: u_int32_t leafRecords; /* number of leaf records in all leaf nodes */ ! 551: u_int32_t firstLeafNode; /* node number of first leaf node */ ! 552: u_int32_t lastLeafNode; /* node number of last leaf node */ ! 553: u_int16_t nodeSize; /* size of a node, in bytes */ ! 554: u_int16_t maxKeyLength; /* reserved */ ! 555: u_int32_t totalNodes; /* total number of nodes in tree */ ! 556: u_int32_t freeNodes; /* number of unused (free) nodes in tree */ ! 557: u_int16_t reserved1; /* unused */ ! 558: u_int32_t clumpSize; /* reserved */ ! 559: u_int8_t btreeType; /* reserved */ ! 560: u_int8_t reserved2; /* reserved */ ! 561: u_int32_t attributes; /* persistent attributes about the tree */ ! 562: u_int32_t reserved3[16]; /* reserved */ ! 563: }; ! 564: typedef struct BTHeaderRec BTHeaderRec; ! 565: ! 566: /* Constants for BTHeaderRec attributes */ ! 567: enum { ! 568: kBTBadCloseMask = 0x00000001, /* reserved */ ! 569: kBTBigKeysMask = 0x00000002, /* key length field is 16 bits */ ! 570: kBTVariableIndexKeysMask = 0x00000004 /* keys in index nodes are variable length */ ! 571: }; ! 572: ! 573: #pragma options align=reset ! 574: ! 575: #ifdef __cplusplus ! 576: } ! 577: #endif ! 578: ! 579: #endif /* __HFS_FORMAT__ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.