HFSVolumes.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. {
  2. File: HFSVolumes.p
  3. Contains: On-disk data structures for HFS and HFS Plus volumes.
  4. Version: Technology: Mac OS 8.1
  5. Release: Universal Interfaces 3.4.2
  6. Copyright: © 1984-2002 by Apple Computer, Inc. All rights reserved.
  7. Bugs?: For bug reports, consult the following page on
  8. the World Wide Web:
  9. http://www.freepascal.org/bugs.html
  10. }
  11. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit HFSVolumes;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes,Files,Finder;
  92. {$ALIGN MAC68K}
  93. { Signatures used to differentiate between HFS and HFS Plus volumes }
  94. const
  95. kHFSSigWord = $4244; { 'BD' in ASCII }
  96. kHFSPlusSigWord = $482B; { 'H+' in ASCII }
  97. kHFSPlusVersion = $0004; { will change as format changes (version 4 shipped with Mac OS 8.1) }
  98. kHFSPlusMountVersion = $382E3130 (* '8.10' *); { will change as implementations change ('8.10' in Mac OS 8.1) }
  99. { CatalogNodeID is used to track catalog objects }
  100. type
  101. HFSCatalogNodeID = UInt32;
  102. const
  103. kHFSMaxVolumeNameChars = 27;
  104. kHFSMaxFileNameChars = 31;
  105. kHFSPlusMaxFileNameChars = 255;
  106. { Extent overflow file data structures }
  107. { HFS Extent key }
  108. type
  109. HFSExtentKeyPtr = ^HFSExtentKey;
  110. HFSExtentKey = record
  111. keyLength: SInt8; { length of key, excluding this field }
  112. forkType: SInt8; { 0 = data fork, FF = resource fork }
  113. fileID: HFSCatalogNodeID; { file ID }
  114. startBlock: UInt16; { first file allocation block number in this extent }
  115. end;
  116. { HFS Plus Extent key }
  117. HFSPlusExtentKeyPtr = ^HFSPlusExtentKey;
  118. HFSPlusExtentKey = record
  119. keyLength: UInt16; { length of key, excluding this field }
  120. forkType: SInt8; { 0 = data fork, FF = resource fork }
  121. pad: SInt8; { make the other fields align on 32-bit boundary }
  122. fileID: HFSCatalogNodeID; { file ID }
  123. startBlock: UInt32; { first file allocation block number in this extent }
  124. end;
  125. { Number of extent descriptors per extent record }
  126. const
  127. kHFSExtentDensity = 3;
  128. kHFSPlusExtentDensity = 8;
  129. { HFS extent descriptor }
  130. type
  131. HFSExtentDescriptorPtr = ^HFSExtentDescriptor;
  132. HFSExtentDescriptor = record
  133. startBlock: UInt16; { first allocation block }
  134. blockCount: UInt16; { number of allocation blocks }
  135. end;
  136. { HFS Plus extent descriptor }
  137. HFSPlusExtentDescriptorPtr = ^HFSPlusExtentDescriptor;
  138. HFSPlusExtentDescriptor = record
  139. startBlock: UInt32; { first allocation block }
  140. blockCount: UInt32; { number of allocation blocks }
  141. end;
  142. { HFS extent record }
  143. HFSExtentRecord = array [0..2] of HFSExtentDescriptor;
  144. { HFS Plus extent record }
  145. HFSPlusExtentRecord = array [0..7] of HFSPlusExtentDescriptor;
  146. { Fork data info (HFS Plus only) - 80 bytes }
  147. HFSPlusForkDataPtr = ^HFSPlusForkData;
  148. HFSPlusForkData = record
  149. logicalSize: UInt64; { fork's logical size in bytes }
  150. clumpSize: UInt32; { fork's clump size in bytes }
  151. totalBlocks: UInt32; { total blocks used by this fork }
  152. extents: HFSPlusExtentRecord; { initial set of extents }
  153. end;
  154. { Permissions info (HFS Plus only) - 16 bytes }
  155. HFSPlusPermissionsPtr = ^HFSPlusPermissions;
  156. HFSPlusPermissions = record
  157. ownerID: UInt32; { user or group ID of file/folder owner }
  158. groupID: UInt32; { additional user of group ID }
  159. permissions: UInt32; { permissions (bytes: unused, owner, group, everyone) }
  160. specialDevice: UInt32; { UNIX: device for character or block special file }
  161. end;
  162. { Catalog file data structures }
  163. const
  164. kHFSRootParentID = 1; { Parent ID of the root folder }
  165. kHFSRootFolderID = 2; { Folder ID of the root folder }
  166. kHFSExtentsFileID = 3; { File ID of the extents file }
  167. kHFSCatalogFileID = 4; { File ID of the catalog file }
  168. kHFSBadBlockFileID = 5; { File ID of the bad allocation block file }
  169. kHFSAllocationFileID = 6; { File ID of the allocation file (HFS Plus only) }
  170. kHFSStartupFileID = 7; { File ID of the startup file (HFS Plus only) }
  171. kHFSAttributesFileID = 8; { File ID of the attribute file (HFS Plus only) }
  172. kHFSBogusExtentFileID = 15; { Used for exchanging extents in extents file }
  173. kHFSFirstUserCatalogNodeID = 16;
  174. { HFS catalog key }
  175. type
  176. HFSCatalogKeyPtr = ^HFSCatalogKey;
  177. HFSCatalogKey = record
  178. keyLength: SInt8; { key length (in bytes) }
  179. reserved: SInt8; { reserved (set to zero) }
  180. parentID: HFSCatalogNodeID; { parent folder ID }
  181. nodeName: Str31; { catalog node name }
  182. end;
  183. { HFS Plus catalog key }
  184. HFSPlusCatalogKeyPtr = ^HFSPlusCatalogKey;
  185. HFSPlusCatalogKey = record
  186. keyLength: UInt16; { key length (in bytes) }
  187. parentID: HFSCatalogNodeID; { parent folder ID }
  188. nodeName: HFSUniStr255; { catalog node name }
  189. end;
  190. { Catalog record types }
  191. const
  192. { HFS Catalog Records }
  193. kHFSFolderRecord = $0100; { Folder record }
  194. kHFSFileRecord = $0200; { File record }
  195. kHFSFolderThreadRecord = $0300; { Folder thread record }
  196. kHFSFileThreadRecord = $0400; { File thread record }
  197. { HFS Plus Catalog Records }
  198. kHFSPlusFolderRecord = 1; { Folder record }
  199. kHFSPlusFileRecord = 2; { File record }
  200. kHFSPlusFolderThreadRecord = 3; { Folder thread record }
  201. kHFSPlusFileThreadRecord = 4; { File thread record }
  202. { Catalog file record flags }
  203. kHFSFileLockedBit = $0000; { file is locked and cannot be written to }
  204. kHFSFileLockedMask = $0001;
  205. kHFSThreadExistsBit = $0001; { a file thread record exists for this file }
  206. kHFSThreadExistsMask = $0002;
  207. { HFS catalog folder record - 70 bytes }
  208. type
  209. HFSCatalogFolderPtr = ^HFSCatalogFolder;
  210. HFSCatalogFolder = record
  211. recordType: SInt16; { record type }
  212. flags: UInt16; { folder flags }
  213. valence: UInt16; { folder valence }
  214. folderID: HFSCatalogNodeID; { folder ID }
  215. createDate: UInt32; { date and time of creation }
  216. modifyDate: UInt32; { date and time of last modification }
  217. backupDate: UInt32; { date and time of last backup }
  218. userInfo: DInfo; { Finder information }
  219. finderInfo: DXInfo; { additional Finder information }
  220. reserved: array [0..3] of UInt32; { reserved - set to zero }
  221. end;
  222. { HFS Plus catalog folder record - 88 bytes }
  223. HFSPlusCatalogFolderPtr = ^HFSPlusCatalogFolder;
  224. HFSPlusCatalogFolder = record
  225. recordType: SInt16; { record type = HFS Plus folder record }
  226. flags: UInt16; { file flags }
  227. valence: UInt32; { folder's valence (limited to 2^16 in Mac OS) }
  228. folderID: HFSCatalogNodeID; { folder ID }
  229. createDate: UInt32; { date and time of creation }
  230. contentModDate: UInt32; { date and time of last content modification }
  231. attributeModDate: UInt32; { date and time of last attribute modification }
  232. accessDate: UInt32; { date and time of last access (Rhapsody only) }
  233. backupDate: UInt32; { date and time of last backup }
  234. permissions: HFSPlusPermissions; { permissions (for Rhapsody) }
  235. userInfo: DInfo; { Finder information }
  236. finderInfo: DXInfo; { additional Finder information }
  237. textEncoding: UInt32; { hint for name conversions }
  238. reserved: UInt32; { reserved - set to zero }
  239. end;
  240. { HFS catalog file record - 102 bytes }
  241. HFSCatalogFilePtr = ^HFSCatalogFile;
  242. HFSCatalogFile = record
  243. recordType: SInt16; { record type }
  244. flags: SInt8; { file flags }
  245. fileType: SInt8; { file type (unused ?) }
  246. userInfo: FInfo; { Finder information }
  247. fileID: HFSCatalogNodeID; { file ID }
  248. dataStartBlock: UInt16; { not used - set to zero }
  249. dataLogicalSize: SInt32; { logical EOF of data fork }
  250. dataPhysicalSize: SInt32; { physical EOF of data fork }
  251. rsrcStartBlock: UInt16; { not used - set to zero }
  252. rsrcLogicalSize: SInt32; { logical EOF of resource fork }
  253. rsrcPhysicalSize: SInt32; { physical EOF of resource fork }
  254. createDate: UInt32; { date and time of creation }
  255. modifyDate: UInt32; { date and time of last modification }
  256. backupDate: UInt32; { date and time of last backup }
  257. finderInfo: FXInfo; { additional Finder information }
  258. clumpSize: UInt16; { file clump size (not used) }
  259. dataExtents: HFSExtentRecord; { first data fork extent record }
  260. rsrcExtents: HFSExtentRecord; { first resource fork extent record }
  261. reserved: UInt32; { reserved - set to zero }
  262. end;
  263. { HFS Plus catalog file record - 248 bytes }
  264. HFSPlusCatalogFilePtr = ^HFSPlusCatalogFile;
  265. HFSPlusCatalogFile = record
  266. recordType: SInt16; { record type = HFS Plus file record }
  267. flags: UInt16; { file flags }
  268. reserved1: UInt32; { reserved - set to zero }
  269. fileID: HFSCatalogNodeID; { file ID }
  270. createDate: UInt32; { date and time of creation }
  271. contentModDate: UInt32; { date and time of last content modification }
  272. attributeModDate: UInt32; { date and time of last attribute modification }
  273. accessDate: UInt32; { date and time of last access (Rhapsody only) }
  274. backupDate: UInt32; { date and time of last backup }
  275. permissions: HFSPlusPermissions; { permissions (for Rhapsody) }
  276. userInfo: FInfo; { Finder information }
  277. finderInfo: FXInfo; { additional Finder information }
  278. textEncoding: UInt32; { hint for name conversions }
  279. reserved2: UInt32; { reserved - set to zero }
  280. { start on double long (64 bit) boundry }
  281. dataFork: HFSPlusForkData; { size and block data for data fork }
  282. resourceFork: HFSPlusForkData; { size and block data for resource fork }
  283. end;
  284. { HFS catalog thread record - 46 bytes }
  285. HFSCatalogThreadPtr = ^HFSCatalogThread;
  286. HFSCatalogThread = record
  287. recordType: SInt16; { record type }
  288. reserved: array [0..1] of SInt32; { reserved - set to zero }
  289. parentID: HFSCatalogNodeID; { parent ID for this catalog node }
  290. nodeName: Str31; { name of this catalog node }
  291. end;
  292. { HFS Plus catalog thread record -- maximum 520 bytes }
  293. HFSPlusCatalogThreadPtr = ^HFSPlusCatalogThread;
  294. HFSPlusCatalogThread = record
  295. recordType: SInt16; { record type }
  296. reserved: SInt16; { reserved - set to zero }
  297. parentID: HFSCatalogNodeID; { parent ID for this catalog node }
  298. nodeName: HFSUniStr255; { name of this catalog node (variable length) }
  299. end;
  300. {
  301. These are the types of records in the attribute B-tree. The values were chosen
  302. so that they wouldn't conflict with the catalog record types.
  303. }
  304. const
  305. kHFSPlusAttrInlineData = $10; { if size < kAttrOverflowSize }
  306. kHFSPlusAttrForkData = $20; { if size >= kAttrOverflowSize }
  307. kHFSPlusAttrExtents = $30; { overflow extents for large attributes }
  308. {
  309. HFSPlusAttrInlineData
  310. For small attributes, whose entire value is stored within this one
  311. B-tree record.
  312. There would not be any other records for this attribute.
  313. }
  314. type
  315. HFSPlusAttrInlineDataPtr = ^HFSPlusAttrInlineData;
  316. HFSPlusAttrInlineData = record
  317. recordType: UInt32; { = kHFSPlusAttrInlineData }
  318. reserved: UInt32;
  319. logicalSize: UInt32; { size in bytes of userData }
  320. userData: packed array [0..1] of UInt8; { variable length; space allocated is a multiple of 2 bytes }
  321. end;
  322. {
  323. HFSPlusAttrForkData
  324. For larger attributes, whose value is stored in allocation blocks.
  325. If the attribute has more than 8 extents, there will be additonal
  326. records (of type HFSPlusAttrExtents) for this attribute.
  327. }
  328. HFSPlusAttrForkDataPtr = ^HFSPlusAttrForkData;
  329. HFSPlusAttrForkData = record
  330. recordType: UInt32; { = kHFSPlusAttrForkData }
  331. reserved: UInt32;
  332. theFork: HFSPlusForkData; { size and first extents of value }
  333. end;
  334. {
  335. HFSPlusAttrExtents
  336. This record contains information about overflow extents for large,
  337. fragmented attributes.
  338. }
  339. HFSPlusAttrExtentsPtr = ^HFSPlusAttrExtents;
  340. HFSPlusAttrExtents = record
  341. recordType: UInt32; { = kHFSPlusAttrExtents }
  342. reserved: UInt32;
  343. extents: HFSPlusExtentRecord; { additional extents }
  344. end;
  345. { A generic Attribute Record }
  346. HFSPlusAttrRecordPtr = ^HFSPlusAttrRecord;
  347. HFSPlusAttrRecord = record
  348. case SInt16 of
  349. 0: (
  350. recordType: UInt32;
  351. );
  352. 1: (
  353. inlineData: HFSPlusAttrInlineData;
  354. );
  355. 2: (
  356. forkData: HFSPlusAttrForkData;
  357. );
  358. 3: (
  359. overflowExtents: HFSPlusAttrExtents;
  360. );
  361. end;
  362. { Key and node lengths }
  363. const
  364. kHFSPlusExtentKeyMaximumLength = 10;
  365. kHFSExtentKeyMaximumLength = 7;
  366. kHFSPlusCatalogKeyMaximumLength = 516;
  367. kHFSPlusCatalogKeyMinimumLength = 6;
  368. kHFSCatalogKeyMaximumLength = 37;
  369. kHFSCatalogKeyMinimumLength = 6;
  370. kHFSPlusCatalogMinNodeSize = 4096;
  371. kHFSPlusExtentMinNodeSize = 512;
  372. kHFSPlusAttrMinNodeSize = 4096;
  373. { HFS and HFS Plus volume attribute bits }
  374. { Bits 0-6 are reserved (always cleared by MountVol call) }
  375. kHFSVolumeHardwareLockBit = 7; { volume is locked by hardware }
  376. kHFSVolumeUnmountedBit = 8; { volume was successfully unmounted }
  377. kHFSVolumeSparedBlocksBit = 9; { volume has bad blocks spared }
  378. kHFSVolumeNoCacheRequiredBit = 10; { don't cache volume blocks (i.e. RAM or ROM disk) }
  379. kHFSBootVolumeInconsistentBit = 11; { boot volume is inconsistent (System 7.6 and later) }
  380. { Bits 12-14 are reserved for future use }
  381. kHFSVolumeSoftwareLockBit = 15; { volume is locked by software }
  382. kHFSVolumeHardwareLockMask = $80;
  383. kHFSVolumeUnmountedMask = $0100;
  384. kHFSVolumeSparedBlocksMask = $0200;
  385. kHFSVolumeNoCacheRequiredMask = $0400;
  386. kHFSBootVolumeInconsistentMask = $0800;
  387. kHFSVolumeSoftwareLockMask = $8000;
  388. kHFSMDBAttributesMask = $8380;
  389. kHFSCatalogNodeIDsReusedBit = 12; { nextCatalogID wrapped around }
  390. kHFSCatalogNodeIDsReusedMask = $1000;
  391. { Master Directory Block (HFS only) - 162 bytes }
  392. { Stored at sector #2 (3rd sector) }
  393. type
  394. HFSMasterDirectoryBlockPtr = ^HFSMasterDirectoryBlock;
  395. HFSMasterDirectoryBlock = record
  396. { These first fields are also used by MFS }
  397. drSigWord: UInt16; { volume signature }
  398. drCrDate: UInt32; { date and time of volume creation }
  399. drLsMod: UInt32; { date and time of last modification }
  400. drAtrb: UInt16; { volume attributes }
  401. drNmFls: UInt16; { number of files in root folder }
  402. drVBMSt: UInt16; { first block of volume bitmap }
  403. drAllocPtr: UInt16; { start of next allocation search }
  404. drNmAlBlks: UInt16; { number of allocation blocks in volume }
  405. drAlBlkSiz: UInt32; { size (in bytes) of allocation blocks }
  406. drClpSiz: UInt32; { default clump size }
  407. drAlBlSt: UInt16; { first allocation block in volume }
  408. drNxtCNID: UInt32; { next unused catalog node ID }
  409. drFreeBks: UInt16; { number of unused allocation blocks }
  410. drVN: Str27; { volume name }
  411. { Master Directory Block extensions for HFS }
  412. drVolBkUp: UInt32; { date and time of last backup }
  413. drVSeqNum: UInt16; { volume backup sequence number }
  414. drWrCnt: UInt32; { volume write count }
  415. drXTClpSiz: UInt32; { clump size for extents overflow file }
  416. drCTClpSiz: UInt32; { clump size for catalog file }
  417. drNmRtDirs: UInt16; { number of directories in root folder }
  418. drFilCnt: UInt32; { number of files in volume }
  419. drDirCnt: UInt32; { number of directories in volume }
  420. drFndrInfo: array [0..7] of SInt32; { information used by the Finder }
  421. drEmbedSigWord: UInt16; { embedded volume signature (formerly drVCSize) }
  422. drEmbedExtent: HFSExtentDescriptor; { embedded volume location and size (formerly drVBMCSize and drCtlCSize) }
  423. drXTFlSize: UInt32; { size of extents overflow file }
  424. drXTExtRec: HFSExtentRecord; { extent record for extents overflow file }
  425. drCTFlSize: UInt32; { size of catalog file }
  426. drCTExtRec: HFSExtentRecord; { extent record for catalog file }
  427. end;
  428. { HFSPlusVolumeHeader (HFS Plus only) - 512 bytes }
  429. { Stored at sector #2 (3rd sector) and second-to-last sector. }
  430. HFSPlusVolumeHeaderPtr = ^HFSPlusVolumeHeader;
  431. HFSPlusVolumeHeader = record
  432. signature: UInt16; { volume signature == 'H+' }
  433. version: UInt16; { current version is kHFSPlusVersion }
  434. attributes: UInt32; { volume attributes }
  435. lastMountedVersion: UInt32; { implementation version which last mounted volume }
  436. reserved: UInt32; { reserved - set to zero }
  437. createDate: UInt32; { date and time of volume creation }
  438. modifyDate: UInt32; { date and time of last modification }
  439. backupDate: UInt32; { date and time of last backup }
  440. checkedDate: UInt32; { date and time of last disk check }
  441. fileCount: UInt32; { number of files in volume }
  442. folderCount: UInt32; { number of directories in volume }
  443. blockSize: UInt32; { size (in bytes) of allocation blocks }
  444. totalBlocks: UInt32; { number of allocation blocks in volume (includes this header and VBM }
  445. freeBlocks: UInt32; { number of unused allocation blocks }
  446. nextAllocation: UInt32; { start of next allocation search }
  447. rsrcClumpSize: UInt32; { default resource fork clump size }
  448. dataClumpSize: UInt32; { default data fork clump size }
  449. nextCatalogID: HFSCatalogNodeID; { next unused catalog node ID }
  450. writeCount: UInt32; { volume write count }
  451. encodingsBitmap: UInt64; { which encodings have been use on this volume }
  452. finderInfo: packed array [0..31] of UInt8; { information used by the Finder }
  453. allocationFile: HFSPlusForkData; { allocation bitmap file }
  454. extentsFile: HFSPlusForkData; { extents B-tree file }
  455. catalogFile: HFSPlusForkData; { catalog B-tree file }
  456. attributesFile: HFSPlusForkData; { extended attributes B-tree file }
  457. startupFile: HFSPlusForkData; { boot file }
  458. end;
  459. { ---------- HFS and HFS Plus B-tree structures ---------- }
  460. { BTNodeDescriptor -- Every B-tree node starts with these fields. }
  461. BTNodeDescriptorPtr = ^BTNodeDescriptor;
  462. BTNodeDescriptor = record
  463. fLink: UInt32; { next node at this level }
  464. bLink: UInt32; { previous node at this level }
  465. kind: SInt8; { kind of node (leaf, index, header, map) }
  466. height: SInt8; { zero for header, map; child is one more than parent }
  467. numRecords: UInt16; { number of records in this node }
  468. reserved: UInt16; { reserved; set to zero }
  469. end;
  470. { Constants for BTNodeDescriptor kind }
  471. const
  472. kBTLeafNode = -1;
  473. kBTIndexNode = 0;
  474. kBTHeaderNode = 1;
  475. kBTMapNode = 2;
  476. { BTHeaderRec -- The first record of a B-tree header node }
  477. type
  478. BTHeaderRecPtr = ^BTHeaderRec;
  479. BTHeaderRec = record
  480. treeDepth: UInt16; { maximum height (usually leaf nodes) }
  481. rootNode: UInt32; { node number of root node }
  482. leafRecords: UInt32; { number of leaf records in all leaf nodes }
  483. firstLeafNode: UInt32; { node number of first leaf node }
  484. lastLeafNode: UInt32; { node number of last leaf node }
  485. nodeSize: UInt16; { size of a node, in bytes }
  486. maxKeyLength: UInt16; { reserved }
  487. totalNodes: UInt32; { total number of nodes in tree }
  488. freeNodes: UInt32; { number of unused (free) nodes in tree }
  489. reserved1: UInt16; { unused }
  490. clumpSize: UInt32; { reserved }
  491. btreeType: SInt8; { reserved }
  492. reserved2: SInt8; { reserved }
  493. attributes: UInt32; { persistent attributes about the tree }
  494. reserved3: array [0..15] of UInt32; { reserved }
  495. end;
  496. { Constants for BTHeaderRec attributes }
  497. const
  498. kBTBadCloseMask = $00000001; { reserved }
  499. kBTBigKeysMask = $00000002; { key length field is 16 bits }
  500. kBTVariableIndexKeysMask = $00000004; { keys in index nodes are variable length }
  501. {$ALIGN MAC68K}
  502. end.