~ubuntu-branches/ubuntu/trusty/hfsprogs/trusty-proposed

« back to all changes in this revision

Viewing changes to debian/patches/0003-Add-helper-include-files-absent-from-the-upstream-pa.patch

  • Committer: Package Import Robot
  • Author(s): Rogério Brito
  • Date: 2013-10-24 01:20:15 UTC
  • Revision ID: package-import@ubuntu.com-20131024012015-qsncxmr4cielybvz
Tags: 332.25-11
* debian/control: Remove DMUA flag.
* debian/rules: Override rules for which we don't have makefiles.
  (Closes: #724195)
* debian/patches:
  + Change the headers to be friendlier with gbp pq.
  + Remove unreferenced patches in series file.
  + Coalesce all patches touching man pages into one.
  + Regenerate everything from patch-queue branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From: =?UTF-8?q?Rog=C3=A9rio=20Brito?= <rbrito@ime.usp.br>
 
2
Date: Thu, 24 Oct 2013 01:11:21 -0200
 
3
Subject: Add helper include files absent from the upstream package
 
4
 
 
5
Add some include files from an Apple system that contain the definition of
 
6
the data structures used by the programs that manipulate the filesystems.
 
7
---
 
8
 include/bitstring.h        | 164 +++++++++++
 
9
 include/hfs/hfs_format.h   | 689 +++++++++++++++++++++++++++++++++++++++++++++
 
10
 include/hfs/hfs_mount.h    |  78 +++++
 
11
 include/sys/appleapiopts.h |  52 ++++
 
12
 4 files changed, 983 insertions(+)
 
13
 create mode 100644 include/bitstring.h
 
14
 create mode 100644 include/hfs/hfs_format.h
 
15
 create mode 100644 include/hfs/hfs_mount.h
 
16
 create mode 100644 include/sys/appleapiopts.h
 
17
 
 
18
diff --git a/include/bitstring.h b/include/bitstring.h
 
19
new file mode 100644
 
20
index 0000000..fbecfbe
 
21
--- /dev/null
 
22
+++ b/include/bitstring.h
 
23
@@ -0,0 +1,164 @@
 
24
+/*
 
25
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
 
26
+ *
 
27
+ * @APPLE_LICENSE_HEADER_START@
 
28
+ *
 
29
+ * The contents of this file constitute Original Code as defined in and
 
30
+ * are subject to the Apple Public Source License Version 1.1 (the
 
31
+ * "License").  You may not use this file except in compliance with the
 
32
+ * License.  Please obtain a copy of the License at
 
33
+ * http://www.apple.com/publicsource and read it before using this file.
 
34
+ *
 
35
+ * This Original Code and all software distributed under the License are
 
36
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 
37
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 
38
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 
39
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
 
40
+ * License for the specific language governing rights and limitations
 
41
+ * under the License.
 
42
+ *
 
43
+ * @APPLE_LICENSE_HEADER_END@
 
44
+ */
 
45
+/*
 
46
+ * Copyright (c) 1989, 1993
 
47
+ *     The Regents of the University of California.  All rights reserved.
 
48
+ *
 
49
+ * This code is derived from software contributed to Berkeley by
 
50
+ * Paul Vixie.
 
51
+ *
 
52
+ * Redistribution and use in source and binary forms, with or without
 
53
+ * modification, are permitted provided that the following conditions
 
54
+ * are met:
 
55
+ * 1. Redistributions of source code must retain the above copyright
 
56
+ *    notice, this list of conditions and the following disclaimer.
 
57
+ * 2. Redistributions in binary form must reproduce the above copyright
 
58
+ *    notice, this list of conditions and the following disclaimer in the
 
59
+ *    documentation and/or other materials provided with the distribution.
 
60
+ * 3. All advertising materials mentioning features or use of this software
 
61
+ *    must display the following acknowledgement:
 
62
+ *     This product includes software developed by the University of
 
63
+ *     California, Berkeley and its contributors.
 
64
+ * 4. Neither the name of the University nor the names of its contributors
 
65
+ *    may be used to endorse or promote products derived from this software
 
66
+ *    without specific prior written permission.
 
67
+ *
 
68
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 
69
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
70
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
71
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 
72
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
73
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
74
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
75
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
76
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
77
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
78
+ * SUCH DAMAGE.
 
79
+ *
 
80
+ *     @(#)bitstring.h 8.1 (Berkeley) 7/19/93
 
81
+ */
 
82
+
 
83
+#ifndef _BITSTRING_H_
 
84
+#define        _BITSTRING_H_
 
85
+
 
86
+typedef        unsigned char bitstr_t;
 
87
+
 
88
+/* internal macros */
 
89
+                               /* byte of the bitstring bit is in */
 
90
+#define        _bit_byte(bit) \
 
91
+       ((bit) >> 3)
 
92
+
 
93
+                               /* mask for the bit within its byte */
 
94
+#define        _bit_mask(bit) \
 
95
+       (1 << ((bit)&0x7))
 
96
+
 
97
+/* external macros */
 
98
+                               /* bytes in a bitstring of nbits bits */
 
99
+#define        bitstr_size(nbits) \
 
100
+       ((((nbits) - 1) >> 3) + 1)
 
101
+
 
102
+                               /* allocate a bitstring */
 
103
+#define        bit_alloc(nbits) \
 
104
+       (bitstr_t *)calloc(1, \
 
105
+           (unsigned int)bitstr_size(nbits) * sizeof(bitstr_t))
 
106
+
 
107
+                               /* allocate a bitstring on the stack */
 
108
+#define        bit_decl(name, nbits) \
 
109
+       (name)[bitstr_size(nbits)]
 
110
+
 
111
+                               /* is bit N of bitstring name set? */
 
112
+#define        bit_test(name, bit) \
 
113
+       ((name)[_bit_byte(bit)] & _bit_mask(bit))
 
114
+
 
115
+                               /* set bit N of bitstring name */
 
116
+#define        bit_set(name, bit) \
 
117
+       (name)[_bit_byte(bit)] |= _bit_mask(bit)
 
118
+
 
119
+                               /* clear bit N of bitstring name */
 
120
+#define        bit_clear(name, bit) \
 
121
+       (name)[_bit_byte(bit)] &= ~_bit_mask(bit)
 
122
+
 
123
+                               /* clear bits start ... stop in bitstring */
 
124
+#define        bit_nclear(name, start, stop) { \
 
125
+       register bitstr_t *_name = name; \
 
126
+       register int _start = start, _stop = stop; \
 
127
+       register int _startbyte = _bit_byte(_start); \
 
128
+       register int _stopbyte = _bit_byte(_stop); \
 
129
+       if (_startbyte == _stopbyte) { \
 
130
+               _name[_startbyte] &= ((0xff >> (8 - (_start&0x7))) | \
 
131
+                                     (0xff << ((_stop&0x7) + 1))); \
 
132
+       } else { \
 
133
+               _name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \
 
134
+               while (++_startbyte < _stopbyte) \
 
135
+                       _name[_startbyte] = 0; \
 
136
+               _name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \
 
137
+       } \
 
138
+}
 
139
+
 
140
+                               /* set bits start ... stop in bitstring */
 
