1 | /** @file
|
---|
2 | * IPRT - Hierarchical File System (HFS).
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2009-2022 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef IPRT_INCLUDED_formats_hfs_h
|
---|
27 | #define IPRT_INCLUDED_formats_hfs_h
|
---|
28 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
29 | # pragma once
|
---|
30 | #endif
|
---|
31 |
|
---|
32 |
|
---|
33 | #include <iprt/types.h>
|
---|
34 | #include <iprt/assertcompile.h>
|
---|
35 |
|
---|
36 |
|
---|
37 | /** @defgroup grp_rt_fmt_hfs HFS - Hierarchical File System.
|
---|
38 | * @{
|
---|
39 | */
|
---|
40 |
|
---|
41 |
|
---|
42 | /** @name HFS signature words (HFSPlusVolumeHeader::signature)
|
---|
43 | * @{ */
|
---|
44 | #define kHFSSigWord UINT16_C(0x4244)
|
---|
45 | #define kHFSPlusSigWord UINT16_C(0x482b)
|
---|
46 | #define kHFSXSigWord UINT16_C(0x4858)
|
---|
47 | /** @} */
|
---|
48 |
|
---|
49 | /** @name HFS version numbers (HFSPlusVolumeHeader::version).
|
---|
50 | * @{ */
|
---|
51 | #define kHFSPlusVersion UINT16_C(4)
|
---|
52 | #define kHFSXVersion UINT16_C(5)
|
---|
53 | /** @} */
|
---|
54 |
|
---|
55 | /** @name HFS mount version numbers (HFSPlusVolumeHeader::lastMountedVersion).
|
---|
56 | * @{ */
|
---|
57 | #define kHFSPlusMountVersion UINT32_C(0x31302e30)
|
---|
58 | #define kHFSJMountVersion UINT32_C(0x4846534a)
|
---|
59 | #define kFSKMountVersion UINT32_C(0x46534b21)
|
---|
60 | /** @} */
|
---|
61 |
|
---|
62 | /** @name Hard link file creators & types.
|
---|
63 | * @{ */
|
---|
64 | #define kHardLinkFileType UINT32_C(0x686c6e6b)
|
---|
65 | #define kHFSPlusCreator UINT32_C(0x6866732b)
|
---|
66 | /** @} */
|
---|
67 |
|
---|
68 | /** @name Symlink file creators & types.
|
---|
69 | * @{ */
|
---|
70 | #define kSymLinkFileType UINT32_C(0x736c6e6b)
|
---|
71 | #define kSymLinkCreator UINT32_C(0x72686170)
|
---|
72 | /** @} */
|
---|
73 |
|
---|
74 | /** @name Name limits.
|
---|
75 | * @{ */
|
---|
76 | #define kHFSMaxVolumeNameChars UINT8_C(0x1b)
|
---|
77 | #define kHFSMaxFileNameChars UINT8_C(0x1f)
|
---|
78 | #define kHFSPlusMaxFileNameChars UINT8_C(0xff)
|
---|
79 | #define kHFSMaxAttrNameLen UINT8_C(0x7f)
|
---|
80 | /** @} */
|
---|
81 |
|
---|
82 | /** @name Extent descriptor record densities
|
---|
83 | * @{ */
|
---|
84 | #define kHFSExtentDensity UINT8_C(3)
|
---|
85 | #define kHFSPlusExtentDensity UINT8_C(8)
|
---|
86 | /** @} */
|
---|
87 |
|
---|
88 |
|
---|
89 | /** @name File IDs (various fileID members).
|
---|
90 | * @{ */
|
---|
91 | #define kHFSRootParentID UINT32_C(0x00000001)
|
---|
92 | #define kHFSRootFolderID UINT32_C(0x00000002)
|
---|
93 | #define kHFSExtentsFileID UINT32_C(0x00000003)
|
---|
94 | #define kHFSCatalogFileID UINT32_C(0x00000004)
|
---|
95 | #define kHFSBadBlockFileID UINT32_C(0x00000005)
|
---|
96 | #define kHFSAllocationFileID UINT32_C(0x00000006)
|
---|
97 | #define kHFSStartupFileID UINT32_C(0x00000007)
|
---|
98 | #define kHFSAttributesFileID UINT32_C(0x00000008)
|
---|
99 | #define kHFSAttributeDataFileID UINT32_C(0x0000000c)
|
---|
100 | #define kHFSRepairCatalogFileID UINT32_C(0x0000000e)
|
---|
101 | #define kHFSBogusExtentFileID UINT32_C(0x0000000f)
|
---|
102 | #define kHFSFirstUserCatalogNodeID UINT32_C(0x00000010)
|
---|
103 | /** @} */
|
---|
104 |
|
---|
105 | /** @name Catalog record types.
|
---|
106 | * @{ */
|
---|
107 | #define kHFSFolderRecord UINT16_C(0x0100)
|
---|
108 | #define kHFSFileRecord UINT16_C(0x0200)
|
---|
109 | #define kHFSFolderThreadRecord UINT16_C(0x0300)
|
---|
110 | #define kHFSFileThreadRecord UINT16_C(0x0400)
|
---|
111 | #define kHFSPlusFolderRecord UINT16_C(0x0001)
|
---|
112 | #define kHFSPlusFileRecord UINT16_C(0x0002)
|
---|
113 | #define kHFSPlusFolderThreadRecord UINT16_C(0x0003)
|
---|
114 | #define kHFSPlusFileThreadRecord UINT16_C(0x0004)
|
---|
115 | /** @} */
|
---|
116 |
|
---|
117 | /** @name File record bits and masks.
|
---|
118 | * @{ */
|
---|
119 | #define kHFSFileLockedBit 0
|
---|
120 | #define kHFSThreadExistsBit 1
|
---|
121 | #define kHFSHasAttributesBit 2
|
---|
122 | #define kHFSHasSecurityBit 3
|
---|
123 | #define kHFSHasFolderCountBit 4
|
---|
124 | #define kHFSHasLinkChainBit 5
|
---|
125 | #define kHFSHasChildLinkBit 6
|
---|
126 | #define kHFSHasDateAddedBit 7
|
---|
127 |
|
---|
128 | #define kHFSFileLockedMask RT_BIT(kHFSFileLockedBit)
|
---|
129 | #define kHFSThreadExistsMask RT_BIT(kHFSThreadExistsBit)
|
---|
130 | #define kHFSHasAttributesMask RT_BIT(kHFSHasAttributesBit)
|
---|
131 | #define kHFSHasSecurityMask RT_BIT(kHFSHasSecurityBit)
|
---|
132 | #define kHFSHasFolderCountMask RT_BIT(kHFSHasFolderCountBit)
|
---|
133 | #define kHFSHasLinkChainMask RT_BIT(kHFSHasLinkChainBit)
|
---|
134 | #define kHFSHasChildLinkMask RT_BIT(kHFSHasChildLinkBit)
|
---|
135 | #define kHFSHasDateAddedMask RT_BIT(kHFSHasDateAddedBit)
|
---|
136 | /** @} */
|
---|
137 |
|
---|
138 | /** @name Key and node lengths.
|
---|
139 | * @{ */
|
---|
140 | #define kHFSPlusAttrKeyMaximumLength ( sizeof(HFSPlusAttrKey) - sizeof(uint16_t) )
|
---|
141 | #define kHFSPlusAttrKeyMinimumLength ( kHFSPlusAttrKeyMaximumLength - (kHFSMaxAttrNameLen * sizeof(uint16_t)) )
|
---|
142 | #define kHFSPlusExtentKeyMaximumLength ( sizeof(HFSPlusExtentKey) - sizeof(uint16_t),
|
---|
143 | #define kHFSExtentKeyMaximumLength ( sizeof(HFSExtentKey) - sizeof(uint8_t) )
|
---|
144 | #define kHFSPlusCatalogKeyMaximumLength ( sizeof(HFSPlusCatalogKey) - sizeof(uint16_t) )
|
---|
145 | #define kHFSPlusCatalogKeyMinimumLength ( kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(uint16_t) )
|
---|
146 | #define kHFSCatalogKeyMaximumLength ( sizeof(HFSCatalogKey) - sizeof(uint8_t) )
|
---|
147 | #define kHFSCatalogKeyMinimumLength ( kHFSCatalogKeyMaximumLength - kHFSMaxFileNameChars - 1 + sizeof(uint8_t) )
|
---|
148 | #define kHFSPlusCatalogMinNodeSize UINT16_C(0x1000)
|
---|
149 | #define kHFSPlusExtentMinNodeSize UINT16_C(0x0200)
|
---|
150 | #define kHFSPlusAttrMinNodeSize UINT16_C(0x1000)
|
---|
151 | /** @} */
|
---|
152 |
|
---|
153 | /** @name Volume Attribute bits and masks.
|
---|
154 | * @remarks HFS has only 16-bit wide field, HFS+ has 32-bit.
|
---|
155 | * @{ */
|
---|
156 | #define kHFSVolumeHardwareLockBit 7
|
---|
157 | #define kHFSVolumeUnmountedBit 8
|
---|
158 | #define kHFSVolumeSparedBlocksBit 9
|
---|
159 | #define kHFSVolumeNoCacheRequiredBit 10
|
---|
160 | #define kHFSBootVolumeInconsistentBit 11
|
---|
161 | #define kHFSCatalogNodeIDsReusedBit 12
|
---|
162 | #define kHFSVolumeJournaledBit 13
|
---|
163 | #define kHFSVolumeInconsistentBit 14
|
---|
164 | #define kHFSVolumeSoftwareLockBit 15
|
---|
165 | #define kHFSUnusedNodeFixBit 31
|
---|
166 | #define kHFSContentProtectionBit 30
|
---|
167 |
|
---|
168 | #define kHFSVolumeHardwareLockMask RT_BIT(kHFSVolumeHardwareLockBit)
|
---|
169 | #define kHFSVolumeUnmountedMask RT_BIT(kHFSVolumeUnmountedBit)
|
---|
170 | #define kHFSVolumeSparedBlocksMask RT_BIT(kHFSVolumeSparedBlocksBit)
|
---|
171 | #define kHFSVolumeNoCacheRequiredMask RT_BIT(kHFSVolumeNoCacheRequiredBit)
|
---|
172 | #define kHFSBootVolumeInconsistentMask RT_BIT(kHFSBootVolumeInconsistentBit)
|
---|
173 | #define kHFSCatalogNodeIDsReusedMask RT_BIT(kHFSCatalogNodeIDsReusedBit)
|
---|
174 | #define kHFSVolumeJournaledMask RT_BIT(kHFSVolumeJournaledBit)
|
---|
175 | #define kHFSVolumeInconsistentMask RT_BIT(kHFSVolumeInconsistentBit)
|
---|
176 | #define kHFSVolumeSoftwareLockMask RT_BIT(kHFSVolumeSoftwareLockBit)
|
---|
177 | #define kHFSUnusedNodeFixMask RT_BIT(kHFSUnusedNodeFixBit)
|
---|
178 | #define kHFSContentProtectionMask RT_BIT(kHFSContentProtectionBit)
|
---|
179 |
|
---|
180 | #define kHFSMDBAttributesMask UINT16_C(0x8380)
|
---|
181 | /** @} */
|
---|
182 |
|
---|
183 | /** @name Misc
|
---|
184 | * @{ */
|
---|
185 | #define kHFSUnusedNodesFixDate UINT32_C(0xc5ef2480)
|
---|
186 |
|
---|
187 | #define HFSPLUSMETADATAFOLDER "\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80\xE2\x90\x80HFS+ Private Data"
|
---|
188 | #define HFSPLUS_DIR_METADATA_FOLDER ".HFS+ Private Directory Data\xd"
|
---|
189 | #define HFS_INODE_PREFIX "iNode"
|
---|
190 | #define HFS_DELETE_PREFIX "temp"
|
---|
191 | #define HFS_DIRINODE_PREFIX "dir_"
|
---|
192 | #define FIRST_LINK_XATTR_NAME "com.apple.system.hfs.firstlink"
|
---|
193 | #define FIRST_LINK_XATTR_REC_SIZE ( sizeof(HFSPlusAttrData) + 10 )
|
---|
194 |
|
---|
195 | /* {b3e20f39-f292-11d6-97a4-00306543ecac} */
|
---|
196 | #define HFS_UUID_NAMESPACE_ID "\xB3\xE2\x0F\x39\xF2\x92\x11\xD6\x97\xA4\x00\x30\x65\x43\xEC\xAC"
|
---|
197 |
|
---|
198 | #define SET_HFS_TEXT_ENCODING(a_uHint) (UINT32_C(0x656e6300) | (uint8_t)(a_uHint))
|
---|
199 | #define GET_HFS_TEXT_ENCODING(a_uHint) ( ((a_uHint) & UINT32_C(0xffffff00)) == UINT32_C(0x656e6300) \
|
---|
200 | ? UINT32_C(0x000000ff)(a_uHint) : UINT32_MAX)
|
---|
201 | /** @} */
|
---|
202 |
|
---|
203 | /** @name B-tree stuff.
|
---|
204 | * @{ */
|
---|
205 | #define kMaxKeyLength 520
|
---|
206 |
|
---|
207 | #define kBTLeafNode (-1)
|
---|
208 | #define kBTIndexNode 0
|
---|
209 | #define kBTHeaderNode 1
|
---|
210 | #define kBTMapNode 2
|
---|
211 |
|
---|
212 | #define kBTBadCloseMask RT_BIT_32(0)
|
---|
213 | #define kBTBigKeysMask RT_BIT_32(1)
|
---|
214 | #define kBTVariableIndexKeysMask RT_BIT_32(2)
|
---|
215 |
|
---|
216 | /** @} */
|
---|
217 |
|
---|
218 | /** @name B-tree compare types (BTHeaderRec::keyCompareType)
|
---|
219 | * @{ */
|
---|
220 | #define kHFSCaseFolding UINT8_C(0xcf)
|
---|
221 | #define kHFSBinaryCompare UINT8_C(0xbc)
|
---|
222 | /** @} */
|
---|
223 |
|
---|
224 | /** @name Journal stuff.
|
---|
225 | * @{ */
|
---|
226 | #define JIB_RESERVED_SIZE ( sizeof(uint32_t) * 32 - 85 )
|
---|
227 |
|
---|
228 | #define kJIJournalInFSMask RT_BIT_32(0)
|
---|
229 | #define kJIJournalOnOtherDeviceMask RT_BIT_32(1)
|
---|
230 | #define kJIJournalNeedInitMask RT_BIT_32(2)
|
---|
231 |
|
---|
232 | #define EXTJNL_CONTENT_TYPE_UUID "4a6f7572-6e61-11aa-aa11-00306543ecac"
|
---|
233 | /** @} */
|
---|
234 |
|
---|
235 |
|
---|
236 |
|
---|
237 | typedef struct HFSUniStr255
|
---|
238 | {
|
---|
239 | uint16_t length;
|
---|
240 | RTUTF16 unicode[255];
|
---|
241 | } HFSUniStr255;
|
---|
242 | AssertCompileSize(HFSUniStr255, 0x200);
|
---|
243 | typedef const HFSUniStr255 * ConstHFSUniStr255Param;
|
---|
244 |
|
---|
245 | #pragma pack(1)
|
---|
246 | typedef struct HFSExtentKey
|
---|
247 | {
|
---|
248 | uint8_t keyLength;
|
---|
249 | uint8_t forkType;
|
---|
250 | uint32_t fileID; /**< Misaligned. */
|
---|
251 | uint16_t startBLock;
|
---|
252 | } HFSExtentKey;
|
---|
253 | #pragma pack()
|
---|
254 | AssertCompileSize(HFSExtentKey, 8);
|
---|
255 |
|
---|
256 | typedef struct HFSPlusExtentKey
|
---|
257 | {
|
---|
258 | uint16_t keyLength;
|
---|
259 | uint8_t forkType;
|
---|
260 | uint8_t pad;
|
---|
261 | uint32_t fileID;
|
---|
262 | uint32_t startBlock;
|
---|
263 | } HFSPlusExtentKey;
|
---|
264 | AssertCompileSize(HFSPlusExtentKey, 12);
|
---|
265 |
|
---|
266 | typedef struct HFSExtentDescriptor
|
---|
267 | {
|
---|
268 | uint16_t startBlock;
|
---|
269 | uint16_t blockCount;
|
---|
270 | } HFSExtentDescriptor;
|
---|
271 | AssertCompileSize(HFSExtentDescriptor, 4);
|
---|
272 |
|
---|
273 | typedef struct HFSPlusExtentDescriptor
|
---|
274 | {
|
---|
275 | uint32_t startBlock;
|
---|
276 | uint32_t blockCount;
|
---|
277 | } HFSPlusExtentDescriptor;
|
---|
278 | AssertCompileSize(HFSPlusExtentDescriptor, 8);
|
---|
279 |
|
---|
280 | typedef HFSExtentDescriptor HFSExtentRecord[3];
|
---|
281 | typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
|
---|
282 |
|
---|
283 | typedef struct FndrFileInfo
|
---|
284 | {
|
---|
285 | uint32_t fdType;
|
---|
286 | uint32_t fdCreator;
|
---|
287 | uint16_t fdFlags;
|
---|
288 | struct
|
---|
289 | {
|
---|
290 | int16_t v;
|
---|
291 | int16_t h;
|
---|
292 | } fdLocation;
|
---|
293 | uint16_t opaque;
|
---|
294 | } FndrFileInfo;
|
---|
295 | AssertCompileSize(FndrFileInfo, 16);
|
---|
296 |
|
---|
297 | typedef struct FndrDirInfo
|
---|
298 | {
|
---|
299 | struct
|
---|
300 | {
|
---|
301 | int16_t top;
|
---|
302 | int16_t left;
|
---|
303 | int16_t bottom;
|
---|
304 | int16_t right;
|
---|
305 | } frRect;
|
---|
306 | uint16_t frFlags;
|
---|
307 | struct
|
---|
308 | {
|
---|
309 | int16_t v;
|
---|
310 | int16_t h;
|
---|
311 | } fdLocation;
|
---|
312 | uint16_t opaque;
|
---|
313 | } FndrDirInfo;
|
---|
314 | AssertCompileSize(FndrDirInfo, 16);
|
---|
315 |
|
---|
316 | typedef struct FndrOpaqueInfo
|
---|
317 | {
|
---|
318 | int8_t opaque[16];
|
---|
319 | } FndrOpaqueInfo;
|
---|
320 | AssertCompileSize(FndrOpaqueInfo, 16);
|
---|
321 |
|
---|
322 | typedef struct FndrExtendedFileInfo
|
---|
323 | {
|
---|
324 | uint32_t reserved1;
|
---|
325 | uint32_t date_added;
|
---|
326 | uint16_t extended_flags;
|
---|
327 | uint16_t reserved2;
|
---|
328 | uint32_t reserved3;
|
---|
329 | } FndrExtendedFileInfo;
|
---|
330 | AssertCompileSize(FndrExtendedFileInfo, 16);
|
---|
331 |
|
---|
332 | typedef struct FndrExtendedDirInfo
|
---|
333 | {
|
---|
334 | uint32_t point;
|
---|
335 | uint32_t date_added;
|
---|
336 | uint16_t extended_flags;
|
---|
337 | uint16_t reserved3;
|
---|
338 | uint32_t reserved4;
|
---|
339 | } FndrExtendedDirInfo;
|
---|
340 | AssertCompileSize(FndrExtendedDirInfo, 16);
|
---|
341 |
|
---|
342 | typedef struct HFSPlusForkData
|
---|
343 | {
|
---|
344 | uint64_t logicalSize;
|
---|
345 | uint32_t clumpSize;
|
---|
346 | uint32_t totalBlocks;
|
---|
347 | HFSPlusExtentRecord extents;
|
---|
348 | } HFSPlusForkData;
|
---|
349 | AssertCompileSize(HFSPlusForkData, 80);
|
---|
350 |
|
---|
351 | typedef struct HFSPlusBSDInfo
|
---|
352 | {
|
---|
353 | uint32_t ownerID;
|
---|
354 | uint32_t groupID;
|
---|
355 | uint8_t adminFlags;
|
---|
356 | uint8_t ownerFlags;
|
---|
357 | uint16_t fileMode;
|
---|
358 | union
|
---|
359 | {
|
---|
360 | uint32_t iNodeNum;
|
---|
361 | uint32_t linkCount;
|
---|
362 | uint32_t rawDevice;
|
---|
363 | } special;
|
---|
364 | } HFSPlusBSDInfo;
|
---|
365 | AssertCompileSize(HFSPlusBSDInfo, 16);
|
---|
366 |
|
---|
367 | #pragma pack(1)
|
---|
368 | typedef struct HFSCatalogKey
|
---|
369 | {
|
---|
370 | uint8_t keyLength;
|
---|
371 | uint8_t reserved;
|
---|
372 | uint32_t parentID; /**< Misaligned. */
|
---|
373 | uint8_t nodeName[kHFSMaxFileNameChars + 1];
|
---|
374 | } HFSCatalogKey;
|
---|
375 | #pragma pack()
|
---|
376 | AssertCompileSize(HFSCatalogKey, 0x26);
|
---|
377 |
|
---|
378 | #pragma pack(1)
|
---|
379 | typedef struct HFSPlusCatalogKey
|
---|
380 | {
|
---|
381 | uint16_t keyLength;
|
---|
382 | uint32_t parentID; /**< Misaligned. */
|
---|
383 | HFSUniStr255 nodeName;
|
---|
384 | } HFSPlusCatalogKey;
|
---|
385 | #pragma pack()
|
---|
386 | AssertCompileSize(HFSPlusCatalogKey, 0x206);
|
---|
387 |
|
---|
388 | #pragma pack(1)
|
---|
389 | typedef struct HFSCatalogFolder
|
---|
390 | {
|
---|
391 | int16_t recordType;
|
---|
392 | uint16_t flags;
|
---|
393 | uint16_t valence;
|
---|
394 | uint32_t folderID; /**< Misaligned. */
|
---|
395 | uint32_t createDate; /**< Misaligned. */
|
---|
396 | uint32_t modifyDate; /**< Misaligned. */
|
---|
397 | uint32_t backupDate; /**< Misaligned. */
|
---|
398 | FndrDirInfo userInfo;
|
---|
399 | FndrOpaqueInfo finderInfo;
|
---|
400 | uint32_t reserved[4]; /**< Misaligned. */
|
---|
401 | } HFSCatalogFolder;
|
---|
402 | #pragma pack()
|
---|
403 | AssertCompileSize(HFSCatalogFolder, 70);
|
---|
404 |
|
---|
405 | typedef struct HFSPlusCatalogFolder
|
---|
406 | {
|
---|
407 | int16_t recordType;
|
---|
408 | uint16_t flags;
|
---|
409 | uint32_t valence;
|
---|
410 | uint32_t folderID;
|
---|
411 | uint32_t createDate;
|
---|
412 | uint32_t contentModDate;
|
---|
413 | uint32_t attributeModDate;
|
---|
414 | uint32_t accessDate;
|
---|
415 | uint32_t backupDate;
|
---|
416 | HFSPlusBSDInfo bsdInfo;
|
---|
417 | FndrDirInfo userInfo;
|
---|
418 | FndrOpaqueInfo finderInfo;
|
---|
419 | uint32_t textEncoding;
|
---|
420 | uint32_t folderCount;
|
---|
421 | } HFSPlusCatalogFolder;
|
---|
422 | AssertCompileSize(HFSPlusCatalogFolder, 88);
|
---|
423 |
|
---|
424 | #pragma pack(1)
|
---|
425 | typedef struct HFSCatalogFile
|
---|
426 | {
|
---|
427 | int16_t recordType;
|
---|
428 | uint8_t flags;
|
---|
429 | uint8_t fileType;
|
---|
430 | FndrFileInfo userInfo;
|
---|
431 | uint32_t fileID;
|
---|
432 | uint16_t dataStartBlock;
|
---|
433 | int32_t dataLogicalSize; /**< Misaligned. */
|
---|
434 | int32_t dataPhysicalSize; /**< Misaligned. */
|
---|
435 | uint16_t rsrcStartBlock;
|
---|
436 | int32_t rsrcLogicalSize;
|
---|
437 | int32_t rsrcPhysicalSize;
|
---|
438 | uint32_t createDate;
|
---|
439 | uint32_t modifyDate;
|
---|
440 | uint32_t backupDate;
|
---|
441 | FndrOpaqueInfo finderInfo;
|
---|
442 | uint16_t clumpSize;
|
---|
443 | HFSExtentRecord dataExtents; /**< Misaligned. */
|
---|
444 | HFSExtentRecord rsrcExtents; /**< Misaligned. */
|
---|
445 | uint32_t reserved; /**< Misaligned. */
|
---|
446 | } HFSCatalogFile;
|
---|
447 | #pragma pack()
|
---|
448 | AssertCompileSize(HFSCatalogFile, 102);
|
---|
449 |
|
---|
450 | #pragma pack(1)
|
---|
451 | typedef struct HFSPlusCatalogFile
|
---|
452 | {
|
---|
453 | int16_t recordType;
|
---|
454 | uint16_t flags;
|
---|
455 | uint32_t reserved1;
|
---|
456 | uint32_t fileID;
|
---|
457 | uint32_t createDate;
|
---|
458 | uint32_t contentModDate;
|
---|
459 | uint32_t attributeModDate;
|
---|
460 | uint32_t accessDate;
|
---|
461 | uint32_t backupDate;
|
---|
462 | HFSPlusBSDInfo bsdInfo;
|
---|
463 | FndrFileInfo userInfo;
|
---|
464 | FndrOpaqueInfo finderInfo;
|
---|
465 | uint32_t textEncoding;
|
---|
466 | uint32_t reserved2;
|
---|
467 | HFSPlusForkData dataFork;
|
---|
468 | HFSPlusForkData resourceFork;
|
---|
469 | } HFSPlusCatalogFile;
|
---|
470 | #pragma pack()
|
---|
471 | AssertCompileMemberAlignment(HFSPlusCatalogFile, dataFork, 8);
|
---|
472 | AssertCompileSize(HFSPlusCatalogFile, 248);
|
---|
473 |
|
---|
474 | #pragma pack(1)
|
---|
475 | typedef struct HFSCatalogThread
|
---|
476 | {
|
---|
477 | int16_t recordType;
|
---|
478 | int32_t reserved[2];
|
---|
479 | uint32_t parentID;
|
---|
480 | uint8_t nodeName[kHFSMaxFileNameChars + 1];
|
---|
481 | } HFSCatalogThread;
|
---|
482 | #pragma pack()
|
---|
483 | AssertCompileSize(HFSCatalogThread, 46);
|
---|
484 |
|
---|
485 | typedef struct HFSPlusCatalogThread
|
---|
486 | {
|
---|
487 | int16_t recordType;
|
---|
488 | int16_t reserved;
|
---|
489 | uint32_t parentID;
|
---|
490 | HFSUniStr255 nodeName;
|
---|
491 | } HFSPlusCatalogThread;
|
---|
492 | AssertCompileSize(HFSPlusCatalogThread, 0x208);
|
---|
493 |
|
---|
494 | typedef struct HFSPlusAttrForkData
|
---|
495 | {
|
---|
496 | uint32_t recordType;
|
---|
497 | uint32_t reserved;
|
---|
498 | HFSPlusForkData theFork;
|
---|
499 | } HFSPlusAttrForkData;
|
---|
500 | AssertCompileSize(HFSPlusAttrForkData, 88);
|
---|
501 |
|
---|
502 | typedef struct HFSPlusAttrExtents
|
---|
503 | {
|
---|
504 | uint32_t recordType;
|
---|
505 | uint32_t reserved;
|
---|
506 | HFSPlusExtentRecord extents;
|
---|
507 | } HFSPlusAttrExtents;
|
---|
508 | AssertCompileSize(HFSPlusAttrExtents, 72);
|
---|
509 |
|
---|
510 | #pragma pack(1)
|
---|
511 | typedef struct HFSPlusAttrData
|
---|
512 | {
|
---|
513 | uint32_t recordType;
|
---|
514 | uint32_t reserved[2];
|
---|
515 | uint32_t attrSize;
|
---|
516 | uint8_t attrData[2]; /**< Causes misaligned struct size. */
|
---|
517 | } HFSPlusAttrData;
|
---|
518 | #pragma pack()
|
---|
519 | AssertCompileSize(HFSPlusAttrData, 18);
|
---|
520 |
|
---|
521 | #pragma pack(1)
|
---|
522 | typedef struct HFSPlusAttrInlineData
|
---|
523 | {
|
---|
524 | uint32_t recordType;
|
---|
525 | uint32_t reserved;
|
---|
526 | uint32_t logicalSize;
|
---|
527 | uint8_t userData[2]; /**< Causes misaligned struct size. */
|
---|
528 | } HFSPlusAttrInlineData;
|
---|
529 | #pragma pack()
|
---|
530 | AssertCompileSize(HFSPlusAttrInlineData, 14);
|
---|
531 |
|
---|
532 | typedef union HFSPlusAttrRecord
|
---|
533 | {
|
---|
534 | uint32_t recordType;
|
---|
535 | HFSPlusAttrInlineData inlineData;
|
---|
536 | HFSPlusAttrData attrData;
|
---|
537 | HFSPlusAttrForkData forkData;
|
---|
538 | HFSPlusAttrExtents overflowExtents;
|
---|
539 | } HFSPlusAttrRecord;
|
---|
540 | AssertCompileSize(HFSPlusAttrRecord, 88);
|
---|
541 |
|
---|
542 | typedef struct HFSPlusAttrKey
|
---|
543 | {
|
---|
544 | uint16_t keyLength;
|
---|
545 | uint16_t pad;
|
---|
546 | uint32_t fileID;
|
---|
547 | uint32_t startBlock;
|
---|
548 | uint16_t attrNameLen;
|
---|
549 | RTUTF16 attrName[kHFSMaxAttrNameLen];
|
---|
550 | } HFSPlusAttrKey;
|
---|
551 | AssertCompileSize(HFSPlusAttrKey, 268);
|
---|
552 |
|
---|
553 | #pragma pack(1)
|
---|
554 | typedef struct HFSMasterDirectoryBlock
|
---|
555 | {
|
---|
556 | uint16_t drSigWord;
|
---|
557 | uint32_t drCrDate; /**< Misaligned. */
|
---|
558 | uint32_t drLsMod; /**< Misaligned. */
|
---|
559 | uint16_t drAtrb;
|
---|
560 | uint16_t drNmFls;
|
---|
561 | uint16_t drVBMSt;
|
---|
562 | uint16_t drAllocPtr;
|
---|
563 | uint16_t drNmAlBlks;
|
---|
564 | uint32_t drAlBlkSiz;
|
---|
565 | uint32_t drClpSiz;
|
---|
566 | uint16_t drAlBlSt;
|
---|
567 | uint32_t drNxCNID; /**< Misaligned. */
|
---|
568 | uint16_t drFreeBks;
|
---|
569 | uint8_t drVN[kHFSMaxVolumeNameChars + 1];
|
---|
570 | uint32_t drVolBkUp;
|
---|
571 | uint16_t drVSeqNum;
|
---|
572 | uint32_t drWrCnt; /**< Misaligned. */
|
---|
573 | uint32_t drXTClpSiz; /**< Misaligned. */
|
---|
574 | uint32_t drCTClpSiz; /**< Misaligned. */
|
---|
575 | uint16_t drNmRtDirs;
|
---|
576 | uint32_t drFilCnt;
|
---|
577 | uint32_t drDirCnt;
|
---|
578 | uint32_t drFndrInfo[8];
|
---|
579 | uint16_t drEmbedSigWord;
|
---|
580 | HFSExtentDescriptor drEmbedExtent;
|
---|
581 | uint32_t drXTFlSize; /**< Misaligned. */
|
---|
582 | HFSExtentRecord drXTExtRec;
|
---|
583 | uint32_t drCTFlSize; /**< Misaligned. */
|
---|
584 | HFSExtentRecord drCTExtRec;
|
---|
585 | } HFSMasterDirectoryBlock;
|
---|
586 | #pragma pack()
|
---|
587 | AssertCompileSize(HFSMasterDirectoryBlock, 162);
|
---|
588 |
|
---|
589 | typedef struct HFSPlusVolumeHeader
|
---|
590 | {
|
---|
591 | uint16_t signature;
|
---|
592 | uint16_t version;
|
---|
593 | uint32_t attributes;
|
---|
594 | uint32_t lastMountedVersion;
|
---|
595 | uint32_t journalInfoBlock;
|
---|
596 | uint32_t createDate;
|
---|
597 | uint32_t modifyDate;
|
---|
598 | uint32_t backupDate;
|
---|
599 | uint32_t checkedDate;
|
---|
600 | uint32_t fileCount;
|
---|
601 | uint32_t folderCount;
|
---|
602 | uint32_t blockSize;
|
---|
603 | uint32_t totalBlocks;
|
---|
604 | uint32_t freeBlocks;
|
---|
605 | uint32_t nextAllocation;
|
---|
606 | uint32_t rsrcClumpSize;
|
---|
607 | uint32_t dataClumpSize;
|
---|
608 | uint32_t nextCatalogID;
|
---|
609 | uint32_t writeCount;
|
---|
610 | uint64_t encodingsBitmap;
|
---|
611 | uint8_t finderInfo[32];
|
---|
612 | HFSPlusForkData allocationFile;
|
---|
613 | HFSPlusForkData extentsFile;
|
---|
614 | HFSPlusForkData catalogFile;
|
---|
615 | HFSPlusForkData attributesFile;
|
---|
616 | HFSPlusForkData startupFile;
|
---|
617 | } HFSPlusVolumeHeader;
|
---|
618 | AssertCompileMemberAlignment(HFSPlusVolumeHeader, nextCatalogID, 8);
|
---|
619 | AssertCompileSize(HFSPlusVolumeHeader, 512);
|
---|
620 |
|
---|
621 | typedef union BTreeKey
|
---|
622 | {
|
---|
623 | uint8_t length8;
|
---|
624 | uint16_t length16;
|
---|
625 | uint8_t rawData[kMaxKeyLength + 2];
|
---|
626 | } BTreeKey;
|
---|
627 | AssertCompileSize(BTreeKey, 522);
|
---|
628 |
|
---|
629 | #pragma pack(1)
|
---|
630 | typedef struct BTNodeDescriptor
|
---|
631 | {
|
---|
632 | uint32_t fLink;
|
---|
633 | uint32_t bLink;
|
---|
634 | int8_t kind;
|
---|
635 | uint8_t height;
|
---|
636 | uint16_t numRecords;
|
---|
637 | uint16_t reserved; /**< Causes struct size misalignment. */
|
---|
638 | } BTNodeDescriptor;
|
---|
639 | #pragma pack()
|
---|
640 | AssertCompileSize(BTNodeDescriptor, 14);
|
---|
641 |
|
---|
642 | #pragma pack(1)
|
---|
643 | typedef struct BTHeaderRec
|
---|
644 | {
|
---|
645 | uint16_t treeDepth;
|
---|
646 | uint32_t rootNode; /**< Misaligned. */
|
---|
647 | uint32_t leafRecords; /**< Misaligned. */
|
---|
648 | uint32_t firstLeafNode; /**< Misaligned. */
|
---|
649 | uint32_t lastLeafNode; /**< Misaligned. */
|
---|
650 | uint16_t nodeSize;
|
---|
651 | uint16_t maxKeyLength;
|
---|
652 | uint32_t totalNodes; /**< Misaligned. */
|
---|
653 | uint32_t freeNodes; /**< Misaligned. */
|
---|
654 | uint16_t reserved1;
|
---|
655 | uint32_t clumpSize;
|
---|
656 | uint8_t btreeType;
|
---|
657 | uint8_t keyCompareType;
|
---|
658 | uint32_t attributes; /**< Misaligned. */
|
---|
659 | uint32_t reserved3[16]; /**< Misaligned. */
|
---|
660 | } BTHeaderRec;
|
---|
661 | #pragma pack()
|
---|
662 | AssertCompileSize(BTHeaderRec, 106);
|
---|
663 |
|
---|
664 | #pragma pack(1)
|
---|
665 | typedef struct JournalInfoBlock
|
---|
666 | {
|
---|
667 | uint32_t flags;
|
---|
668 | uint32_t devices_signature[8];
|
---|
669 | uint64_t offset; /**< Misaligned (morons). */
|
---|
670 | uint64_t size; /**< Misaligned. */
|
---|
671 | char ext_jnl_uuid[37];
|
---|
672 | char machine_serial_num[48];
|
---|
673 | char reserved[JIB_RESERVED_SIZE];
|
---|
674 | } JournalInfoBlock;
|
---|
675 | #pragma pack()
|
---|
676 | AssertCompileSize(JournalInfoBlock, 180);
|
---|
677 |
|
---|
678 | /** @} */
|
---|
679 |
|
---|
680 | #endif /* !IPRT_INCLUDED_formats_hfs_h */
|
---|
681 |
|
---|