141
+#define        bit_nset(name, start, stop) { \
 
142
+       register bitstr_t *_name = name; \
 
143
+       register int _start = start, _stop = stop; \
 
144
+       register int _startbyte = _bit_byte(_start); \
 
145
+       register int _stopbyte = _bit_byte(_stop); \
 
146
+       if (_startbyte == _stopbyte) { \
 
147
+               _name[_startbyte] |= ((0xff << (_start&0x7)) & \
 
148
+                                   (0xff >> (7 - (_stop&0x7)))); \
 
149
+       } else { \
 
150
+               _name[_startbyte] |= 0xff << ((_start)&0x7); \
 
151
+               while (++_startbyte < _stopbyte) \
 
152
+                       _name[_startbyte] = 0xff; \
 
153
+               _name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \
 
154
+       } \
 
155
+}
 
156
+
 
157
+                               /* find first bit clear in name */
 
158
+#define        bit_ffc(name, nbits, value) { \
 
159
+       register bitstr_t *_name = name; \
 
160
+       register int _byte, _nbits = nbits; \
 
161
+       register int _stopbyte = _bit_byte(_nbits), _value = -1; \
 
162
+       for (_byte = 0; _byte <= _stopbyte; ++_byte) \
 
163
+               if (_name[_byte] != 0xff) { \
 
164
+                       _value = _byte << 3; \
 
165
+                       for (_stopbyte = _name[_byte]; (_stopbyte&0x1); \
 
166
+                           ++_value, _stopbyte >>= 1); \
 
167
+                       break; \
 
168
+               } \
 
169
+       *(value) = _value; \
 
170
+}
 
171
+
 
172
+                               /* find first bit set in name */
 
173
+#define        bit_ffs(name, nbits, value) { \
 
174
+       register bitstr_t *_name = name; \
 
175
+       register int _byte, _nbits = nbits; \
 
176
+       register int _stopbyte = _bit_byte(_nbits), _value = -1; \
 
177
+       for (_byte = 0; _byte <= _stopbyte; ++_byte) \
 
178
+               if (_name[_byte]) { \
 
179
+                       _value = _byte << 3; \
 
180
+                       for (_stopbyte = _name[_byte]; !(_stopbyte&0x1); \
 
181
+                           ++_value, _stopbyte >>= 1); \
 
182
+                       break; \
 
183
+               } \
 
184
+       *(value) = _value; \
 
185
+}
 
186
+
 
187
+#endif /* !_BITSTRING_H_ */
 
188
diff --git a/include/hfs/hfs_format.h b/include/hfs/hfs_format.h
 
189
new file mode 100644
 
190
index 0000000..d820329
 
191
--- /dev/null
 
192
+++ b/include/hfs/hfs_format.h
 
193
@@ -0,0 +1,689 @@
 
194
+/*
 
195
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
 
196
+ *
 
197
+ * @APPLE_LICENSE_HEADER_START@
 
198
+ *
 
199
+ * The contents of this file constitute Original Code as defined in and
 
200
+ * are subject to the Apple Public Source License Version 1.1 (the
 
201
+ * "License").  You may not use this file except in compliance with the
 
202
+ * License.  Please obtain a copy of the License at
 
203
+ * http://www.apple.com/publicsource and read it before using this file.
 
204
+ *
 
205
+ * This Original Code and all software distributed under the License are
 
206
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 
207
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 
208
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 
209
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
 
210
+ * License for the specific language governing rights and limitations
 
211
+ * under the License.
 
212
+ *
 
213
+ * @APPLE_LICENSE_HEADER_END@
 
214
+ */
 
215
+#ifndef __HFS_FORMAT__
 
216
+#define __HFS_FORMAT__
 
217
+
 
218
+#include "missing.h"
 
219
+
 
220
+#include <sys/appleapiopts.h>
 
221
+
 
222
+/*
 
223
+ * hfs_format.c
 
224
+ *
 
225
+ * This file describes the on-disk format for HFS and HFS Plus volumes.
 
226
+ * The HFS Plus volume format is desciibed in detail in Apple Technote 1150.
 
227
+ *
 
228
+ * http://developer.apple.com/technotes/tn/tn1150.html
 
229
+ *
 
230
+ */
 
231
+
 
232
+#ifdef __cplusplus
 
233
+extern "C" {
 
234
+#endif
 
235
+
 
236
+/* some on-disk hfs structures have 68K alignment (misaligned) */
 
237
+
 
238
+#define PACKED_S       __attribute__((packed))
 
239
+
 
240
+/* Signatures used to differentiate between HFS and HFS Plus volumes */
 
241
+enum {
 
242
+       kHFSSigWord             = 0x4244,       /* 'BD' in ASCII */
 
243
+       kHFSPlusSigWord         = 0x482B,       /* 'H+' in ASCII */
 
244
+       kHFSXSigWord            = 0x4858,       /* 'HX' in ASCII */
 
245
+
 
246
+       kHFSPlusVersion         = 0x0004,       /* 'H+' volumes are version 4 only */
 
247
+       kHFSXVersion            = 0x0005,       /* 'HX' volumes start with version 5 */
 
248
+
 
249
+       kHFSPlusMountVersion    = 0x31302E30,   /* '10.0' for Mac OS X */
 
250
+       kHFSJMountVersion       = 0x4846534a,   /* 'HFSJ' for journaled HFS+ on OS X */
 
251
+       kFSKMountVersion        = 0x46534b21    /* 'FSK!' for failed journal replay */
 
252
+}PACKED_S;
 
253
+
 
254
+
 
255
+#if 1
 
256
+/*
 
257
+ * Mac OS X has a special directory for linked and unlinked files (HFS Plus only).
 
258
+ * This directory and its contents are never exported from the filesystem under
 
259
+ * Mac OS X.
 
260
+ *
 
261
+ * To make this folder name sort last,  it has embedded null prefix.
 
262
+ * (0xC0, 0x80 in UTF-8)
 
263
+ */
 
264
+#define HFSPLUSMETADATAFOLDER  "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
 
265
+
 
266
+/*
 
267
+ * Files in the HFS Private Data folder have one of the following prefixes
 
268
+ * followed by a decimal number (no leading zeros).  For indirect nodes this
 
269
+ * number is a 32 bit random number.  For unlinked (deleted) files that are
 
270
+ * still open, the number is the file ID for that file.
 
271
+ *
 
272
+ * e.g.  iNode7182000 and temp3296
 
273
+ */
 
274
+#define HFS_INODE_PREFIX       "iNode"
 
275
+#define HFS_DELETE_PREFIX      "temp"
 
276
+
 
277
+#endif /* __APPLE_API_PRIVATE */
 
278
+
 
279
+/*
 
280
+ * Indirect link files (hard links) have the following type/creator.
 
281
+ */
 
282
+enum {
 
283
+       kHardLinkFileType = 0x686C6E6B,  /* 'hlnk' */
 
284
+       kHFSPlusCreator   = 0x6866732B   /* 'hfs+' */
 
285
+}PACKED_S;
 
286
+
 
287
+
 
288
+#ifndef _HFSUNISTR255_DEFINED_
 
289
+#define _HFSUNISTR255_DEFINED_
 
290
+/* Unicode strings are used for HFS Plus file and folder names */
 
291
+struct HFSUniStr255 {
 
292
+       u_int16_t       length;         /* number of unicode characters */
 
293
+       u_int16_t       unicode[255];   /* unicode characters */
 
294
+} PACKED_S;
 
295
+typedef struct HFSUniStr255 HFSUniStr255;
 
296
+typedef const HFSUniStr255 *ConstHFSUniStr255Param;
 
297
+#endif /* _HFSUNISTR255_DEFINED_ */
 
298
+
 
299
+enum {
 
300
+       kHFSMaxVolumeNameChars          = 27,
 
301
+       kHFSMaxFileNameChars            = 31,
 
302
+       kHFSPlusMaxFileNameChars        = 255
 
303
+}PACKED_S;
 
304
+
 
305
+
 
306
+/* Extent overflow file data structures */
 
307
+
 
308
+/* HFS Extent key */
 
309
+struct HFSExtentKey {
 
310
+       u_int8_t        keyLength;      /* length of key, excluding this field */
 
311
+       u_int8_t        forkType;       /* 0 = data fork, FF = resource fork */
 
312
+       u_int32_t       fileID;         /* file ID */
 
313
+       u_int16_t       startBlock;     /* first file allocation block number in this extent */
 
314
+}PACKED_S;
 
315
+typedef struct HFSExtentKey HFSExtentKey;
 
316
+
 
317
+/* HFS Plus Extent key */
 
318
+struct HFSPlusExtentKey {
 
319
+       u_int16_t       keyLength;              /* length of key, excluding this field */
 
320
+       u_int8_t        forkType;               /* 0 = data fork, FF = resource fork */
 
321
+       u_int8_t        pad;                    /* make the other fields align on 32-bit boundary */
 
322
+       u_int32_t       fileID;                 /* file ID */
 
323
+       u_int32_t       startBlock;             /* first file allocation block number in this extent */
 
324
+}PACKED_S;
 
325
+typedef struct HFSPlusExtentKey HFSPlusExtentKey;
 
326
+
 
327
+/* Number of extent descriptors per extent record */
 
328
+enum {
 
329
+       kHFSExtentDensity       = 3,
 
330
+       kHFSPlusExtentDensity   = 8
 
331
+}PACKED_S;
 
332
+
 
333
+/* HFS extent descriptor */
 
334
+struct HFSExtentDescriptor {
 
335
+       u_int16_t       startBlock;             /* first allocation block */
 
336
+       u_int16_t       blockCount;             /* number of allocation blocks */
 
337
+}PACKED_S;
 
338
+typedef struct HFSExtentDescriptor HFSExtentDescriptor;
 
339
+
 
340
+/* HFS Plus extent descriptor */
 
341
+struct HFSPlusExtentDescriptor {
 
342
+       u_int32_t       startBlock;             /* first allocation block */
 
343
+       u_int32_t       blockCount;             /* number of allocation blocks */
 
344
+}PACKED_S;
 
345
+typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor;
 
346
+
 
347
+/* HFS extent record */
 
348
+typedef HFSExtentDescriptor HFSExtentRecord[3];
 
349
+
 
350
+/* HFS Plus extent record */
 
351
+typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
 
352
+
 
353
+
 
354
+/* Finder information */
 
355
+struct FndrFileInfo {
 
356
+       u_int32_t       fdType;         /* file type */
 
357
+       u_int32_t       fdCreator;      /* file creator */
 
358
+       u_int16_t       fdFlags;        /* Finder flags */
 
359
+       struct {
 
360
+           int16_t     v;              /* file's location */
 
361
+           int16_t     h;
 
362
+       } PACKED_S fdLocation;
 
363
+       int16_t         opaque;
 
364
+}PACKED_S;
 
365
+typedef struct FndrFileInfo FndrFileInfo;
 
366
+
 
367
+struct FndrDirInfo {
 
368
+       struct {                        /* folder's window rectangle */
 
369
+           int16_t     top;
 
370
+           int16_t     left;
 
371
+           int16_t     bottom;
 
372
+           int16_t     right;
 
373
+       }PACKED_S frRect;
 
374
+       unsigned short  frFlags;        /* Finder flags */
 
375
+       struct {
 
376
+           u_int16_t   v;              /* folder's location */
 
377
+           u_int16_t   h;
 
378
+       }PACKED_S frLocation;
 
379
+       int16_t         opaque;
 
380
+}PACKED_S;
 
381
+typedef struct FndrDirInfo FndrDirInfo;
 
382
+
 
383
+struct FndrOpaqueInfo {
 
384
+       int8_t opaque[16];
 
385
+}PACKED_S;
 
386
+typedef struct FndrOpaqueInfo FndrOpaqueInfo;
 
387
+
 
388
+
 
389
+/* HFS Plus Fork data info - 80 bytes */
 
390
+struct HFSPlusForkData {
 
391
+       u_int64_t               logicalSize;    /* fork's logical size in bytes */
 
392
+       u_int32_t               clumpSize;      /* fork's clump size in bytes */
 
393
+       u_int32_t               totalBlocks;    /* total blocks used by this fork */
 
394
+       HFSPlusExtentRecord     extents;        /* initial set of extents */
 
395
+}PACKED_S;
 
396
+typedef struct HFSPlusForkData HFSPlusForkData;
 
397
+
 
398
+
 
399
+/* Mac OS X has 16 bytes worth of "BSD" info.
 
400
+ *
 
401
+ * Note:  Mac OS 9 implementations and applications
 
402
+ * should preserve, but not change, this information.
 
403
+ */
 
404
+struct HFSPlusBSDInfo {
 
405
+       u_int32_t       ownerID;        /* user or group ID of file/folder owner */
 
406
+       u_int32_t       groupID;        /* additional user of group ID */
 
407
+       u_int8_t        adminFlags;     /* super-user changeable flags */
 
408
+       u_int8_t        ownerFlags;     /* owner changeable flags */
 
409
+       u_int16_t       fileMode;       /* file type and permission bits */
 
410
+       union {
 
411
+           u_int32_t   iNodeNum;       /* indirect node number (hard links only) */
 
412
+           u_int32_t   linkCount;      /* links that refer to this indirect node */
 
413
+           u_int32_t   rawDevice;      /* special file device (FBLK and FCHR only) */
 
414
+       }PACKED_S special;
 
415
+}PACKED_S;
 
416
+typedef struct HFSPlusBSDInfo HFSPlusBSDInfo;
 
417
+
 
418
+
 
419
+/* Catalog file data structures */
 
420
+
 
421
+enum {
 
422
+       kHFSRootParentID                = 1,    /* Parent ID of the root folder */
 
423
+       kHFSRootFolderID                = 2,    /* Folder ID of the root folder */
 
424
+       kHFSExtentsFileID               = 3,    /* File ID of the extents file */
 
425
+       kHFSCatalogFileID               = 4,    /* File ID of the catalog file */
 
426
+       kHFSBadBlockFileID              = 5,    /* File ID of the bad allocation block file */
 
427
+       kHFSAllocationFileID            = 6,    /* File ID of the allocation file (HFS Plus only) */
 
428
+       kHFSStartupFileID               = 7,    /* File ID of the startup file (HFS Plus only) */
 
429
+       kHFSAttributesFileID            = 8,    /* File ID of the attribute file (HFS Plus only) */
 
430
+       kHFSRepairCatalogFileID         = 14,   /* Used when rebuilding Catalog B-tree */
 
431
+       kHFSBogusExtentFileID           = 15,   /* Used for exchanging extents in extents file */
 
432
+       kHFSFirstUserCatalogNodeID      = 16
 
433
+}PACKED_S;
 
434
+
 
435
+/* HFS catalog key */
 
436
+struct HFSCatalogKey {
 
437
+       u_int8_t        keyLength;              /* key length (in bytes) */
 
438
+       u_int8_t        reserved;               /* reserved (set to zero) */
 
439
+       u_int32_t       parentID;               /* parent folder ID */
 
440
+       u_int8_t        nodeName[kHFSMaxFileNameChars + 1]; /* catalog node name */
 
441
+}PACKED_S;
 
442
+typedef struct HFSCatalogKey HFSCatalogKey;
 
443
+
 
444
+/* HFS Plus catalog key */
 
445
+struct HFSPlusCatalogKey {
 
446
+       u_int16_t               keyLength;      /* key length (in bytes) */
 
447
+       u_int32_t               parentID;       /* parent folder ID */
 
448
+       HFSUniStr255            nodeName;       /* catalog node name */
 
449
+}PACKED_S;
 
450
+typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
 
451
+
 
452
+/* Catalog record types */
 
453
+enum {
 
454
+       /* HFS Catalog Records */
 
455
+       kHFSFolderRecord                = 0x0100,       /* Folder record */
 
456
+       kHFSFileRecord                  = 0x0200,       /* File record */
 
457
+       kHFSFolderThreadRecord          = 0x0300,       /* Folder thread record */
 
458
+       kHFSFileThreadRecord            = 0x0400,       /* File thread record */
 
459
+
 
460
+       /* HFS Plus Catalog Records */
 
461
+       kHFSPlusFolderRecord            = 1,            /* Folder record */
 
462
+       kHFSPlusFileRecord              = 2,            /* File record */
 
463
+       kHFSPlusFolderThreadRecord      = 3,            /* Folder thread record */
 
464
+       kHFSPlusFileThreadRecord        = 4             /* File thread record */
 
465
+}PACKED_S;
 
466
+
 
467
+
 
468
+/* Catalog file record flags */
 
469
+enum {
 
470
+       kHFSFileLockedBit       = 0x0000,       /* file is locked and cannot be written to */
 
471
+       kHFSFileLockedMask      = 0x0001,
 
472
+
 
473
+       kHFSThreadExistsBit     = 0x0001,       /* a file thread record exists for this file */
 
474
+       kHFSThreadExistsMask    = 0x0002,
 
475
+
 
476
+       kHFSHasAttributesBit    = 0x0002,       /* object has extended attributes */
 
477
+       kHFSHasAttributesMask   = 0x0004,
 
478
+
 
479
+       kHFSHasSecurityBit      = 0x0003,       /* object has security data (ACLs) */
 
480
+       kHFSHasSecurityMask     = 0x0008
 
481
+}PACKED_S;
 
482
+
 
483
+
 
484
+/* HFS catalog folder record - 70 bytes */
 
485
+struct HFSCatalogFolder {
 
486
+       int16_t                 recordType;             /* == kHFSFolderRecord */
 
487
+       u_int16_t               flags;                  /* folder flags */
 
488
+       u_int16_t               valence;                /* folder valence */
 
489
+       u_int32_t               folderID;               /* folder ID */
 
490
+       u_int32_t               createDate;             /* date and time of creation */
 
491
+       u_int32_t               modifyDate;             /* date and time of last modification */
 
492
+       u_int32_t               backupDate;             /* date and time of last backup */
 
493
+       FndrDirInfo             userInfo;               /* Finder information */
 
494
+       FndrOpaqueInfo          finderInfo;             /* additional Finder information */
 
495
+       u_int32_t               reserved[4];            /* reserved - initialized as zero */
 
496
+}PACKED_S;
 
497
+typedef struct HFSCatalogFolder HFSCatalogFolder;
 
498
+
 
499
+/* HFS Plus catalog folder record - 88 bytes */
 
500
+struct HFSPlusCatalogFolder {
 
501
+       int16_t                 recordType;             /* == kHFSPlusFolderRecord */
 
502
+       u_int16_t               flags;                  /* file flags */
 
503
+       u_int32_t               valence;                /* folder's valence (limited to 2^16 in Mac OS) */
 
504
+       u_int32_t               folderID;               /* folder ID */
 
505
+       u_int32_t               createDate;             /* date and time of creation */
 
506
+       u_int32_t               contentModDate;         /* date and time of last content modification */
 
507
+       u_int32_t               attributeModDate;       /* date and time of last attribute modification */
 
508
+       u_int32_t               accessDate;             /* date and time of last access (MacOS X only) */
 
509
+       u_int32_t               backupDate;             /* date and time of last backup */
 
510
+       HFSPlusBSDInfo          bsdInfo;                /* permissions (for MacOS X) */
 
511
+       FndrDirInfo             userInfo;               /* Finder information */
 
512
+       FndrOpaqueInfo          finderInfo;             /* additional Finder information */
 
513
+       u_int32_t               textEncoding;           /* hint for name conversions */
 
514
+       u_int32_t               attrBlocks;             /* cached count of attribute data blocks */
 
515
+}PACKED_S;
 
516
+typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder;
 
517
+
 
518
+/* HFS catalog file record - 102 bytes */
 
519
+struct HFSCatalogFile {
 
520
+       int16_t                 recordType;             /* == kHFSFileRecord */
 
521
+       u_int8_t                flags;                  /* file flags */
 
522
+       int8_t                  fileType;               /* file type (unused ?) */
 
523
+       FndrFileInfo            userInfo;               /* Finder information */
 
524
+       u_int32_t               fileID;                 /* file ID */
 
525
+       u_int16_t               dataStartBlock;         /* not used - set to zero */
 
526
+       int32_t                 dataLogicalSize;        /* logical EOF of data fork */
 
527
+       int32_t                 dataPhysicalSize;       /* physical EOF of data fork */
 
528
+       u_int16_t               rsrcStartBlock;         /* not used - set to zero */
 
529
+       int32_t                 rsrcLogicalSize;        /* logical EOF of resource fork */
 
530
+       int32_t                 rsrcPhysicalSize;       /* physical EOF of resource fork */
 
531
+       u_int32_t               createDate;             /* date and time of creation */
 
532
+       u_int32_t               modifyDate;             /* date and time of last modification */
 
533
+       u_int32_t               backupDate;             /* date and time of last backup */
 
534
+       FndrOpaqueInfo          finderInfo;             /* additional Finder information */
 
535
+       u_int16_t               clumpSize;              /* file clump size (not used) */
 
536
+       HFSExtentRecord         dataExtents;            /* first data fork extent record */
 
537
+       HFSExtentRecord         rsrcExtents;            /* first resource fork extent record */
 
538
+       u_int32_t               reserved;               /* reserved - initialized as zero */
 
539
+}PACKED_S;
 
540
+typedef struct HFSCatalogFile HFSCatalogFile;
 
541
+
 
542
+/* HFS Plus catalog file record - 248 bytes */
 
543
+struct HFSPlusCatalogFile {
 
544
+       int16_t                 recordType;             /* == kHFSPlusFileRecord */
 
545
+       u_int16_t               flags;                  /* file flags */
 
546
+       u_int32_t               reserved1;              /* reserved - initialized as zero */
 
547
+       u_int32_t               fileID;                 /* file ID */
 
548
+       u_int32_t               createDate;             /* date and time of creation */
 
549
+       u_int32_t               contentModDate;         /* date and time of last content modification */
 
550
+       u_int32_t               attributeModDate;       /* date and time of last attribute modification */
 
551
+       u_int32_t               accessDate;             /* date and time of last access (MacOS X only) */
 
552
+       u_int32_t               backupDate;             /* date and time of last backup */
 
553
+       HFSPlusBSDInfo          bsdInfo;                /* permissions (for MacOS X) */
 
554
+       FndrFileInfo            userInfo;               /* Finder information */
 
555
+       FndrOpaqueInfo          finderInfo;             /* additional Finder information */
 
556
+       u_int32_t               textEncoding;           /* hint for name conversions */
 
557
+       u_int32_t               attrBlocks;             /* cached count of attribute data blocks */
 
558
+
 
559
+       /* Note: these start on double long (64 bit) boundry */
 
560
+       HFSPlusForkData         dataFork;               /* size and block data for data fork */
 
561
+       HFSPlusForkData         resourceFork;           /* size and block data for resource fork */
 
562
+}PACKED_S;
 
563
+typedef struct HFSPlusCatalogFile HFSPlusCatalogFile;
 
564
+
 
565
+/* HFS catalog thread record - 46 bytes */
 
566
+struct HFSCatalogThread {
 
567
+       int16_t         recordType;             /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */
 
568
+       int32_t         reserved[2];            /* reserved - initialized as zero */
 
569
+       u_int32_t       parentID;               /* parent ID for this catalog node */
 
570
+       u_int8_t        nodeName[kHFSMaxFileNameChars + 1]; /* name of this catalog node */
 
571
+}PACKED_S;
 
572
+typedef struct HFSCatalogThread HFSCatalogThread;
 
573
+
 
574
+/* HFS Plus catalog thread record -- 264 bytes */
 
575
+struct HFSPlusCatalogThread {
 
576
+       int16_t         recordType;             /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
 
577
+       int16_t         reserved;               /* reserved - initialized as zero */
 
578
+       u_int32_t       parentID;               /* parent ID for this catalog node */
 
579
+       HFSUniStr255    nodeName;               /* name of this catalog node (variable length) */
 
580
+}PACKED_S;
 
581
+typedef struct HFSPlusCatalogThread HFSPlusCatalogThread;
 
582
+
 
583
+#ifdef __APPLE_API_UNSTABLE
 
584
+/*
 
585
+       These are the types of records in the attribute B-tree.  The values were
 
586
+       chosen so that they wouldn't conflict with the catalog record types.
 
587
+*/
 
588
+enum {
 
589
+       kHFSPlusAttrInlineData  = 0x10,    /* if size <  kAttrOverflowSize */
 
590
+       kHFSPlusAttrForkData    = 0x20,    /* if size >= kAttrOverflowSize */
 
591
+       kHFSPlusAttrExtents     = 0x30     /* overflow extents for large attributes */
 
592
+}PACKED_S;
 
593
+
 
594
+
 
595
+/*
 
596
+       HFSPlusAttrForkData
 
597
+       For larger attributes, whose value is stored in allocation blocks.
 
598
+       If the attribute has more than 8 extents, there will be additonal
 
599
+       records (of type HFSPlusAttrExtents) for this attribute.
 
600
+*/
 
601
+struct HFSPlusAttrForkData {
 
602
+       u_int32_t       recordType;             /* == kHFSPlusAttrForkData*/
 
603
+       u_int32_t       reserved;
 
604
+       HFSPlusForkData theFork;                /* size and first extents of value*/
 
605
+}PACKED_S;
 
606
+typedef struct HFSPlusAttrForkData HFSPlusAttrForkData;
 
607
+
 
608
+/*
 
609
+       HFSPlusAttrExtents
 
610
+       This record contains information about overflow extents for large,
 
611
+       fragmented attributes.
 
612
+*/
 
613
+struct HFSPlusAttrExtents {
 
614
+       u_int32_t               recordType;     /* == kHFSPlusAttrExtents*/
 
615
+       u_int32_t               reserved;
 
616
+       HFSPlusExtentRecord     extents;        /* additional extents*/
 
617
+}PACKED_S;
 
618
+typedef struct HFSPlusAttrExtents HFSPlusAttrExtents;
 
619
+
 
620
+/*
 
621
+ * Atrributes B-tree Data Record
 
622
+ *
 
623
+ * For small attributes, whose entire value is stored
 
624
+ * within a single B-tree record.
 
625
+ */
 
626
+struct HFSPlusAttrData {
 
627
+       u_int32_t    recordType;   /* == kHFSPlusAttrInlineData */
 
628
+       u_int32_t    reserved[2];
 
629
+       u_int32_t    attrSize;     /* size of attribute data in bytes */
 
630
+       u_int8_t     attrData[2];  /* variable length */
 
631
+}PACKED_S;
 
632
+typedef struct HFSPlusAttrData HFSPlusAttrData;
 
633
+
 
634
+
 
635
+/* HFSPlusAttrInlineData is obsolete use HFSPlusAttrData instead */
 
636
+struct HFSPlusAttrInlineData {
 
637
+       u_int32_t       recordType;
 
638
+       u_int32_t       reserved;
 
639
+       u_int32_t       logicalSize;
 
640
+       u_int8_t        userData[2];
 
641
+}PACKED_S;
 
642
+typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData;
 
643
+
 
644
+
 
645
+/*     A generic Attribute Record*/
 
646
+union HFSPlusAttrRecord {
 
647
+       u_int32_t               recordType;
 
648
+       HFSPlusAttrInlineData   inlineData;   /* NOT USED */
 
649
+       HFSPlusAttrData         attrData;
 
650
+       HFSPlusAttrForkData     forkData;
 
651
+       HFSPlusAttrExtents      overflowExtents;
 
652
+}PACKED_S;
 
653
+typedef union HFSPlusAttrRecord HFSPlusAttrRecord;
 
654
+
 
655
+/* Attribute key */
 
656
+enum { kHFSMaxAttrNameLen = 127 };
 
657
+struct HFSPlusAttrKey {
 
658
+       u_int16_t     keyLength;       /* key length (in bytes) */
 
659
+       u_int16_t     pad;             /* set to zero */
 
660
+       u_int32_t     fileID;          /* file associated with attribute */
 
661
+       u_int32_t     startBlock;      /* first attribue allocation block number for extents */
 
662
+       u_int16_t     attrNameLen;     /* number of unicode characters */
 
663
+       u_int16_t     attrName[127];   /* attribute name (Unicode) */
 
664
+}PACKED_S;
 
665
+typedef struct HFSPlusAttrKey HFSPlusAttrKey;
 
666
+
 
667
+#define kHFSPlusAttrKeyMaximumLength   (sizeof(HFSPlusAttrKey) - sizeof(u_int16_t))
 
668
+#define kHFSPlusAttrKeyMinimumLength   (kHFSPlusAttrKeyMaximumLength - (127 * sizeof(u_int16_t)))
 
669
+
 
670
+#endif /* __APPLE_API_UNSTABLE */
 
671
+
 
672
+
 
673
+/* Key and node lengths */
 
674
+enum {
 
675
+       kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(u_int16_t),
 
676
+       kHFSExtentKeyMaximumLength      = sizeof(HFSExtentKey) - sizeof(u_int8_t),
 
677
+       kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(u_int16_t),
 
678
+       kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(u_int16_t),
 
679
+       kHFSCatalogKeyMaximumLength     = sizeof(HFSCatalogKey) - sizeof(u_int8_t),
 
680
+       kHFSCatalogKeyMinimumLength     = kHFSCatalogKeyMaximumLength - (kHFSMaxFileNameChars + 1) + sizeof(u_int8_t),
 
681
+       kHFSPlusCatalogMinNodeSize      = 4096,
 
682
+       kHFSPlusExtentMinNodeSize       = 512,
 
683
+       kHFSPlusAttrMinNodeSize         = 4096
 
684
+}PACKED_S;
 
685
+
 
686
+/* HFS and HFS Plus volume attribute bits */
 
687
+enum {
 
688
+                                                       /* Bits 0-6 are reserved (always cleared by MountVol call) */
 
689
+       kHFSVolumeHardwareLockBit       = 7,            /* volume is locked by hardware */
 
690
+       kHFSVolumeUnmountedBit          = 8,            /* volume was successfully unmounted */
 
691
+       kHFSVolumeSparedBlocksBit       = 9,            /* volume has bad blocks spared */
 
692
+       kHFSVolumeNoCacheRequiredBit = 10,              /* don't cache volume blocks (i.e. RAM or ROM disk) */
 
693
+       kHFSBootVolumeInconsistentBit = 11,             /* boot volume is inconsistent (System 7.6 and later) */
 
694
+       kHFSCatalogNodeIDsReusedBit = 12,
 
695
+       kHFSVolumeJournaledBit = 13,                    /* this volume has a journal on it */
 
696
+       kHFSVolumeInconsistentBit = 14,                 /* serious inconsistencies detected at runtime */
 
697
+       kHFSVolumeSoftwareLockBit       = 15,           /* volume is locked by software */
 
698
+
 
699
+       kHFSVolumeHardwareLockMask      = 1 << kHFSVolumeHardwareLockBit,
 
700
+       kHFSVolumeUnmountedMask         = 1 << kHFSVolumeUnmountedBit,
 
701
+       kHFSVolumeSparedBlocksMask      = 1 << kHFSVolumeSparedBlocksBit,
 
702
+       kHFSVolumeNoCacheRequiredMask = 1 << kHFSVolumeNoCacheRequiredBit,
 
703
+       kHFSBootVolumeInconsistentMask = 1 << kHFSBootVolumeInconsistentBit,
 
704
+       kHFSCatalogNodeIDsReusedMask = 1 << kHFSCatalogNodeIDsReusedBit,
 
705
+       kHFSVolumeJournaledMask = 1 << kHFSVolumeJournaledBit,
 
706
+       kHFSVolumeInconsistentMask = 1 << kHFSVolumeInconsistentBit,
 
707
+       kHFSVolumeSoftwareLockMask      = 1 << kHFSVolumeSoftwareLockBit,
 
708
+       kHFSMDBAttributesMask           = 0x8380
 
709
+}PACKED_S;
 
710
+
 
711
+
 
712
+/* HFS Master Directory Block - 162 bytes */
 
713
+/* Stored at sector #2 (3rd sector) and second-to-last sector. */
 
714
+struct HFSMasterDirectoryBlock {
 
715
+       u_int16_t               drSigWord;      /* == kHFSSigWord */
 
716
+       u_int32_t               drCrDate;       /* date and time of volume creation */
 
717
+       u_int32_t               drLsMod;        /* date and time of last modification */
 
718
+       u_int16_t               drAtrb;         /* volume attributes */
 
719
+       u_int16_t               drNmFls;        /* number of files in root folder */
 
720
+       u_int16_t               drVBMSt;        /* first block of volume bitmap */
 
721
+       u_int16_t               drAllocPtr;     /* start of next allocation search */
 
722
+       u_int16_t               drNmAlBlks;     /* number of allocation blocks in volume */
 
723
+       u_int32_t               drAlBlkSiz;     /* size (in bytes) of allocation blocks */
 
724
+       u_int32_t               drClpSiz;       /* default clump size */
 
725
+       u_int16_t               drAlBlSt;       /* first allocation block in volume */
 
726
+       u_int32_t               drNxtCNID;      /* next unused catalog node ID */
 
727
+       u_int16_t               drFreeBks;      /* number of unused allocation blocks */
 
728
+       u_int8_t                drVN[kHFSMaxVolumeNameChars + 1];  /* volume name */
 
729
+       u_int32_t               drVolBkUp;      /* date and time of last backup */
 
730
+       u_int16_t               drVSeqNum;      /* volume backup sequence number */
 
731
+       u_int32_t               drWrCnt;        /* volume write count */
 
732
+       u_int32_t               drXTClpSiz;     /* clump size for extents overflow file */
 
733
+       u_int32_t               drCTClpSiz;     /* clump size for catalog file */
 
734
+       u_int16_t               drNmRtDirs;     /* number of directories in root folder */
 
735
+       u_int32_t               drFilCnt;       /* number of files in volume */
 
736
+       u_int32_t               drDirCnt;       /* number of directories in volume */
 
737
+       u_int32_t               drFndrInfo[8];  /* information used by the Finder */
 
738
+       u_int16_t               drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */
 
739
+       HFSExtentDescriptor     drEmbedExtent;  /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
 
740
+       u_int32_t               drXTFlSize;     /* size of extents overflow file */
 
741
+       HFSExtentRecord         drXTExtRec;     /* extent record for extents overflow file */
 
742
+       u_int32_t               drCTFlSize;     /* size of catalog file */
 
743
+       HFSExtentRecord         drCTExtRec;     /* extent record for catalog file */
 
744
+}PACKED_S;
 
745
+typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock;
 
746
+
 
747
+
 
748
+#ifdef __APPLE_API_UNSTABLE
 
749
+#define SET_HFS_TEXT_ENCODING(hint)  \
 
750
+       (0x656e6300 | ((hint) & 0xff))
 
751
+#define GET_HFS_TEXT_ENCODING(hint)  \
 
752
+       (((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU)
 
753
+#endif /* __APPLE_API_UNSTABLE */
 
754
+
 
755
+
 
756
+/* HFS Plus Volume Header - 512 bytes */
 
757
+/* Stored at sector #2 (3rd sector) and second-to-last sector. */
 
758
+struct HFSPlusVolumeHeader {
 
759
+       u_int16_t       signature;              /* == kHFSPlusSigWord */
 
760
+       u_int16_t       version;                /* == kHFSPlusVersion */
 
761
+       u_int32_t       attributes;             /* volume attributes */
 
762
+       u_int32_t       lastMountedVersion;     /* implementation version which last mounted volume */
 
763
+       u_int32_t       journalInfoBlock;       /* block addr of journal info (if volume is journaled, zero otherwise) */
 
764
+
 
765
+       u_int32_t       createDate;             /* date and time of volume creation */
 
766
+       u_int32_t       modifyDate;             /* date and time of last modification */
 
767
+       u_int32_t       backupDate;             /* date and time of last backup */
 
768
+       u_int32_t       checkedDate;            /* date and time of last disk check */
 
769
+
 
770
+       u_int32_t       fileCount;              /* number of files in volume */
 
771
+       u_int32_t       folderCount;            /* number of directories in volume */
 
772
+
 
773
+       u_int32_t       blockSize;              /* size (in bytes) of allocation blocks */
 
774
+       u_int32_t       totalBlocks;            /* number of allocation blocks in volume (includes this header and VBM*/
 
775
+       u_int32_t       freeBlocks;             /* number of unused allocation blocks */
 
776
+
 
777
+       u_int32_t       nextAllocation;         /* start of next allocation search */
 
778
+       u_int32_t       rsrcClumpSize;          /* default resource fork clump size */
 
779
+       u_int32_t       dataClumpSize;          /* default data fork clump size */
 
780
+       u_int32_t       nextCatalogID;          /* next unused catalog node ID */
 
781
+
 
782
+       u_int32_t       writeCount;             /* volume write count */
 
783
+       u_int64_t       encodingsBitmap;        /* which encodings have been use  on this volume */
 
784
+
 
785
+       u_int8_t        finderInfo[32];         /* information used by the Finder */
 
786
+
 
787
+       HFSPlusForkData  allocationFile;        /* allocation bitmap file */
 
788
+       HFSPlusForkData  extentsFile;           /* extents B-tree file */
 
789
+       HFSPlusForkData  catalogFile;           /* catalog B-tree file */
 
790
+       HFSPlusForkData  attributesFile;        /* extended attributes B-tree file */
 
791
+       HFSPlusForkData  startupFile;           /* boot file (secondary loader) */
 
792
+}PACKED_S;
 
793
+typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader;
 
794
+
 
795
+
 
796
+/* B-tree structures */
 
797
+
 
798
+enum BTreeKeyLimits{
 
799
+       kMaxKeyLength   = 520
 
800
+}PACKED_S;
 
801
+
 
802
+union BTreeKey{
 
803
+       u_int8_t        length8;
 
804
+       u_int16_t       length16;
 
805
+       u_int8_t        rawData [kMaxKeyLength+2];
 
806
+}PACKED_S;
 
807
+typedef union BTreeKey BTreeKey;
 
808
+
 
809
+/* BTNodeDescriptor -- Every B-tree node starts with these fields. */
 
810
+struct BTNodeDescriptor {
 
811
+       u_int32_t       fLink;                  /* next node at this level*/
 
812
+       u_int32_t       bLink;                  /* previous node at this level*/
 
813
+       int8_t          kind;                   /* kind of node (leaf, index, header, map)*/
 
814
+       u_int8_t        height;                 /* zero for header, map; child is one more than parent*/
 
815
+       u_int16_t       numRecords;             /* number of records in this node*/
 
816
+       u_int16_t       reserved;               /* reserved - initialized as zero */
 
817
+}PACKED_S;
 
818
+typedef struct BTNodeDescriptor BTNodeDescriptor;
 
819
+
 
820
+/* Constants for BTNodeDescriptor kind */
 
821
+enum {
 
822
+       kBTLeafNode     = -1,
 
823
+       kBTIndexNode    = 0,
 
824
+       kBTHeaderNode   = 1,
 
825
+       kBTMapNode      = 2
 
826
+}PACKED_S;
 
827
+
 
828
+/* BTHeaderRec -- The first record of a B-tree header node */
 
829
+struct BTHeaderRec {
 
830
+       u_int16_t       treeDepth;              /* maximum height (usually leaf nodes) */
 
831
+       u_int32_t       rootNode;               /* node number of root node */
 
832
+       u_int32_t       leafRecords;            /* number of leaf records in all leaf nodes */
 
833
+       u_int32_t       firstLeafNode;          /* node number of first leaf node */
 
834
+       u_int32_t       lastLeafNode;           /* node number of last leaf node */
 
835
+       u_int16_t       nodeSize;               /* size of a node, in bytes */
 
836
+       u_int16_t       maxKeyLength;           /* reserved */
 
837
+       u_int32_t       totalNodes;             /* total number of nodes in tree */
 
838
+       u_int32_t       freeNodes;              /* number of unused (free) nodes in tree */
 
839
+       u_int16_t       reserved1;              /* unused */
 
840
+       u_int32_t       clumpSize;              /* reserved */
 
841
+       u_int8_t        btreeType;              /* reserved */
 
842
+       u_int8_t        keyCompareType;         /* Key string Comparison Type */
 
843
+       u_int32_t       attributes;             /* persistent attributes about the tree */
 
844
+       u_int32_t       reserved3[16];          /* reserved */
 
845
+}PACKED_S;
 
846
+typedef struct BTHeaderRec BTHeaderRec;
 
847
+
 
848
+/* Constants for BTHeaderRec attributes */
 
849
+enum {
 
850
+       kBTBadCloseMask          = 0x00000001,  /* reserved */
 
851
+       kBTBigKeysMask           = 0x00000002,  /* key length field is 16 bits */
 
852
+       kBTVariableIndexKeysMask = 0x00000004   /* keys in index nodes are variable length */
 
853
+}PACKED_S;
 
854
+
 
855
+
 
856
+/* Catalog Key Name Comparison Type */
 
857
+enum {
 
858
+       kHFSCaseFolding   = 0xCF,  /* case folding (case-insensitive) */
 
859
+       kHFSBinaryCompare = 0xBC  /* binary compare (case-sensitive) */
 
860
+}PACKED_S;
 
861
+
 
862
+/* JournalInfoBlock - Structure that describes where our journal lives */
 
863
+struct JournalInfoBlock {
 
864
+       u_int32_t       flags;
 
865
+       u_int32_t       device_signature[8];  // signature used to locate our device.
 
866
+       u_int64_t       offset;               // byte offset to the journal on the device
 
867
+       u_int64_t       size;                 // size in bytes of the journal
 
868
+       u_int32_t       reserved[32];
 
869
+}PACKED_S;
 
870
+typedef struct JournalInfoBlock JournalInfoBlock;
 
871
+
 
872
+enum {
 
873
+    kJIJournalInFSMask          = 0x00000001,
 
874
+    kJIJournalOnOtherDeviceMask = 0x00000002,
 
875
+    kJIJournalNeedInitMask      = 0x00000004
 
876
+}PACKED_S;
 
877
+
 
878
+#ifdef __cplusplus
 
879
+}
 
880
+#endif
 
881
+
 
882
+#endif /* __HFS_FORMAT__ */
 
883
diff --git a/include/hfs/hfs_mount.h b/include/hfs/hfs_mount.h
 
884
new file mode 100644
 
885
index 0000000..ad729f2
 
886
--- /dev/null
 
887
+++ b/include/hfs/hfs_mount.h
 
888
@@ -0,0 +1,78 @@
 
889
+/*
 
890
+ * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
 
891
+ *
 
892
+ * @APPLE_LICENSE_HEADER_START@
 
893
+ *
 
894
+ * The contents of this file constitute Original Code as defined in and
 
895
+ * are subject to the Apple Public Source License Version 1.1 (the
 
896
+ * "License").  You may not use this file except in compliance with the
 
897
+ * License.  Please obtain a copy of the License at
 
898
+ * http://www.apple.com/publicsource and read it before using this file.
 
899
+ *
 
900
+ * This Original Code and all software distributed under the License are
 
901
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 
902
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 
903
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 
904
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
 
905
+ * License for the specific language governing rights and limitations
 
906
+ * under the License.
 
907
+ *
 
908
+ * @APPLE_LICENSE_HEADER_END@
 
909
+ */
 
910
+/*
 
911
+ * Copyright (c) 1997-2002 Apple Computer, Inc. All Rights Reserved
 
912
+ *
 
913
+ */
 
914
+
 
915
+#ifndef _HFS_MOUNT_H_
 
916
+#define _HFS_MOUNT_H_
 
917
+
 
918
+#include <sys/appleapiopts.h>
 
919
+
 
920
+#include <sys/mount.h>
 
921
+#include <sys/time.h>
 
922
+
 
923
+/*
 
924
+ * Arguments to mount HFS-based filesystems
 
925
+ */
 
926
+
 
927
+#define OVERRIDE_UNKNOWN_PERMISSIONS 0
 
928
+
 
929
+#define UNKNOWNUID ((uid_t)99)
 
930
+#define UNKNOWNGID ((gid_t)99)
 
931
+#define UNKNOWNPERMISSIONS (S_IRWXU | S_IROTH | S_IXOTH)               /* 705 */
 
932
+
 
933
+#ifdef __APPLE_API_UNSTABLE
 
934
+struct hfs_mount_args {
 
935
+#ifndef KERNEL
 
936
+       char    *fspec;                 /* block special device to mount */
 
937
+#endif
 
938
+       uid_t   hfs_uid;                /* uid that owns hfs files (standard HFS only) */
 
939
+       gid_t   hfs_gid;                /* gid that owns hfs files (standard HFS only) */
 
940
+       mode_t  hfs_mask;               /* mask to be applied for hfs perms  (standard HFS only) */
 
941
+       u_int32_t hfs_encoding;         /* encoding for this volume (standard HFS only) */
 
942
+       struct  timezone hfs_timezone;  /* user time zone info (standard HFS only) */
 
943
+       int             flags;                  /* mounting flags, see below */
 
944
+       int     journal_tbuffer_size;   /* size in bytes of the journal transaction buffer */
 
945
+       int             journal_flags;          /* flags to pass to journal_open/create */
 
946
+       int             journal_disable;        /* don't use journaling (potentially dangerous) */
 
947
+};
 
948
+
 
949
+#define HFSFSMNT_NOXONFILES    0x1     /* disable execute permissions for files */
 
950
+#define HFSFSMNT_WRAPPER       0x2     /* mount HFS wrapper (if it exists) */
 
951
+#define HFSFSMNT_EXTENDED_ARGS  0x4     /* indicates new fields after "flags" are valid */
 
952
+
 
953
+/*
 
954
+ * Sysctl values for HFS
 
955
+ */
 
956
+#define HFS_ENCODINGBIAS       1           /* encoding matching CJK bias */
 
957
+#define HFS_EXTEND_FS          2
 
958
+#define HFS_ENCODINGHINT       3           /* guess encoding for string */
 
959
+#define HFS_ENABLE_JOURNALING   0x082969
 
960
+#define HFS_DISABLE_JOURNALING  0x031272
 
961
+#define HFS_GET_JOURNAL_INFO    0x6a6e6c69
 
962
+#define HFS_SET_PKG_EXTENSIONS  0x121031
 
963
+
 
964
+#endif /* __APPLE_API_UNSTABLE */
 
965
+
 
966
+#endif /* ! _HFS_MOUNT_H_ */
 
967
diff --git a/include/sys/appleapiopts.h b/include/sys/appleapiopts.h
 
968
new file mode 100644
 
969
index 0000000..4d2061f
 
970
--- /dev/null
 
971
+++ b/include/sys/appleapiopts.h
 
972
@@ -0,0 +1,52 @@
 
973
+/*
 
974
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 
975
+ *
 
976
+ * @APPLE_LICENSE_HEADER_START@
 
977
+ *
 
978
+ * The contents of this file constitute Original Code as defined in and
 
979
+ * are subject to the Apple Public Source License Version 1.1 (the
 
980
+ * "License").  You may not use this file except in compliance with the
 
981
+ * License.  Please obtain a copy of the License at
 
982
+ * http://www.apple.com/publicsource and read it before using this file.
 
983
+ *
 
984
+ * This Original Code and all software distributed under the License are
 
985
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 
986
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 
987
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 
988
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
 
989
+ * License for the specific language governing rights and limitations
 
990
+ * under the License.
 
991
+ *
 
992
+ * @APPLE_LICENSE_HEADER_END@
 
993
+ */
 
994
+
 
995
+#ifndef __SYS_APPLEAPIOPTS_H__
 
996
+#define __SYS_APPLEAPIOPTS_H__
 
997
+
 
998
+
 
999
+#ifndef __APPLE_API_STANDARD
 
1000
+#define __APPLE_API_STANDARD
 
1001
+#endif /* __APPLE_API_STANDARD */
 
1002
+
 
1003
+#ifndef __APPLE_API_STABLE
 
1004
+#define __APPLE_API_STABLE
 
1005
+#endif /* __APPLE_API_STABLE */
 
1006
+
 
1007
+#ifndef __APPLE_API_STRICT_CONFORMANCE
 
1008
+
 
1009
+#ifndef __APPLE_API_EVOLVING
 
1010
+#define __APPLE_API_EVOLVING
 
1011
+#endif /* __APPLE_API_EVOLVING */
 
1012
+
 
1013
+#ifndef __APPLE_API_UNSTABLE
 
1014
+#define __APPLE_API_UNSTABLE
 
1015
+#endif /* __APPLE_API_UNSTABLE */
 
1016
+
 
1017
+#ifndef __APPLE_API_OBSOLETE
 
1018
+#define __APPLE_API_OBSOLETE
 
1019
+#endif /* __APPLE_API_OBSOLETE */
 
1020
+
 
1021
+#endif /* __APPLE_API_STRICT_CONFORMANCE */
 
1022
+
 
1023
+#endif /* __SYS_APPLEAPIOPTS_H__ */
 
1024
+