~ubuntu-branches/ubuntu/hardy/hfsprogs/hardy

« back to all changes in this revision

Viewing changes to debian/patches/diskdev_cmds-332.14.patch

  • Committer: Bazaar Package Importer
  • Author(s): Rogério Brito
  • Date: 2007-07-20 09:37:02 UTC
  • Revision ID: james.westby@ubuntu.com-20070720093702-lpkfouao72t9s13i
Tags: 332.14-1
* Initial release (Closes: #433168)
* debian/control: add dependency on libssl-dev for the hash functions
* debian/control: add dependency on quilt
* debian/copyright: included the complete text of the APSL 2.0
* debian/links: create links for HFS variants of the utils and manpages
* debian/rules: use quilt to patch the source, so we get a Makefile for Linux
* debian/patches: incorporated patch from Gentoo to work with quilt
* debian/patches: included patch to fix *roff warning
* debian/patches: added patch to install bootdata on usr/share correctly
* debian/patches: added patch to enable the -a for fsck (Tks: Adam Adam Cécile)
* debian/dirs: added entry for directory mentioned above
* debian/rules: added the file for wrapper HFS filesystem
* debian/README.Debian: give the URL of the Gentoo instructions

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Index: hfsprogs-332.14/Makefile.lnx
 
2
===================================================================
 
3
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
 
4
+++ hfsprogs-332.14/Makefile.lnx        2007-07-17 13:02:59.000000000 -0300
 
5
@@ -0,0 +1,8 @@
 
6
+CC := gcc
 
7
+CFLAGS := -g3 -Wall -I$(PWD)/include -DDEBUG_BUILD=0 -D_FILE_OFFSET_BITS=64 -D LINUX=1 -D BSD=1
 
8
+SUBDIRS := newfs_hfs.tproj fsck_hfs.tproj
 
9
+
 
10
+all clean:
 
11
+       for d in $(SUBDIRS); do $(MAKE) -C $$d -f Makefile.lnx $@; done
 
12
+
 
13
+export CC CFLAGS
 
14
Index: hfsprogs-332.14/fsck_hfs.tproj/Makefile.lnx
 
15
===================================================================
 
16
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
 
17
+++ hfsprogs-332.14/fsck_hfs.tproj/Makefile.lnx 2007-07-17 13:02:59.000000000 -0300
 
18
@@ -0,0 +1,15 @@
 
19
+CFILES = fsck_hfs.c strings.c utilities.c cache.c
 
20
+OFILES = $(CFILES:.c=.o)
 
21
+
 
22
+all: fsck_hfs
 
23
+
 
24
+fsck_hfs: $(OFILES) dfalib/libdfa.a
 
25
+
 
26
+dfalib/libdfa.a: FORCE
 
27
+       $(MAKE) -C dfalib -f Makefile.lnx libdfa.a
 
28
+
 
29
+clean:
 
30
+       $(RM) fsck_hfs $(OFILES)
 
31
+       $(MAKE) -C dfalib -f Makefile.lnx clean
 
32
+
 
33
+.PHONY : FORCE clean
 
34
Index: hfsprogs-332.14/fsck_hfs.tproj/cache.c
 
35
===================================================================
 
36
--- hfsprogs-332.14.orig/fsck_hfs.tproj/cache.c 2006-02-20 18:45:15.000000000 -0300
 
37
+++ hfsprogs-332.14/fsck_hfs.tproj/cache.c      2007-07-17 13:02:59.000000000 -0300
 
38
@@ -26,7 +26,11 @@
 
39
 #include <stdlib.h>
 
40
 #include <sys/mman.h>
 
41
 #include <sys/stat.h>
 
42
+#if LINUX
 
43
+#include "missing.h"
 
44
+#else
 
45
 #include <sys/types.h>
 
46
+#endif /* __LINUX__ */
 
47
 #include <sys/uio.h>
 
48
 #include <unistd.h>
 
49
 #include <string.h>
 
50
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/BTree.c
 
51
===================================================================
 
52
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/BTree.c  2006-02-20 18:45:15.000000000 -0300
 
53
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/BTree.c       2007-07-17 13:02:59.000000000 -0300
 
54
@@ -1705,7 +1705,9 @@
 
55
                                                                 UInt16                                  version,
 
56
                                                                 BTreeInfoRec                   *info )
 
57
 {
 
58
+#if !LINUX
 
59
 #pragma unused (version)
 
60
+#endif
 
61
 
 
62
        BTreeControlBlockPtr    btreePtr;
 
63
 
 
64
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/BTreeTreeOps.c
 
65
===================================================================
 
66
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/BTreeTreeOps.c   2006-02-20 18:45:15.000000000 -0300
 
67
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/BTreeTreeOps.c        2007-07-17 13:02:59.000000000 -0300
 
68
@@ -223,7 +223,7 @@
 
69
         //
 
70
         if (curNodeNum == 0)
 
71
         {
 
72
-//          Panic("\pSearchTree: curNodeNum is zero!");
 
73
+            Panic("SearchTree: curNodeNum is zero!");
 
74
             err = fsBTInvalidNodeErr;
 
75
             goto ErrorExit;
 
76
         }
 
77
@@ -433,7 +433,7 @@
 
78
                M_ExitOnError (err);
 
79
                
 
80
                if ( DEBUG_BUILD && updateParent && newRoot )
 
81
-                       DebugStr("\p InsertLevel: New root from primary key, update from secondary key...");
 
82
+                       DebugStr("InsertLevel: New root from primary key, update from secondary key...");
 
83
        }
 
84
 
 
85
        //////////////////////// Update Parent(s) ///////////////////////////////
 
86
@@ -448,7 +448,7 @@
 
87
                
 
88
                secondaryKey = nil;
 
89
                
 
90
-               PanicIf ( (level == btreePtr->treeDepth), "\p InsertLevel: unfinished insert!?");
 
91
+               PanicIf ( (level == btreePtr->treeDepth), "InsertLevel: unfinished insert!?");
 
92
 
 
93
                ++level;
 
94
 
 
95
@@ -456,7 +456,7 @@
 
96
                index = treePathTable [level].index;
 
97
                parentNodeNum = treePathTable [level].node;
 
98
 
 
99
-               PanicIf ( parentNodeNum == 0, "\p InsertLevel: parent node is zero!?");
 
100
+               PanicIf ( parentNodeNum == 0, "InsertLevel: parent node is zero!?");
 
101
 
 
102
                err = GetNode (btreePtr, parentNodeNum, &parentNode);   // released as target node in next level up
 
103
                M_ExitOnError (err);
 
104
@@ -470,7 +470,7 @@
 
105
                {
 
106
                        //���debug: check if ptr == targetNodeNum
 
107
                        GetRecordByIndex (btreePtr, parentNode.buffer, index, &keyPtr, &recPtr, &recSize);
 
108
-                       PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, "\p InsertLevel: parent ptr doesn't match target node!");
 
109
+                       PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, "InsertLevel: parent ptr doesn't match target node!");
 
110
                        
 
111
                        // need to delete and re-insert this parent key/ptr
 
112
                        // we delete it here and it gets re-inserted in the
 
113
@@ -532,7 +532,7 @@
 
114
        (void) ReleaseNode (btreePtr, targetNode);
 
115
        (void) ReleaseNode (btreePtr, &siblingNode);
 
116
 
 
117
-       Panic ("\p InsertLevel: an error occured!");
 
118
+       Panic ("InsertLevel: an error occured!");
 
119
 
 
120
        return  err;
 
121
 
 
122
@@ -566,7 +566,7 @@
 
123
 
 
124
        *rootSplit = false;
 
125
        
 
126
-       PanicIf ( targetNode->buffer == siblingNode->buffer, "\p InsertNode: targetNode == siblingNode, huh?");
 
127
+       PanicIf ( targetNode->buffer == siblingNode->buffer, "InsertNode: targetNode == siblingNode, huh?");
 
128
        
 
129
        leftNodeNum = ((NodeDescPtr) targetNode->buffer)->bLink;
 
130
        rightNodeNum = ((NodeDescPtr) targetNode->buffer)->fLink;
 
131
@@ -606,7 +606,7 @@
 
132
        
 
133
        if ( leftNodeNum > 0 )
 
134
        {
 
135
-               PanicIf ( siblingNode->buffer != nil, "\p InsertNode: siblingNode already aquired!");
 
136
+               PanicIf ( siblingNode->buffer != nil, "InsertNode: siblingNode already aquired!");
 
137
 
 
138
                if ( siblingNode->buffer == nil )
 
139
                {
 
140
@@ -614,7 +614,7 @@
 
141
                        M_ExitOnError (err);
 
142
                }
 
143
 
 
144
-               PanicIf ( ((NodeDescPtr) siblingNode->buffer)->fLink != nodeNum, "\p InsertNode, RotateLeft: invalid sibling link!" );
 
145
+               PanicIf ( ((NodeDescPtr) siblingNode->buffer)->fLink != nodeNum, "InsertNode, RotateLeft: invalid sibling link!" );
 
146
 
 
147
                if ( !key->skipRotate )         // are rotates allowed?
 
148
                {
 
149
@@ -703,7 +703,7 @@
 
150
 
 
151
        targetNodeNum = treePathTable[level].node;
 
152
        targetNodePtr = targetNode->buffer;
 
153
-       PanicIf (targetNodePtr == nil, "\pDeleteTree: targetNode has nil buffer!");
 
154
+       PanicIf (targetNodePtr == nil, "DeleteTree: targetNode has nil buffer!");
 
155
 
 
156
        DeleteRecord (btreePtr, targetNodePtr, index);
 
157
                
 
158
@@ -797,7 +797,7 @@
 
159
                         
 
160
                        //���debug: check if ptr == targetNodeNum
 
161
                        GetRecordByIndex (btreePtr, parentNode.buffer, index, &keyPtr, &recPtr, &recSize);
 
162
-                       PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, "\p DeleteTree: parent ptr doesn't match targetNodeNum!!");
 
163
+                       PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, " DeleteTree: parent ptr doesn't match targetNodeNum!!");
 
164
                        
 
165
                        // need to delete and re-insert this parent key/ptr
 
166
                        DeleteRecord (btreePtr, parentNode.buffer, index);
 
167
@@ -1018,7 +1018,7 @@
 
168
                                                                                keyPtr, keyLength, recPtr, recSize);
 
169
                        if ( !didItFit )
 
170
                        {
 
171
-                               Panic ("\pRotateLeft: InsertKeyRecord (left) returned false!");
 
172
+                               Panic ("RotateLeft: InsertKeyRecord (left) returned false!");
 
173
                                err = fsBTBadRotateErr;
 
174
                                goto ErrorExit;
 
175
                        }
 
176
@@ -1031,7 +1031,7 @@
 
177
                        didItFit = RotateRecordLeft (btreePtr, leftNode, rightNode);
 
178
                        if ( !didItFit )
 
179
                        {
 
180
-                               Panic ("\pRotateLeft: RotateRecordLeft returned false!");
 
181
+                               Panic ("RotateLeft: RotateRecordLeft returned false!");
 
182
                                err = fsBTBadRotateErr;
 
183
                                goto ErrorExit;
 
184
                        }
 
185
@@ -1048,7 +1048,7 @@
 
186
                                                                        keyPtr, keyLength, recPtr, recSize);
 
187
                if ( !didItFit )
 
188
                {
 
189
-                       Panic ("\pRotateLeft: InsertKeyRecord (right) returned false!");
 
190
+                       Panic ("RotateLeft: InsertKeyRecord (right) returned false!");
 
191
                        err = fsBTBadRotateErr;
 
192
                        goto ErrorExit;
 
193
                }
 
194
@@ -1117,7 +1117,7 @@
 
195
        right = rightNode->buffer;
 
196
        left  = leftNode->buffer;
 
197
        
 
198
-       PanicIf ( right->bLink != 0 && left == 0, "\p SplitLeft: left sibling missing!?" );
 
199
+       PanicIf ( right->bLink != 0 && left == 0, " SplitLeft: left sibling missing!?" );
 
200
        
 
201
        //�� type should be kLeafNode or kIndexNode
 
202
        
 
203
@@ -1240,8 +1240,8 @@
 
204
        Boolean                         didItFit;
 
205
        UInt16                          keyLength;      
 
206
        
 
207
-       PanicIf (leftNode == nil, "\pAddNewRootNode: leftNode == nil");
 
208
-       PanicIf (rightNode == nil, "\pAddNewRootNode: rightNode == nil");
 
209
+       PanicIf (leftNode == nil, "AddNewRootNode: leftNode == nil");
 
210
+       PanicIf (rightNode == nil, "AddNewRootNode: rightNode == nil");
 
211
        
 
212
        
 
213
        /////////////////////// Initialize New Root Node ////////////////////////////
 
214
@@ -1264,7 +1264,7 @@
 
215
        didItFit = InsertKeyRecord ( btreePtr, rootNode.buffer, 0, keyPtr, keyLength,
 
216
                                                                 (UInt8 *) &rightNode->bLink, 4 );
 
217
 
 
218
-       PanicIf ( !didItFit, "\pAddNewRootNode:InsertKeyRecord failed for left index record");
 
219
+       PanicIf ( !didItFit, "AddNewRootNode:InsertKeyRecord failed for left index record");
 
220
 
 
221
 
 
222
        //////////////////// Insert Right Node Index Record /////////////////////////
 
223
@@ -1275,7 +1275,7 @@
 
224
        didItFit = InsertKeyRecord ( btreePtr, rootNode.buffer, 1, keyPtr, keyLength,
 
225
                                                                 (UInt8 *) &leftNode->fLink, 4 );
 
226
 
 
227
-       PanicIf ( !didItFit, "\pAddNewRootNode:InsertKeyRecord failed for right index record");
 
228
+       PanicIf ( !didItFit, "AddNewRootNode:InsertKeyRecord failed for right index record");
 
229
 
 
230
 
 
231
 #if DEBUG_TREEOPS
 
232
@@ -1355,7 +1355,7 @@
 
233
        }
 
234
        rightPtr = rightNodePtr->buffer;
 
235
        
 
236
-       PanicIf ( leftPtr->fLink != 0 && rightPtr == 0, "\p SplitRight: right sibling missing!?" );
 
237
+       PanicIf ( leftPtr->fLink != 0 && rightPtr == 0, "SplitRight: right sibling missing!?" );
 
238
        
 
239
        //�� type should be kLeafNode or kIndexNode
 
240
        
 
241
@@ -1557,7 +1557,7 @@
 
242
                                                                        keyPtr, keyLength, recPtr, recSize);
 
243
                if ( !didItFit )
 
244
                {
 
245
-                       Panic ("\pRotateRight: InsertKeyRecord (left) returned false!");
 
246
+                       Panic ("RotateRight: InsertKeyRecord (left) returned false!");
 
247
                        err = fsBTBadRotateErr;
 
248
                        goto ErrorExit;
 
249
                }
 
250
@@ -1572,7 +1572,7 @@
 
251
                didItFit = RotateRecordRight( btreePtr, leftNodePtr, rightNodePtr );
 
252
                if ( !didItFit )
 
253
                {
 
254
-                       Panic ("\pRotateRight: RotateRecordRight returned false!");
 
255
+                       Panic ("RotateRight: RotateRecordRight returned false!");
 
256
                        err = fsBTBadRotateErr;
 
257
                        goto ErrorExit;
 
258
                }
 
259
@@ -1583,7 +1583,7 @@
 
260
                                                                                keyPtr, keyLength, recPtr, recSize);
 
261
                        if ( !didItFit )
 
262
                        {
 
263
-                               Panic ("\pRotateRight: InsertKeyRecord (left) returned false!");
 
264
+                               Panic ("RotateRight: InsertKeyRecord (left) returned false!");
 
265
                                err = fsBTBadRotateErr;
 
266
                                goto ErrorExit;
 
267
                        }
 
268
@@ -1607,7 +1607,7 @@
 
269
                                                                        keyPtr, keyLength, recPtr, recSize);
 
270
                if ( !didItFit )
 
271
                {
 
272
-                       Panic ("\pRotateRight: InsertKeyRecord (right) returned false!");
 
273
+                       Panic ("RotateRight: InsertKeyRecord (right) returned false!");
 
274
                        err = fsBTBadRotateErr;
 
275
                        goto ErrorExit;
 
276
                }
 
277
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/BlockCache.c
 
278
===================================================================
 
279
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/BlockCache.c     2006-02-20 18:45:15.000000000 -0300
 
280
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/BlockCache.c  2007-07-17 13:02:59.000000000 -0300
 
281
@@ -20,6 +20,9 @@
 
282
  * @APPLE_LICENSE_HEADER_END@
 
283
  */
 
284
 
 
285
+#if LINUX
 
286
+#include "missing.h"
 
287
+#endif
 
288
 #include "SRuntime.h"
 
289
 #include "Scavenger.h"
 
290
 #include "../cache.h"
 
291
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/Makefile.lnx
 
292
===================================================================
 
293
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
 
294
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/Makefile.lnx  2007-07-17 13:02:59.000000000 -0300
 
295
@@ -0,0 +1,15 @@
 
296
+CFILES = hfs_endian.c BlockCache.c\
 
297
+         BTree.c BTreeAllocate.c BTreeMiscOps.c \
 
298
+         BTreeNodeOps.c BTreeScanner.c BTreeTreeOps.c\
 
299
+         CatalogCheck.c HardLinkCheck.c\
 
300
+         SBTree.c SControl.c SVerify1.c SVerify2.c\
 
301
+         SRepair.c SRebuildCatalogBTree.c\
 
302
+         SUtils.c SKeyCompare.c SDevice.c SExtents.c SAllocate.c\
 
303
+         SCatalog.c SStubs.c VolumeBitmapCheck.c
 
304
+OFILES = $(CFILES:.c=.o)
 
305
+
 
306
+libdfa.a: $(OFILES)
 
307
+       ar rc $@ $?
 
308
+
 
309
+clean:
 
310
+       $(RM) $(OFILES) libdfa.a
 
311
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/SBTree.c
 
312
===================================================================
 
313
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/SBTree.c 2006-02-20 18:45:15.000000000 -0300
 
314
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/SBTree.c      2007-07-17 13:02:59.000000000 -0300
 
315
@@ -93,7 +93,7 @@
 
316
                        CopyMemory(&resultIterator->key, foundKey, CalcKeySize(btcb, &resultIterator->key));    //�� warning, this could overflow user's buffer!!!
 
317
 
 
318
                if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, *dataSize) )
 
319
-                       DebugStr("\pSearchBTreeRecord: bad record?");
 
320
+                       DebugStr("SearchBTreeRecord: bad record?");
 
321
        }
 
322
 
 
323
 ErrorExit:
 
324
@@ -190,7 +190,7 @@
 
325
                CopyMemory(&iterator->key, key, CalcKeySize(btcb, &iterator->key));     //�� warning, this could overflow user's buffer!!!
 
326
                
 
327
                if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, *dataSize) )
 
328
-                       DebugStr("\pGetBTreeRecord: bad record?");
 
329
+                       DebugStr("GetBTreeRecord: bad record?");
 
330
 
 
331
        }
 
332
        
 
333
@@ -222,7 +222,7 @@
 
334
        CopyMemory(key, &iterator.key, CalcKeySize(btcb, (BTreeKey *) key));    //�� should we range check against maxkeylen?
 
335
 
 
336
        if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, dataSize) )
 
337
-               DebugStr("\pInsertBTreeRecord: bad record?");
 
338
+               DebugStr("InsertBTreeRecord: bad record?");
 
339
 
 
340
        result = BTInsertRecord( fcb, &iterator, &btRecord, dataSize );
 
341
 
 
342
@@ -284,7 +284,7 @@
 
343
        CopyMemory(key, &iterator.key, CalcKeySize(btcb, (BTreeKey *) key));            //�� should we range check against maxkeylen?
 
344
 
 
345
        if ( DEBUG_BUILD && !ValidHFSRecord(newData, btcb, dataSize) )
 
346
-               DebugStr("\pReplaceBTreeRecord: bad record?");
 
347
+               DebugStr("ReplaceBTreeRecord: bad record?");
 
348
 
 
349
        result = BTReplaceRecord( fcb, &iterator, &btRecord, dataSize );
 
350
 
 
351
@@ -301,7 +301,9 @@
 
352
 OSStatus
 
353
 SetEndOfForkProc ( SFCB *filePtr, FSSize minEOF, FSSize maxEOF )
 
354
 {
 
355
+#if !LINUX
 
356
 #pragma unused (maxEOF)
 
357
+#endif
 
358
 
 
359
        OSStatus        result;
 
360
        UInt32          actualSectorsAdded;
 
361
@@ -321,7 +323,7 @@
 
362
        else
 
363
        {
 
364
                if ( DEBUG_BUILD )
 
365
-                       DebugStr("\pSetEndOfForkProc: minEOF is smaller than current size!");
 
366
+                       DebugStr("SetEndOfForkProc: minEOF is smaller than current size!");
 
367
                return -1;
 
368
        }
 
369
 
 
370
@@ -347,7 +349,7 @@
 
371
        //      Make sure we got at least as much space as we needed
 
372
        //
 
373
        if (filePtr->fcbLogicalSize < minEOF) {
 
374
-               Panic("\pSetEndOfForkProc: disk too full to extend B-tree file");
 
375
+               Panic("SetEndOfForkProc: disk too full to extend B-tree file");
 
376
                return dskFulErr;
 
377
        }
 
378
        
 
379
@@ -419,7 +421,7 @@
 
380
        if ( (keyLen < 6) || (keyLen > btcb->maxKeyLength) )
 
381
        {
 
382
                if ( DEBUG_BUILD )
 
383
-                       DebugStr("\pCheckBTreeKey: bad key length!");
 
384
+                       DebugStr("CheckBTreeKey: bad key length!");
 
385
                return fsBTInvalidKeyLengthErr;
 
386
        }
 
387
        
 
388
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/SControl.c
 
389
===================================================================
 
390
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/SControl.c       2006-02-20 18:45:15.000000000 -0300
 
391
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/SControl.c    2007-07-17 13:02:59.000000000 -0300
 
392
@@ -739,7 +739,7 @@
 
393
                pointer = (ScavStaticStructures *) AllocateClearMemory( sizeof(ScavStaticStructures) );
 
394
                if ( pointer == nil ) {
 
395
                        if ( GPtr->logLevel >= kDebugLog ) {
 
396
-                               printf( "\t error %d - could not allocate %ld bytes of memory \n",
 
397
+                               printf( "\t error %d - could not allocate %i bytes of memory \n",
 
398
                                        R_NoMem, sizeof(ScavStaticStructures) );
 
399
                        }
 
400
                        return( R_NoMem );
 
401
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/SDevice.c
 
402
===================================================================
 
403
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/SDevice.c        2006-02-20 18:45:15.000000000 -0300
 
404
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/SDevice.c     2007-07-17 13:02:59.000000000 -0300
 
405
@@ -28,24 +28,61 @@
 
406
 #include <unistd.h>
 
407
 #include <errno.h>
 
408
 #include <sys/ioctl.h>
 
409
-
 
410
+#if LINUX
 
411
+#include <fcntl.h>
 
412
+#include <sys/stat.h>
 
413
+#else
 
414
 #include <IOKit/storage/IOMediaBSDClient.h>
 
415
-
 
416
+#endif /* LINUX */
 
417
 #else
 
418
-
 
419
 #include <Files.h>
 
420
 #include <Device.h>
 
421
 #include <Disks.h>
 
422
 
 
423
-#endif
 
424
-
 
425
+#endif 
 
426
 
 
427
 OSErr GetDeviceSize(int driveRefNum, UInt64 *numBlocks, UInt32 *blockSize)
 
428
 {
 
429
 #if BSD
 
430
        UInt64 devBlockCount = 0;
 
431
        int devBlockSize = 0;
 
432
+#if LINUX
 
433
+       struct stat stbuf;
 
434
 
 
435
+       devBlockSize = 512;
 
436
+
 
437
+#ifndef BLKGETSIZE
 
438
+#define BLKGETSIZE              _IO(0x12,96)
 
439
+#endif
 
440
+#ifndef BLKGETSIZE64
 
441
+#define BLKGETSIZE64            _IOR(0x12,114,size_t)
 
442
+#endif
 
443
+       if (fstat(driveRefNum, &stbuf) < 0){
 
444
+               printf("Error: %s\n", strerror(errno));
 
445
+               return(-1);
 
446
+       }
 
447
+        
 
448
+        if (S_ISREG(stbuf.st_mode)) {
 
449
+                devBlockCount = stbuf.st_size / 512;
 
450
+        } 
 
451
+        else if (S_ISBLK(stbuf.st_mode)) {
 
452
+                unsigned long size;
 
453
+                u_int64_t size64;
 
454
+                if (!ioctl(driveRefNum, BLKGETSIZE64, &size64))
 
455
+                        devBlockCount = size64 / 512;
 
456
+                else if (!ioctl(driveRefNum, BLKGETSIZE, &size))
 
457
+                        devBlockCount = size;
 
458
+                else{
 
459
+                        printf("Error: %s\n", strerror(errno));
 
460
+                       return(-1);
 
461
+               }
 
462
+                       
 
463
+        }
 
464
+        else{
 
465
+                printf("Device is not a block device");
 
466
+               return(-1);
 
467
+       }
 
468
+#elif BSD
 
469
        if (ioctl(driveRefNum, DKIOCGETBLOCKCOUNT, &devBlockCount) < 0) {
 
470
                printf("ioctl(DKIOCGETBLOCKCOUNT) for fd %d: %s\n", driveRefNum, strerror(errno));
 
471
                return (-1);
 
472
@@ -55,6 +92,7 @@
 
473
                printf("ioctl(DKIOCGETBLOCKSIZE) for fd %d: %s\n", driveRefNum, strerror(errno));
 
474
                return (-1);
 
475
        }
 
476
+#endif /* BSD */
 
477
 
 
478
        if (devBlockSize != 512) {
 
479
                *numBlocks = (devBlockCount * (UInt64)devBlockSize) / 512;
 
480
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/SKeyCompare.c
 
481
===================================================================
 
482
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/SKeyCompare.c    2006-02-20 18:45:15.000000000 -0300
 
483
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/SKeyCompare.c 2007-07-17 13:02:59.000000000 -0300
 
484
@@ -454,7 +454,9 @@
 
485
  * The name portion of the key is compared using a 16-bit binary comparison. 
 
486
  * This is called from the b-tree code.
 
487
  */
 
488
+#if !LINUX
 
489
 __private_extern__
 
490
+#endif
 
491
 SInt32
 
492
 CompareAttributeKeys(const AttributeKey *searchKey, const AttributeKey *trialKey)
 
493
 {
 
494
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/SRepair.c
 
495
===================================================================
 
496
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/SRepair.c        2006-02-20 18:45:15.000000000 -0300
 
497
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/SRepair.c     2007-07-17 13:02:59.000000000 -0300
 
498
@@ -1593,7 +1593,9 @@
 
499
 
 
500
 static OSErr   FixWrapperExtents( SGlobPtr GPtr, RepairOrderPtr p )
 
501
 {
 
502
+#if !LINUX
 
503
 #pragma unused (p)
 
504
+#endif
 
505
 
 
506
        OSErr                                           err;
 
507
        HFSMasterDirectoryBlock         *mdb;
 
508
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/SRuntime.h
 
509
===================================================================
 
510
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/SRuntime.h       2006-02-20 18:45:15.000000000 -0300
 
511
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/SRuntime.h    2007-07-17 13:02:59.000000000 -0300
 
512
@@ -27,8 +27,11 @@
 
513
 #define __SRUNTIME__
 
514
 
 
515
 #if BSD
 
516
-
 
517
+#if LINUX
 
518
+#include "missing.h"
 
519
+#else
 
520
 #include <sys/types.h>
 
521
+#endif
 
522
 #include <stdlib.h>
 
523
 #include <string.h>
 
524
 #include <stdio.h>
 
525
@@ -91,10 +94,12 @@
 
526
 
 
527
 typedef u_int32_t      HFSCatalogNodeID;
 
528
 
 
529
+#if !LINUX
 
530
 enum {
 
531
        false           = 0,
 
532
        true            = 1
 
533
 };
 
534
+#endif
 
535
 
 
536
 /* OS error codes */
 
537
 enum {
 
538
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/SUtils.c
 
539
===================================================================
 
540
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/SUtils.c 2006-02-20 18:45:15.000000000 -0300
 
541
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/SUtils.c      2007-07-17 13:02:59.000000000 -0300
 
542
@@ -380,7 +380,8 @@
 
543
 //                             GPtr->realVCB                   Real in-memory vcb
 
544
 //------------------------------------------------------------------------------
 
545
 
 
546
-#if !BSD       
 
547
+#if BSD
 
548
+#if !LINUX
 
549
 OSErr GetVolumeFeatures( SGlobPtr GPtr )
 
550
 {
 
551
        OSErr                                   err;
 
552
@@ -418,7 +419,7 @@
 
553
        return( noErr );
 
554
 }
 
555
 #endif
 
556
-
 
557
+#endif
 
558
 
 
559
 
 
560
 /*-------------------------------------------------------------------------------
 
561
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/SVerify2.c
 
562
===================================================================
 
563
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/SVerify2.c       2006-02-20 18:45:15.000000000 -0300
 
564
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/SVerify2.c    2007-07-17 13:02:59.000000000 -0300
 
565
@@ -32,7 +32,9 @@
 
566
 */
 
567
 
 
568
 #include <sys/ioctl.h>
 
569
+#if !LINUX
 
570
 #include <sys/disk.h>
 
571
+#endif
 
572
 
 
573
 #include "BTree.h"
 
574
 #include "BTreePrivate.h"
 
575
@@ -1240,8 +1242,13 @@
 
576
         * clump size for read-only media is irrelevant we skip the clump size 
 
577
         * check to avoid non useful warnings. 
 
578
         */
 
579
+#if LINUX
 
580
+       // FIXME
 
581
+       isWriteable = 1;
 
582
+#else
 
583
        isWriteable = 0;
 
584
        ioctl( GPtr->DrvNum, DKIOCISWRITABLE, &isWriteable );
 
585
+#endif
 
586
        if ( isWriteable != 0 && 
 
587
                 volumeHeader->catalogFile.clumpSize != vcb->vcbCatalogFile->fcbClumpSize ) {
 
588
                PrintError(GPtr, E_InvalidClumpSize, 0);
 
589
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/Scavenger.h
 
590
===================================================================
 
591
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/Scavenger.h      2006-02-20 18:45:15.000000000 -0300
 
592
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/Scavenger.h   2007-07-17 13:02:59.000000000 -0300
 
593
@@ -35,11 +35,16 @@
 
594
 #include "BTreeScanner.h"
 
595
 #include "hfs_endian.h"
 
596
 
 
597
+#if LINUX
 
598
+#define XATTR_MAXNAMELEN 127
 
599
+#include <limits.h>
 
600
+#else
 
601
 #include <sys/xattr.h>
 
602
 #include <sys/acl.h>
 
603
 #include <sys/kauth.h>
 
604
-#include <sys/errno.h>
 
605
 #include <sys/syslimits.h>
 
606
+#endif
 
607
+#include <sys/errno.h>
 
608
 
 
609
 #ifdef __cplusplus
 
610
 extern "C" {
 
611
@@ -1434,4 +1439,8 @@
 
612
 };
 
613
 #endif
 
614
 
 
615
+#if LINUX
 
616
+#undef XATTR_MAXNAMELEN
 
617
+#endif
 
618
+
 
619
 #endif /* __SCAVENGER__ */
 
620
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/hfs_endian.c
 
621
===================================================================
 
622
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/hfs_endian.c     2006-02-20 18:45:15.000000000 -0300
 
623
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/hfs_endian.c  2007-07-17 13:02:59.000000000 -0300
 
624
@@ -31,7 +31,11 @@
 
625
 #include <sys/types.h>
 
626
 #include <sys/stat.h>
 
627
 
 
628
+#if LINUX
 
629
+#include "missing.h"
 
630
+#else
 
631
 #include <architecture/byte_order.h>
 
632
+#endif
 
633
 #include <hfs/hfs_format.h>
 
634
 
 
635
 #include "Scavenger.h"
 
636
@@ -559,7 +563,7 @@
 
637
             /* Make sure name length is consistent with key length */
 
638
             if (keyLength < sizeof(srcKey->parentID) + sizeof(srcKey->nodeName.length) +
 
639
                 srcKey->nodeName.length*sizeof(srcKey->nodeName.unicode[0])) {
 
640
-                               if (debug) printf("hfs_swap_HFSPlusBTInternalNode: catalog record #%d keyLength=%d expected=%lu\n",
 
641
+                               if (debug) printf("hfs_swap_HFSPlusBTInternalNode: catalog record #%d keyLength=%d expected=%i\n",
 
642
                                        srcDesc->numRecords-i, keyLength, sizeof(srcKey->parentID) + sizeof(srcKey->nodeName.length) +
 
643
                     srcKey->nodeName.length*sizeof(srcKey->nodeName.unicode[0]));
 
644
                                WriteError(fcb->fcbVolume->vcbGPtr, E_KeyLen, fcb->fcbFileID, src->blockNum);
 
645
Index: hfsprogs-332.14/fsck_hfs.tproj/dfalib/hfs_endian.h
 
646
===================================================================
 
647
--- hfsprogs-332.14.orig/fsck_hfs.tproj/dfalib/hfs_endian.h     2006-02-20 18:45:15.000000000 -0300
 
648
+++ hfsprogs-332.14/fsck_hfs.tproj/dfalib/hfs_endian.h  2007-07-17 13:02:59.000000000 -0300
 
649
@@ -27,9 +27,14 @@
 
650
  *
 
651
  * This file prototypes endian swapping routines for the HFS/HFS Plus
 
652
  * volume format.
 
653
- */
 
654
+*/
 
655
 #include <hfs/hfs_format.h>
 
656
+#if LINUX
 
657
+#include <endian.h>
 
658
+#include <byteswap.h>
 
659
+#else
 
660
 #include <architecture/byte_order.h>
 
661
+#endif
 
662
 #include "SRuntime.h"
 
663
 
 
664
 /*********************/
 
665
Index: hfsprogs-332.14/fsck_hfs.tproj/fsck_hfs.c
 
666
===================================================================
 
667
--- hfsprogs-332.14.orig/fsck_hfs.tproj/fsck_hfs.c      2006-02-20 18:45:15.000000000 -0300
 
668
+++ hfsprogs-332.14/fsck_hfs.tproj/fsck_hfs.c   2007-07-17 13:02:59.000000000 -0300
 
669
@@ -24,10 +24,14 @@
 
670
 #include <sys/types.h>
 
671
 #include <sys/stat.h>
 
672
 #include <sys/param.h>
 
673
+#if !LINUX
 
674
 #include <sys/ucred.h>
 
675
+#endif
 
676
 #include <sys/mount.h>
 
677
 #include <sys/ioctl.h>
 
678
+#if !LINUX
 
679
 #include <sys/disk.h>
 
680
+#endif
 
681
 
 
682
 #include <hfs/hfs_mount.h>
 
683
 
 
684
@@ -170,10 +174,12 @@
 
685
        
 
686
        if (guiControl)
 
687
                debug = 0; /* debugging is for command line only */
 
688
-
 
689
+#if LINUX
 
690
+// FIXME
 
691
+#else
 
692
        if (signal(SIGINT, SIG_IGN) != SIG_IGN)
 
693
                (void)signal(SIGINT, catch);
 
694
-
 
695
+#endif
 
696
        if (argc < 1) {
 
697
                (void) fprintf(stderr, "%s: missing special-device\n", progname);
 
698
                usage();
 
699
@@ -194,7 +200,9 @@
 
700
        int chkLev, repLev, logLev;
 
701
        int blockDevice_fd, canWrite;
 
702
        char *unraw, *mntonname;
 
703
+#if !LINUX
 
704
        struct statfs *fsinfo;
 
705
+#endif
 
706
        int fs_fd=-1;  // fd to the root-dir of the fs we're checking (only w/lfag == 1)
 
707
 
 
708
        flags = 0;
 
709
@@ -203,7 +211,9 @@
 
710
        canWrite = 0;
 
711
        unraw = NULL;
 
712
        mntonname = NULL;
 
713
-
 
714
+#if LINUX
 
715
+       // FIXME
 
716
+#else
 
717
        if (lflag) {
 
718
                result = getmntinfo(&fsinfo, MNT_NOWAIT);
 
719
 
 
720
@@ -233,7 +243,7 @@
 
721
                    }
 
722
                }
 
723
        }
 
724
-
 
725
+#endif
 
726
        if (debug && preen)
 
727
                pwarn("starting\n");
 
728
        
 
729
@@ -306,6 +316,9 @@
 
730
                        }
 
731
                }
 
732
        } else {
 
733
+#if LINUX
 
734
+       // FIXME
 
735
+#else
 
736
                struct statfs stfs_buf;
 
737
                /*
 
738
                 * Check to see if root is mounted read-write.
 
739
@@ -315,18 +328,24 @@
 
740
                else
 
741
                        flags = 0;
 
742
                ckfini(flags & MNT_RDONLY);
 
743
+#endif
 
744
        }
 
745
 
 
746
        /* XXX free any allocated memory here */
 
747
 
 
748
        if (hotroot && fsmodified) {
 
749
+#if !LINUX
 
750
                struct hfs_mount_args args;
 
751
+#endif
 
752
                /*
 
753
                 * We modified the root.  Do a mount update on
 
754
                 * it, unless it is read-write, so we can continue.
 
755
                 */
 
756
                if (!preen)
 
757
                        printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
 
758
+#if LINUX
 
759
+               // FIXME
 
760
+#else
 
761
                if (flags & MNT_RDONLY) {               
 
762
                        bzero(&args, sizeof(args));
 
763
                        flags |= MNT_UPDATE | MNT_RELOAD;
 
764
@@ -335,6 +354,7 @@
 
765
                                goto ExitThisRoutine;
 
766
                        }
 
767
                }
 
768
+#endif
 
769
                if (!preen)
 
770
                        printf("\n***** REBOOT NOW *****\n");
 
771
                sync();
 
772
@@ -380,11 +400,13 @@
 
773
                printf("Can't stat %s: %s\n", dev, strerror(errno));
 
774
                return (0);
 
775
        }
 
776
+#if !LINUX
 
777
        if ((statb.st_mode & S_IFMT) != S_IFCHR) {
 
778
                pfatal("%s is not a character device", dev);
 
779
                if (reply("CONTINUE") == 0)
 
780
                        return (0);
 
781
        }
 
782
+#endif
 
783
        if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
 
784
                printf("Can't open %s: %s\n", dev, strerror(errno));
 
785
                return (0);
 
786
@@ -407,10 +429,14 @@
 
787
                printf("\n");
 
788
 
 
789
        /* Get device block size to initialize cache */
 
790
+#if LINUX
 
791
+       devBlockSize = 512;
 
792
+#else
 
793
        if (ioctl(fsreadfd, DKIOCGETBLOCKSIZE, &devBlockSize) < 0) {
 
794
                pfatal ("Can't get device block size\n");
 
795
                return (0);
 
796
        }
 
797
+#endif
 
798
        /* Initialize the cache */
 
799
        if (CacheInit (&fscache, fsreadfd, fswritefd, devBlockSize,
 
800
                        CACHE_IOSIZE, CACHE_BLOCKS, CACHE_HASHSIZE) != EOK) {
 
801
@@ -431,11 +457,15 @@
 
802
 
 
803
 static void getWriteAccess( char *dev, int *blockDevice_fdPtr, int *canWritePtr )
 
804
 {
 
805
+#if !LINUX
 
806
        int                                     i;
 
807
        int                                     myMountsCount;
 
808
+#endif
 
809
        void *                          myPtr;
 
810
        char *                          myCharPtr;
 
811
+#if !LINUX
 
812
        struct statfs *         myBufPtr;
 
813
+#endif
 
814
        void *                          myNamePtr;
 
815
 
 
816
        myPtr = NULL;
 
817
@@ -456,18 +486,19 @@
 
818
                *canWritePtr = 1;
 
819
                goto ExitThisRoutine;
 
820
        }
 
821
-       
 
822
        // get count of mounts then get the info for each 
 
823
+#if LINUX
 
824
+       // FIXME
 
825
+#else
 
826
        myMountsCount = getfsstat( NULL, 0, MNT_NOWAIT );
 
827
        if ( myMountsCount < 0 )
 
828
                goto ExitThisRoutine;
 
829
-
 
830
        myPtr = (void *) malloc( sizeof(struct statfs) * myMountsCount );
 
831
        if ( myPtr == NULL ) 
 
832
                goto ExitThisRoutine;
 
833
        myMountsCount = getfsstat(      myPtr, 
 
834
-                                                               (sizeof(struct statfs) * myMountsCount), 
 
835
-                                                               MNT_NOWAIT );
 
836
+                                                       (sizeof(struct statfs) * myMountsCount), 
 
837
+                                                       MNT_NOWAIT );
 
838
        if ( myMountsCount < 0 )
 
839
                goto ExitThisRoutine;
 
840
 
 
841
@@ -481,8 +512,8 @@
 
842
                }
 
843
                myBufPtr++;
 
844
        }
 
845
+#endif
 
846
        *canWritePtr = 1;  // single user will get us here, f_mntfromname is not /dev/diskXXXX 
 
847
-       
 
848
 ExitThisRoutine:
 
849
        if ( myPtr != NULL )
 
850
                free( myPtr );
 
851
Index: hfsprogs-332.14/fsck_hfs.tproj/utilities.c
 
852
===================================================================
 
853
--- hfsprogs-332.14.orig/fsck_hfs.tproj/utilities.c     2006-02-20 18:45:15.000000000 -0300
 
854
+++ hfsprogs-332.14/fsck_hfs.tproj/utilities.c  2007-07-17 13:02:59.000000000 -0300
 
855
@@ -183,12 +183,14 @@
 
856
                        printf("Can't stat %s\n", raw);
 
857
                        return (origname);
 
858
                }
 
859
+#if !LINUX
 
860
                if ((stchar.st_mode & S_IFMT) == S_IFCHR) {
 
861
                        return (raw);
 
862
                } else {
 
863
                        printf("%s is not a character device\n", raw);
 
864
                        return (origname);
 
865
                }
 
866
+#endif
 
867
        } else if ((stblock.st_mode & S_IFMT) == S_IFCHR && !retried) {
 
868
                newname = unrawname(newname);
 
869
                retried++;
 
870
@@ -214,7 +216,11 @@
 
871
        *dp = 0;
 
872
        (void)strcpy(rawbuf, name);
 
873
        *dp = '/';
 
874
-       (void)strcat(rawbuf, "/r");
 
875
+#if LINUX
 
876
+       (void)strcat(rawbuf, "/");
 
877
+#else
 
878
+       (void)strcat(rawbuf,"/r");
 
879
+#endif
 
880
        (void)strcat(rawbuf, &dp[1]);
 
881
 
 
882
        return (rawbuf);
 
883
Index: hfsprogs-332.14/include/bitstring.h
 
884
===================================================================
 
885
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
 
886
+++ hfsprogs-332.14/include/bitstring.h 2007-07-17 13:02:59.000000000 -0300
 
887
@@ -0,0 +1,164 @@
 
888
+/*
 
889
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
 
890
+ *
 
891
+ * @APPLE_LICENSE_HEADER_START@
 
892
+ * 
 
893
+ * The contents of this file constitute Original Code as defined in and
 
894
+ * are subject to the Apple Public Source License Version 1.1 (the
 
895
+ * "License").  You may not use this file except in compliance with the
 
896
+ * License.  Please obtain a copy of the License at
 
897
+ * http://www.apple.com/publicsource and read it before using this file.
 
898
+ * 
 
899
+ * This Original Code and all software distributed under the License are
 
900
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 
901
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 
902
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 
903
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
 
904
+ * License for the specific language governing rights and limitations
 
905
+ * under the License.
 
906
+ * 
 
907
+ * @APPLE_LICENSE_HEADER_END@
 
908
+ */
 
909
+/*
 
910
+ * Copyright (c) 1989, 1993
 
911
+ *     The Regents of the University of California.  All rights reserved.
 
912
+ *
 
913
+ * This code is derived from software contributed to Berkeley by
 
914
+ * Paul Vixie.
 
915
+ *
 
916
+ * Redistribution and use in source and binary forms, with or without
 
917
+ * modification, are permitted provided that the following conditions
 
918
+ * are met:
 
919
+ * 1. Redistributions of source code must retain the above copyright
 
920
+ *    notice, this list of conditions and the following disclaimer.
 
921
+ * 2. Redistributions in binary form must reproduce the above copyright
 
922
+ *    notice, this list of conditions and the following disclaimer in the
 
923
+ *    documentation and/or other materials provided with the distribution.
 
924
+ * 3. All advertising materials mentioning features or use of this software
 
925
+ *    must display the following acknowledgement:
 
926
+ *     This product includes software developed by the University of
 
927
+ *     California, Berkeley and its contributors.
 
928
+ * 4. Neither the name of the University nor the names of its contributors
 
929
+ *    may be used to endorse or promote products derived from this software
 
930
+ *    without specific prior written permission.
 
931
+ *
 
932
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 
933
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
934
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
935
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 
936
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
937
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
938
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
939
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
940
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
941
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
942
+ * SUCH DAMAGE.
 
943
+ *
 
944
+ *     @(#)bitstring.h 8.1 (Berkeley) 7/19/93
 
945
+ */
 
946
+
 
947
+#ifndef _BITSTRING_H_
 
948
+#define        _BITSTRING_H_
 
949
+
 
950
+typedef        unsigned char bitstr_t;
 
951
+
 
952
+/* internal macros */
 
953
+                               /* byte of the bitstring bit is in */
 
954
+#define        _bit_byte(bit) \
 
955
+       ((bit) >> 3)
 
956
+
 
957
+                               /* mask for the bit within its byte */
 
958
+#define        _bit_mask(bit) \
 
959
+       (1 << ((bit)&0x7))
 
960
+
 
961
+/* external macros */
 
962
+                               /* bytes in a bitstring of nbits bits */
 
963
+#define        bitstr_size(nbits) \
 
964
+       ((((nbits) - 1) >> 3) + 1)
 
965
+
 
966
+                               /* allocate a bitstring */
 
967
+#define        bit_alloc(nbits) \
 
968
+       (bitstr_t *)calloc(1, \
 
969
+           (unsigned int)bitstr_size(nbits) * sizeof(bitstr_t))
 
970
+
 
971
+                               /* allocate a bitstring on the stack */
 
972
+#define        bit_decl(name, nbits) \
 
973
+       (name)[bitstr_size(nbits)]
 
974
+
 
975
+                               /* is bit N of bitstring name set? */
 
976
+#define        bit_test(name, bit) \
 
977
+       ((name)[_bit_byte(bit)] & _bit_mask(bit))
 
978
+
 
979
+                               /* set bit N of bitstring name */
 
980
+#define        bit_set(name, bit) \
 
981
+       (name)[_bit_byte(bit)] |= _bit_mask(bit)
 
982
+
 
983
+                               /* clear bit N of bitstring name */
 
984
+#define        bit_clear(name, bit) \
 
985
+       (name)[_bit_byte(bit)] &= ~_bit_mask(bit)
 
986
+
 
987
+                               /* clear bits start ... stop in bitstring */
 
988
+#define        bit_nclear(name, start, stop) { \
 
989
+       register bitstr_t *_name = name; \
 
990
+       register int _start = start, _stop = stop; \
 
991
+       register int _startbyte = _bit_byte(_start); \
 
992
+       register int _stopbyte = _bit_byte(_stop); \
 
993
+       if (_startbyte == _stopbyte) { \
 
994
+               _name[_startbyte] &= ((0xff >> (8 - (_start&0x7))) | \
 
995
+                                     (0xff << ((_stop&0x7) + 1))); \
 
996
+       } else { \
 
997
+               _name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \
 
998
+               while (++_startbyte < _stopbyte) \
 
999
+                       _name[_startbyte] = 0; \
 
1000
+               _name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \
 
1001
+       } \
 
1002
+}
 
1003
+
 
1004
+                               /* set bits start ... stop in bitstring */
 
1005
+#define        bit_nset(name, start, stop) { \
 
1006
+       register bitstr_t *_name = name; \
 
1007
+       register int _start = start, _stop = stop; \
 
1008
+       register int _startbyte = _bit_byte(_start); \
 
1009
+       register int _stopbyte = _bit_byte(_stop); \
 
1010
+       if (_startbyte == _stopbyte) { \
 
1011
+               _name[_startbyte] |= ((0xff << (_start&0x7)) & \
 
1012
+                                   (0xff >> (7 - (_stop&0x7)))); \
 
1013
+       } else { \
 
1014
+               _name[_startbyte] |= 0xff << ((_start)&0x7); \
 
1015
+               while (++_startbyte < _stopbyte) \
 
1016
+                       _name[_startbyte] = 0xff; \
 
1017
+               _name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \
 
1018
+       } \
 
1019
+}
 
1020
+
 
1021
+                               /* find first bit clear in name */
 
1022
+#define        bit_ffc(name, nbits, value) { \
 
1023
+       register bitstr_t *_name = name; \
 
1024
+       register int _byte, _nbits = nbits; \
 
1025
+       register int _stopbyte = _bit_byte(_nbits), _value = -1; \
 
1026
+       for (_byte = 0; _byte <= _stopbyte; ++_byte) \
 
1027
+               if (_name[_byte] != 0xff) { \
 
1028
+                       _value = _byte << 3; \
 
1029
+                       for (_stopbyte = _name[_byte]; (_stopbyte&0x1); \
 
1030
+                           ++_value, _stopbyte >>= 1); \
 
1031
+                       break; \
 
1032
+               } \
 
1033
+       *(value) = _value; \
 
1034
+}
 
1035
+
 
1036
+                               /* find first bit set in name */
 
1037
+#define        bit_ffs(name, nbits, value) { \
 
1038
+       register bitstr_t *_name = name; \
 
1039
+       register int _byte, _nbits = nbits; \
 
1040
+       register int _stopbyte = _bit_byte(_nbits), _value = -1; \
 
1041
+       for (_byte = 0; _byte <= _stopbyte; ++_byte) \
 
1042
+               if (_name[_byte]) { \
 
1043
+                       _value = _byte << 3; \
 
1044
+                       for (_stopbyte = _name[_byte]; !(_stopbyte&0x1); \
 
1045
+                           ++_value, _stopbyte >>= 1); \
 
1046
+                       break; \
 
1047
+               } \
 
1048
+       *(value) = _value; \
 
1049
+}
 
1050
+
 
1051
+#endif /* !_BITSTRING_H_ */
 
1052
Index: hfsprogs-332.14/include/hfs/hfs_format.h
 
1053
===================================================================
 
1054
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
 
1055
+++ hfsprogs-332.14/include/hfs/hfs_format.h    2007-07-17 13:02:59.000000000 -0300
 
1056
@@ -0,0 +1,689 @@
 
1057
+/*
 
1058
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
 
1059
+ *
 
1060
+ * @APPLE_LICENSE_HEADER_START@
 
1061
+ * 
 
1062
+ * The contents of this file constitute Original Code as defined in and
 
1063
+ * are subject to the Apple Public Source License Version 1.1 (the
 
1064
+ * "License").  You may not use this file except in compliance with the
 
1065
+ * License.  Please obtain a copy of the License at
 
1066
+ * http://www.apple.com/publicsource and read it before using this file.
 
1067
+ * 
 
1068
+ * This Original Code and all software distributed under the License are
 
1069
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 
1070
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 
1071
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 
1072
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
 
1073
+ * License for the specific language governing rights and limitations
 
1074
+ * under the License.
 
1075
+ * 
 
1076
+ * @APPLE_LICENSE_HEADER_END@
 
1077
+ */
 
1078
+#ifndef __HFS_FORMAT__
 
1079
+#define __HFS_FORMAT__
 
1080
+
 
1081
+#include "missing.h"
 
1082
+
 
1083
+#include <sys/appleapiopts.h>
 
1084
+
 
1085
+/*
 
1086
+ * hfs_format.c
 
1087
+ *
 
1088
+ * This file describes the on-disk format for HFS and HFS Plus volumes.
 
1089
+ * The HFS Plus volume format is desciibed in detail in Apple Technote 1150.
 
1090
+ *
 
1091
+ * http://developer.apple.com/technotes/tn/tn1150.html
 
1092
+ *
 
1093
+ */
 
1094
+
 
1095
+#ifdef __cplusplus
 
1096
+extern "C" {
 
1097
+#endif
 
1098
+
 
1099
+/* some on-disk hfs structures have 68K alignment (misaligned) */
 
1100
+
 
1101
+#define PACKED_S       __attribute__((packed))
 
1102
+       
 
1103
+/* Signatures used to differentiate between HFS and HFS Plus volumes */
 
1104
+enum {
 
1105
+       kHFSSigWord             = 0x4244,       /* 'BD' in ASCII */
 
1106
+       kHFSPlusSigWord         = 0x482B,       /* 'H+' in ASCII */
 
1107
+       kHFSXSigWord            = 0x4858,       /* 'HX' in ASCII */
 
1108
+
 
1109
+       kHFSPlusVersion         = 0x0004,       /* 'H+' volumes are version 4 only */
 
1110
+       kHFSXVersion            = 0x0005,       /* 'HX' volumes start with version 5 */
 
1111
+
 
1112
+       kHFSPlusMountVersion    = 0x31302E30,   /* '10.0' for Mac OS X */
 
1113
+       kHFSJMountVersion       = 0x4846534a,   /* 'HFSJ' for journaled HFS+ on OS X */
 
1114
+       kFSKMountVersion        = 0x46534b21    /* 'FSK!' for failed journal replay */
 
1115
+}PACKED_S;
 
1116
+
 
1117
+
 
1118
+#ifdef __APPLE_API_PRIVATE
 
1119
+/*
 
1120
+ * Mac OS X has a special directory for linked and unlinked files (HFS Plus only).
 
1121
+ * This directory and its contents are never exported from the filesystem under
 
1122
+ * Mac OS X.
 
1123
+ *
 
1124
+ * To make this folder name sort last,  it has embedded null prefix.
 
1125
+ * (0xC0, 0x80 in UTF-8)
 
1126
+ */
 
1127
+#define HFSPLUSMETADATAFOLDER  "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
 
1128
+
 
1129
+/*
 
1130
+ * Files in the HFS Private Data folder have one of the following prefixes
 
1131
+ * followed by a decimal number (no leading zeros).  For indirect nodes this
 
1132
+ * number is a 32 bit random number.  For unlinked (deleted) files that are
 
1133
+ * still open, the number is the file ID for that file.
 
1134
+ *
 
1135
+ * e.g.  iNode7182000 and temp3296
 
1136
+ */
 
1137
+#define HFS_INODE_PREFIX       "iNode"
 
1138
+#define HFS_DELETE_PREFIX      "temp"
 
1139
+
 
1140
+#endif /* __APPLE_API_PRIVATE */
 
1141
+
 
1142
+/*
 
1143
+ * Indirect link files (hard links) have the following type/creator.
 
1144
+ */
 
1145
+enum {
 
1146
+       kHardLinkFileType = 0x686C6E6B,  /* 'hlnk' */
 
1147
+       kHFSPlusCreator   = 0x6866732B   /* 'hfs+' */
 
1148
+}PACKED_S;
 
1149
+
 
1150
+
 
1151
+#ifndef _HFSUNISTR255_DEFINED_
 
1152
+#define _HFSUNISTR255_DEFINED_
 
1153
+/* Unicode strings are used for HFS Plus file and folder names */
 
1154
+struct HFSUniStr255 {
 
1155
+       u_int16_t       length;         /* number of unicode characters */
 
1156
+       u_int16_t       unicode[255];   /* unicode characters */
 
1157
+} PACKED_S;
 
1158
+typedef struct HFSUniStr255 HFSUniStr255;
 
1159
+typedef const HFSUniStr255 *ConstHFSUniStr255Param;
 
1160
+#endif /* _HFSUNISTR255_DEFINED_ */
 
1161
+
 
1162
+enum {
 
1163
+       kHFSMaxVolumeNameChars          = 27,
 
1164
+       kHFSMaxFileNameChars            = 31,
 
1165
+       kHFSPlusMaxFileNameChars        = 255
 
1166
+}PACKED_S;
 
1167
+
 
1168
+
 
1169
+/* Extent overflow file data structures */
 
1170
+
 
1171
+/* HFS Extent key */
 
1172
+struct HFSExtentKey {
 
1173
+       u_int8_t        keyLength;      /* length of key, excluding this field */
 
1174
+       u_int8_t        forkType;       /* 0 = data fork, FF = resource fork */
 
1175
+       u_int32_t       fileID;         /* file ID */
 
1176
+       u_int16_t       startBlock;     /* first file allocation block number in this extent */
 
1177
+}PACKED_S;
 
1178
+typedef struct HFSExtentKey HFSExtentKey;
 
1179
+
 
1180
+/* HFS Plus Extent key */
 
1181
+struct HFSPlusExtentKey {
 
1182
+       u_int16_t       keyLength;              /* length of key, excluding this field */
 
1183
+       u_int8_t        forkType;               /* 0 = data fork, FF = resource fork */
 
1184
+       u_int8_t        pad;                    /* make the other fields align on 32-bit boundary */
 
1185
+       u_int32_t       fileID;                 /* file ID */
 
1186
+       u_int32_t       startBlock;             /* first file allocation block number in this extent */
 
1187
+}PACKED_S;
 
1188
+typedef struct HFSPlusExtentKey HFSPlusExtentKey;
 
1189
+
 
1190
+/* Number of extent descriptors per extent record */
 
1191
+enum {
 
1192
+       kHFSExtentDensity       = 3,
 
1193
+       kHFSPlusExtentDensity   = 8
 
1194
+}PACKED_S;
 
1195
+
 
1196
+/* HFS extent descriptor */
 
1197
+struct HFSExtentDescriptor {
 
1198
+       u_int16_t       startBlock;             /* first allocation block */
 
1199
+       u_int16_t       blockCount;             /* number of allocation blocks */
 
1200
+}PACKED_S;
 
1201
+typedef struct HFSExtentDescriptor HFSExtentDescriptor;
 
1202
+
 
1203
+/* HFS Plus extent descriptor */
 
1204
+struct HFSPlusExtentDescriptor {
 
1205
+       u_int32_t       startBlock;             /* first allocation block */
 
1206
+       u_int32_t       blockCount;             /* number of allocation blocks */
 
1207
+}PACKED_S;
 
1208
+typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor;
 
1209
+
 
1210
+/* HFS extent record */
 
1211
+typedef HFSExtentDescriptor HFSExtentRecord[3];
 
1212
+
 
1213
+/* HFS Plus extent record */
 
1214
+typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
 
1215
+
 
1216
+
 
1217
+/* Finder information */
 
1218
+struct FndrFileInfo {
 
1219
+       u_int32_t       fdType;         /* file type */
 
1220
+       u_int32_t       fdCreator;      /* file creator */
 
1221
+       u_int16_t       fdFlags;        /* Finder flags */
 
1222
+       struct {
 
1223
+           int16_t     v;              /* file's location */
 
1224
+           int16_t     h;
 
1225
+       } PACKED_S fdLocation;
 
1226
+       int16_t         opaque;
 
1227
+}PACKED_S;
 
1228
+typedef struct FndrFileInfo FndrFileInfo;
 
1229
+
 
1230
+struct FndrDirInfo {
 
1231
+       struct {                        /* folder's window rectangle */
 
1232
+           int16_t     top;
 
1233
+           int16_t     left;
 
1234
+           int16_t     bottom;
 
1235
+           int16_t     right;
 
1236
+       }PACKED_S frRect;
 
1237
+       unsigned short  frFlags;        /* Finder flags */
 
1238
+       struct {
 
1239
+           u_int16_t   v;              /* folder's location */
 
1240
+           u_int16_t   h;
 
1241
+       }PACKED_S frLocation;
 
1242
+       int16_t         opaque;
 
1243
+}PACKED_S;
 
1244
+typedef struct FndrDirInfo FndrDirInfo;
 
1245
+
 
1246
+struct FndrOpaqueInfo {
 
1247
+       int8_t opaque[16];
 
1248
+}PACKED_S;
 
1249
+typedef struct FndrOpaqueInfo FndrOpaqueInfo;
 
1250
+
 
1251
+
 
1252
+/* HFS Plus Fork data info - 80 bytes */
 
1253
+struct HFSPlusForkData {
 
1254
+       u_int64_t               logicalSize;    /* fork's logical size in bytes */
 
1255
+       u_int32_t               clumpSize;      /* fork's clump size in bytes */
 
1256
+       u_int32_t               totalBlocks;    /* total blocks used by this fork */
 
1257
+       HFSPlusExtentRecord     extents;        /* initial set of extents */
 
1258
+}PACKED_S;
 
1259
+typedef struct HFSPlusForkData HFSPlusForkData;
 
1260
+
 
1261
+
 
1262
+/* Mac OS X has 16 bytes worth of "BSD" info.
 
1263
+ *
 
1264
+ * Note:  Mac OS 9 implementations and applications
 
1265
+ * should preserve, but not change, this information.
 
1266
+ */
 
1267
+struct HFSPlusBSDInfo {
 
1268
+       u_int32_t       ownerID;        /* user or group ID of file/folder owner */
 
1269
+       u_int32_t       groupID;        /* additional user of group ID */
 
1270
+       u_int8_t        adminFlags;     /* super-user changeable flags */
 
1271
+       u_int8_t        ownerFlags;     /* owner changeable flags */
 
1272
+       u_int16_t       fileMode;       /* file type and permission bits */
 
1273
+       union {
 
1274
+           u_int32_t   iNodeNum;       /* indirect node number (hard links only) */
 
1275
+           u_int32_t   linkCount;      /* links that refer to this indirect node */
 
1276
+           u_int32_t   rawDevice;      /* special file device (FBLK and FCHR only) */
 
1277
+       }PACKED_S special;
 
1278
+}PACKED_S;
 
1279
+typedef struct HFSPlusBSDInfo HFSPlusBSDInfo;
 
1280
+
 
1281
+
 
1282
+/* Catalog file data structures */
 
1283
+
 
1284
+enum {
 
1285
+       kHFSRootParentID                = 1,    /* Parent ID of the root folder */
 
1286
+       kHFSRootFolderID                = 2,    /* Folder ID of the root folder */
 
1287
+       kHFSExtentsFileID               = 3,    /* File ID of the extents file */
 
1288
+       kHFSCatalogFileID               = 4,    /* File ID of the catalog file */
 
1289
+       kHFSBadBlockFileID              = 5,    /* File ID of the bad allocation block file */
 
1290
+       kHFSAllocationFileID            = 6,    /* File ID of the allocation file (HFS Plus only) */
 
1291
+       kHFSStartupFileID               = 7,    /* File ID of the startup file (HFS Plus only) */
 
1292
+       kHFSAttributesFileID            = 8,    /* File ID of the attribute file (HFS Plus only) */
 
1293
+       kHFSRepairCatalogFileID         = 14,   /* Used when rebuilding Catalog B-tree */
 
1294
+       kHFSBogusExtentFileID           = 15,   /* Used for exchanging extents in extents file */
 
1295
+       kHFSFirstUserCatalogNodeID      = 16
 
1296
+}PACKED_S;
 
1297
+
 
1298
+/* HFS catalog key */
 
1299
+struct HFSCatalogKey {
 
1300
+       u_int8_t        keyLength;              /* key length (in bytes) */
 
1301
+       u_int8_t        reserved;               /* reserved (set to zero) */
 
1302
+       u_int32_t       parentID;               /* parent folder ID */
 
1303
+       u_int8_t        nodeName[kHFSMaxFileNameChars + 1]; /* catalog node name */
 
1304
+}PACKED_S;
 
1305
+typedef struct HFSCatalogKey HFSCatalogKey;
 
1306
+
 
1307
+/* HFS Plus catalog key */
 
1308
+struct HFSPlusCatalogKey {
 
1309
+       u_int16_t               keyLength;      /* key length (in bytes) */
 
1310
+       u_int32_t               parentID;       /* parent folder ID */
 
1311
+       HFSUniStr255            nodeName;       /* catalog node name */
 
1312
+}PACKED_S;
 
1313
+typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
 
1314
+
 
1315
+/* Catalog record types */
 
1316
+enum {
 
1317
+       /* HFS Catalog Records */
 
1318
+       kHFSFolderRecord                = 0x0100,       /* Folder record */
 
1319
+       kHFSFileRecord                  = 0x0200,       /* File record */
 
1320
+       kHFSFolderThreadRecord          = 0x0300,       /* Folder thread record */
 
1321
+       kHFSFileThreadRecord            = 0x0400,       /* File thread record */
 
1322
+
 
1323
+       /* HFS Plus Catalog Records */
 
1324
+       kHFSPlusFolderRecord            = 1,            /* Folder record */
 
1325
+       kHFSPlusFileRecord              = 2,            /* File record */
 
1326
+       kHFSPlusFolderThreadRecord      = 3,            /* Folder thread record */
 
1327
+       kHFSPlusFileThreadRecord        = 4             /* File thread record */
 
1328
+}PACKED_S;
 
1329
+
 
1330
+
 
1331
+/* Catalog file record flags */
 
1332
+enum {
 
1333
+       kHFSFileLockedBit       = 0x0000,       /* file is locked and cannot be written to */
 
1334
+       kHFSFileLockedMask      = 0x0001,
 
1335
+
 
1336
+       kHFSThreadExistsBit     = 0x0001,       /* a file thread record exists for this file */
 
1337
+       kHFSThreadExistsMask    = 0x0002,
 
1338
+
 
1339
+       kHFSHasAttributesBit    = 0x0002,       /* object has extended attributes */
 
1340
+       kHFSHasAttributesMask   = 0x0004,
 
1341
+
 
1342
+       kHFSHasSecurityBit      = 0x0003,       /* object has security data (ACLs) */
 
1343
+       kHFSHasSecurityMask     = 0x0008
 
1344
+}PACKED_S;
 
1345
+
 
1346
+
 
1347
+/* HFS catalog folder record - 70 bytes */
 
1348
+struct HFSCatalogFolder {
 
1349
+       int16_t                 recordType;             /* == kHFSFolderRecord */
 
1350
+       u_int16_t               flags;                  /* folder flags */
 
1351
+       u_int16_t               valence;                /* folder valence */
 
1352
+       u_int32_t               folderID;               /* folder ID */
 
1353
+       u_int32_t               createDate;             /* date and time of creation */
 
1354
+       u_int32_t               modifyDate;             /* date and time of last modification */
 
1355
+       u_int32_t               backupDate;             /* date and time of last backup */
 
1356
+       FndrDirInfo             userInfo;               /* Finder information */
 
1357
+       FndrOpaqueInfo          finderInfo;             /* additional Finder information */
 
1358
+       u_int32_t               reserved[4];            /* reserved - initialized as zero */
 
1359
+}PACKED_S;
 
1360
+typedef struct HFSCatalogFolder HFSCatalogFolder;
 
1361
+
 
1362
+/* HFS Plus catalog folder record - 88 bytes */
 
1363
+struct HFSPlusCatalogFolder {
 
1364
+       int16_t                 recordType;             /* == kHFSPlusFolderRecord */
 
1365
+       u_int16_t               flags;                  /* file flags */
 
1366
+       u_int32_t               valence;                /* folder's valence (limited to 2^16 in Mac OS) */
 
1367
+       u_int32_t               folderID;               /* folder ID */
 
1368
+       u_int32_t               createDate;             /* date and time of creation */
 
1369
+       u_int32_t               contentModDate;         /* date and time of last content modification */
 
1370
+       u_int32_t               attributeModDate;       /* date and time of last attribute modification */
 
1371
+       u_int32_t               accessDate;             /* date and time of last access (MacOS X only) */
 
1372
+       u_int32_t               backupDate;             /* date and time of last backup */
 
1373
+       HFSPlusBSDInfo          bsdInfo;                /* permissions (for MacOS X) */
 
1374
+       FndrDirInfo             userInfo;               /* Finder information */
 
1375
+       FndrOpaqueInfo          finderInfo;             /* additional Finder information */
 
1376
+       u_int32_t               textEncoding;           /* hint for name conversions */
 
1377
+       u_int32_t               attrBlocks;             /* cached count of attribute data blocks */
 
1378
+}PACKED_S;
 
1379
+typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder;
 
1380
+
 
1381
+/* HFS catalog file record - 102 bytes */
 
1382
+struct HFSCatalogFile {
 
1383
+       int16_t                 recordType;             /* == kHFSFileRecord */
 
1384
+       u_int8_t                flags;                  /* file flags */
 
1385
+       int8_t                  fileType;               /* file type (unused ?) */
 
1386
+       FndrFileInfo            userInfo;               /* Finder information */
 
1387
+       u_int32_t               fileID;                 /* file ID */
 
1388
+       u_int16_t               dataStartBlock;         /* not used - set to zero */
 
1389
+       int32_t                 dataLogicalSize;        /* logical EOF of data fork */
 
1390
+       int32_t                 dataPhysicalSize;       /* physical EOF of data fork */
 
1391
+       u_int16_t               rsrcStartBlock;         /* not used - set to zero */
 
1392
+       int32_t                 rsrcLogicalSize;        /* logical EOF of resource fork */
 
1393
+       int32_t                 rsrcPhysicalSize;       /* physical EOF of resource fork */
 
1394
+       u_int32_t               createDate;             /* date and time of creation */
 
1395
+       u_int32_t               modifyDate;             /* date and time of last modification */
 
1396
+       u_int32_t               backupDate;             /* date and time of last backup */
 
1397
+       FndrOpaqueInfo          finderInfo;             /* additional Finder information */
 
1398
+       u_int16_t               clumpSize;              /* file clump size (not used) */
 
1399
+       HFSExtentRecord         dataExtents;            /* first data fork extent record */
 
1400
+       HFSExtentRecord         rsrcExtents;            /* first resource fork extent record */
 
1401
+       u_int32_t               reserved;               /* reserved - initialized as zero */
 
1402
+}PACKED_S;
 
1403
+typedef struct HFSCatalogFile HFSCatalogFile;
 
1404
+
 
1405
+/* HFS Plus catalog file record - 248 bytes */
 
1406
+struct HFSPlusCatalogFile {
 
1407
+       int16_t                 recordType;             /* == kHFSPlusFileRecord */
 
1408
+       u_int16_t               flags;                  /* file flags */
 
1409
+       u_int32_t               reserved1;              /* reserved - initialized as zero */
 
1410
+       u_int32_t               fileID;                 /* file ID */
 
1411
+       u_int32_t               createDate;             /* date and time of creation */
 
1412
+       u_int32_t               contentModDate;         /* date and time of last content modification */
 
1413
+       u_int32_t               attributeModDate;       /* date and time of last attribute modification */
 
1414
+       u_int32_t               accessDate;             /* date and time of last access (MacOS X only) */
 
1415
+       u_int32_t               backupDate;             /* date and time of last backup */
 
1416
+       HFSPlusBSDInfo          bsdInfo;                /* permissions (for MacOS X) */
 
1417
+       FndrFileInfo            userInfo;               /* Finder information */
 
1418
+       FndrOpaqueInfo          finderInfo;             /* additional Finder information */
 
1419
+       u_int32_t               textEncoding;           /* hint for name conversions */
 
1420
+       u_int32_t               attrBlocks;             /* cached count of attribute data blocks */
 
1421
+
 
1422
+       /* Note: these start on double long (64 bit) boundry */
 
1423
+       HFSPlusForkData         dataFork;               /* size and block data for data fork */
 
1424
+       HFSPlusForkData         resourceFork;           /* size and block data for resource fork */
 
1425
+}PACKED_S;
 
1426
+typedef struct HFSPlusCatalogFile HFSPlusCatalogFile;
 
1427
+
 
1428
+/* HFS catalog thread record - 46 bytes */
 
1429
+struct HFSCatalogThread {
 
1430
+       int16_t         recordType;             /* == kHFSFolderThreadRecord or kHFSFileThreadRecord */
 
1431
+       int32_t         reserved[2];            /* reserved - initialized as zero */
 
1432
+       u_int32_t       parentID;               /* parent ID for this catalog node */
 
1433
+       u_int8_t        nodeName[kHFSMaxFileNameChars + 1]; /* name of this catalog node */
 
1434
+}PACKED_S;
 
1435
+typedef struct HFSCatalogThread HFSCatalogThread;
 
1436
+
 
1437
+/* HFS Plus catalog thread record -- 264 bytes */
 
1438
+struct HFSPlusCatalogThread {
 
1439
+       int16_t         recordType;             /* == kHFSPlusFolderThreadRecord or kHFSPlusFileThreadRecord */
 
1440
+       int16_t         reserved;               /* reserved - initialized as zero */
 
1441
+       u_int32_t       parentID;               /* parent ID for this catalog node */
 
1442
+       HFSUniStr255    nodeName;               /* name of this catalog node (variable length) */
 
1443
+}PACKED_S;
 
1444
+typedef struct HFSPlusCatalogThread HFSPlusCatalogThread;
 
1445
+
 
1446
+#ifdef __APPLE_API_UNSTABLE
 
1447
+/*
 
1448
+       These are the types of records in the attribute B-tree.  The values were
 
1449
+       chosen so that they wouldn't conflict with the catalog record types.
 
1450
+*/
 
1451
+enum {
 
1452
+       kHFSPlusAttrInlineData  = 0x10,    /* if size <  kAttrOverflowSize */
 
1453
+       kHFSPlusAttrForkData    = 0x20,    /* if size >= kAttrOverflowSize */
 
1454
+       kHFSPlusAttrExtents     = 0x30     /* overflow extents for large attributes */
 
1455
+}PACKED_S;
 
1456
+
 
1457
+
 
1458
+/*
 
1459
+       HFSPlusAttrForkData
 
1460
+       For larger attributes, whose value is stored in allocation blocks.
 
1461
+       If the attribute has more than 8 extents, there will be additonal
 
1462
+       records (of type HFSPlusAttrExtents) for this attribute.
 
1463
+*/
 
1464
+struct HFSPlusAttrForkData {
 
1465
+       u_int32_t       recordType;             /* == kHFSPlusAttrForkData*/
 
1466
+       u_int32_t       reserved;
 
1467
+       HFSPlusForkData theFork;                /* size and first extents of value*/
 
1468
+}PACKED_S;
 
1469
+typedef struct HFSPlusAttrForkData HFSPlusAttrForkData;
 
1470
+
 
1471
+/*
 
1472
+       HFSPlusAttrExtents
 
1473
+       This record contains information about overflow extents for large,
 
1474
+       fragmented attributes.
 
1475
+*/
 
1476
+struct HFSPlusAttrExtents {
 
1477
+       u_int32_t               recordType;     /* == kHFSPlusAttrExtents*/
 
1478
+       u_int32_t               reserved;
 
1479
+       HFSPlusExtentRecord     extents;        /* additional extents*/
 
1480
+}PACKED_S;
 
1481
+typedef struct HFSPlusAttrExtents HFSPlusAttrExtents;
 
1482
+
 
1483
+/*
 
1484
+ * Atrributes B-tree Data Record
 
1485
+ *
 
1486
+ * For small attributes, whose entire value is stored
 
1487
+ * within a single B-tree record.
 
1488
+ */
 
1489
+struct HFSPlusAttrData {
 
1490
+       u_int32_t    recordType;   /* == kHFSPlusAttrInlineData */
 
1491
+       u_int32_t    reserved[2];
 
1492
+       u_int32_t    attrSize;     /* size of attribute data in bytes */
 
1493
+       u_int8_t     attrData[2];  /* variable length */
 
1494
+}PACKED_S;
 
1495
+typedef struct HFSPlusAttrData HFSPlusAttrData;
 
1496
+
 
1497
+
 
1498
+/* HFSPlusAttrInlineData is obsolete use HFSPlusAttrData instead */
 
1499
+struct HFSPlusAttrInlineData {
 
1500
+       u_int32_t       recordType;
 
1501
+       u_int32_t       reserved;
 
1502
+       u_int32_t       logicalSize;
 
1503
+       u_int8_t        userData[2];
 
1504
+}PACKED_S;
 
1505
+typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData;
 
1506
+
 
1507
+
 
1508
+/*     A generic Attribute Record*/
 
1509
+union HFSPlusAttrRecord {
 
1510
+       u_int32_t               recordType;
 
1511
+       HFSPlusAttrInlineData   inlineData;   /* NOT USED */
 
1512
+       HFSPlusAttrData         attrData;
 
1513
+       HFSPlusAttrForkData     forkData;
 
1514
+       HFSPlusAttrExtents      overflowExtents;
 
1515
+}PACKED_S;
 
1516
+typedef union HFSPlusAttrRecord HFSPlusAttrRecord;
 
1517
+
 
1518
+/* Attribute key */
 
1519
+enum { kHFSMaxAttrNameLen = 127 };
 
1520
+struct HFSPlusAttrKey {
 
1521
+       u_int16_t     keyLength;       /* key length (in bytes) */
 
1522
+       u_int16_t     pad;             /* set to zero */
 
1523
+       u_int32_t     fileID;          /* file associated with attribute */
 
1524
+       u_int32_t     startBlock;      /* first attribue allocation block number for extents */
 
1525
+       u_int16_t     attrNameLen;     /* number of unicode characters */
 
1526
+       u_int16_t     attrName[127];   /* attribute name (Unicode) */
 
1527
+}PACKED_S;
 
1528
+typedef struct HFSPlusAttrKey HFSPlusAttrKey;
 
1529
+
 
1530
+#define kHFSPlusAttrKeyMaximumLength   (sizeof(HFSPlusAttrKey) - sizeof(u_int16_t))
 
1531
+#define kHFSPlusAttrKeyMinimumLength   (kHFSPlusAttrKeyMaximumLength - (127 * sizeof(u_int16_t)))
 
1532
+
 
1533
+#endif /* __APPLE_API_UNSTABLE */
 
1534
+
 
1535
+
 
1536
+/* Key and node lengths */
 
1537
+enum {
 
1538
+       kHFSPlusExtentKeyMaximumLength = sizeof(HFSPlusExtentKey) - sizeof(u_int16_t),
 
1539
+       kHFSExtentKeyMaximumLength      = sizeof(HFSExtentKey) - sizeof(u_int8_t),
 
1540
+       kHFSPlusCatalogKeyMaximumLength = sizeof(HFSPlusCatalogKey) - sizeof(u_int16_t),
 
1541
+       kHFSPlusCatalogKeyMinimumLength = kHFSPlusCatalogKeyMaximumLength - sizeof(HFSUniStr255) + sizeof(u_int16_t),
 
1542
+       kHFSCatalogKeyMaximumLength     = sizeof(HFSCatalogKey) - sizeof(u_int8_t),
 
1543
+       kHFSCatalogKeyMinimumLength     = kHFSCatalogKeyMaximumLength - (kHFSMaxFileNameChars + 1) + sizeof(u_int8_t),
 
1544
+       kHFSPlusCatalogMinNodeSize      = 4096,
 
1545
+       kHFSPlusExtentMinNodeSize       = 512,
 
1546
+       kHFSPlusAttrMinNodeSize         = 4096
 
1547
+}PACKED_S;
 
1548
+
 
1549
+/* HFS and HFS Plus volume attribute bits */
 
1550
+enum {
 
1551
+                                                       /* Bits 0-6 are reserved (always cleared by MountVol call) */
 
1552
+       kHFSVolumeHardwareLockBit       = 7,            /* volume is locked by hardware */
 
1553
+       kHFSVolumeUnmountedBit          = 8,            /* volume was successfully unmounted */
 
1554
+       kHFSVolumeSparedBlocksBit       = 9,            /* volume has bad blocks spared */
 
1555
+       kHFSVolumeNoCacheRequiredBit = 10,              /* don't cache volume blocks (i.e. RAM or ROM disk) */
 
1556
+       kHFSBootVolumeInconsistentBit = 11,             /* boot volume is inconsistent (System 7.6 and later) */
 
1557
+       kHFSCatalogNodeIDsReusedBit = 12,
 
1558
+       kHFSVolumeJournaledBit = 13,                    /* this volume has a journal on it */
 
1559
+       kHFSVolumeInconsistentBit = 14,                 /* serious inconsistencies detected at runtime */
 
1560
+       kHFSVolumeSoftwareLockBit       = 15,           /* volume is locked by software */
 
1561
+
 
1562
+       kHFSVolumeHardwareLockMask      = 1 << kHFSVolumeHardwareLockBit,
 
1563
+       kHFSVolumeUnmountedMask         = 1 << kHFSVolumeUnmountedBit,
 
1564
+       kHFSVolumeSparedBlocksMask      = 1 << kHFSVolumeSparedBlocksBit,
 
1565
+       kHFSVolumeNoCacheRequiredMask = 1 << kHFSVolumeNoCacheRequiredBit,
 
1566
+       kHFSBootVolumeInconsistentMask = 1 << kHFSBootVolumeInconsistentBit,
 
1567
+       kHFSCatalogNodeIDsReusedMask = 1 << kHFSCatalogNodeIDsReusedBit,
 
1568
+       kHFSVolumeJournaledMask = 1 << kHFSVolumeJournaledBit,
 
1569
+       kHFSVolumeInconsistentMask = 1 << kHFSVolumeInconsistentBit,
 
1570
+       kHFSVolumeSoftwareLockMask      = 1 << kHFSVolumeSoftwareLockBit,
 
1571
+       kHFSMDBAttributesMask           = 0x8380
 
1572
+}PACKED_S;
 
1573
+
 
1574
+
 
1575
+/* HFS Master Directory Block - 162 bytes */
 
1576
+/* Stored at sector #2 (3rd sector) and second-to-last sector. */
 
1577
+struct HFSMasterDirectoryBlock {
 
1578
+       u_int16_t               drSigWord;      /* == kHFSSigWord */
 
1579
+       u_int32_t               drCrDate;       /* date and time of volume creation */
 
1580
+       u_int32_t               drLsMod;        /* date and time of last modification */
 
1581
+       u_int16_t               drAtrb;         /* volume attributes */
 
1582
+       u_int16_t               drNmFls;        /* number of files in root folder */
 
1583
+       u_int16_t               drVBMSt;        /* first block of volume bitmap */
 
1584
+       u_int16_t               drAllocPtr;     /* start of next allocation search */
 
1585
+       u_int16_t               drNmAlBlks;     /* number of allocation blocks in volume */
 
1586
+       u_int32_t               drAlBlkSiz;     /* size (in bytes) of allocation blocks */
 
1587
+       u_int32_t               drClpSiz;       /* default clump size */
 
1588
+       u_int16_t               drAlBlSt;       /* first allocation block in volume */
 
1589
+       u_int32_t               drNxtCNID;      /* next unused catalog node ID */
 
1590
+       u_int16_t               drFreeBks;      /* number of unused allocation blocks */
 
1591
+       u_int8_t                drVN[kHFSMaxVolumeNameChars + 1];  /* volume name */
 
1592
+       u_int32_t               drVolBkUp;      /* date and time of last backup */
 
1593
+       u_int16_t               drVSeqNum;      /* volume backup sequence number */
 
1594
+       u_int32_t               drWrCnt;        /* volume write count */
 
1595
+       u_int32_t               drXTClpSiz;     /* clump size for extents overflow file */
 
1596
+       u_int32_t               drCTClpSiz;     /* clump size for catalog file */
 
1597
+       u_int16_t               drNmRtDirs;     /* number of directories in root folder */
 
1598
+       u_int32_t               drFilCnt;       /* number of files in volume */
 
1599
+       u_int32_t               drDirCnt;       /* number of directories in volume */
 
1600
+       u_int32_t               drFndrInfo[8];  /* information used by the Finder */
 
1601
+       u_int16_t               drEmbedSigWord; /* embedded volume signature (formerly drVCSize) */
 
1602
+       HFSExtentDescriptor     drEmbedExtent;  /* embedded volume location and size (formerly drVBMCSize and drCtlCSize) */
 
1603
+       u_int32_t               drXTFlSize;     /* size of extents overflow file */
 
1604
+       HFSExtentRecord         drXTExtRec;     /* extent record for extents overflow file */
 
1605
+       u_int32_t               drCTFlSize;     /* size of catalog file */
 
1606
+       HFSExtentRecord         drCTExtRec;     /* extent record for catalog file */
 
1607
+}PACKED_S;
 
1608
+typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock;
 
1609
+
 
1610
+
 
1611
+#ifdef __APPLE_API_UNSTABLE
 
1612
+#define SET_HFS_TEXT_ENCODING(hint)  \
 
1613
+       (0x656e6300 | ((hint) & 0xff))
 
1614
+#define GET_HFS_TEXT_ENCODING(hint)  \
 
1615
+       (((hint) & 0xffffff00) == 0x656e6300 ? (hint) & 0x000000ff : 0xffffffffU)
 
1616
+#endif /* __APPLE_API_UNSTABLE */
 
1617
+
 
1618
+
 
1619
+/* HFS Plus Volume Header - 512 bytes */
 
1620
+/* Stored at sector #2 (3rd sector) and second-to-last sector. */
 
1621
+struct HFSPlusVolumeHeader {
 
1622
+       u_int16_t       signature;              /* == kHFSPlusSigWord */
 
1623
+       u_int16_t       version;                /* == kHFSPlusVersion */
 
1624
+       u_int32_t       attributes;             /* volume attributes */
 
1625
+       u_int32_t       lastMountedVersion;     /* implementation version which last mounted volume */
 
1626
+       u_int32_t       journalInfoBlock;       /* block addr of journal info (if volume is journaled, zero otherwise) */
 
1627
+
 
1628
+       u_int32_t       createDate;             /* date and time of volume creation */
 
1629
+       u_int32_t       modifyDate;             /* date and time of last modification */
 
1630
+       u_int32_t       backupDate;             /* date and time of last backup */
 
1631
+       u_int32_t       checkedDate;            /* date and time of last disk check */
 
1632
+
 
1633
+       u_int32_t       fileCount;              /* number of files in volume */
 
1634
+       u_int32_t       folderCount;            /* number of directories in volume */
 
1635
+
 
1636
+       u_int32_t       blockSize;              /* size (in bytes) of allocation blocks */
 
1637
+       u_int32_t       totalBlocks;            /* number of allocation blocks in volume (includes this header and VBM*/
 
1638
+       u_int32_t       freeBlocks;             /* number of unused allocation blocks */
 
1639
+
 
1640
+       u_int32_t       nextAllocation;         /* start of next allocation search */
 
1641
+       u_int32_t       rsrcClumpSize;          /* default resource fork clump size */
 
1642
+       u_int32_t       dataClumpSize;          /* default data fork clump size */
 
1643
+       u_int32_t       nextCatalogID;          /* next unused catalog node ID */
 
1644
+
 
1645
+       u_int32_t       writeCount;             /* volume write count */
 
1646
+       u_int64_t       encodingsBitmap;        /* which encodings have been use  on this volume */
 
1647
+
 
1648
+       u_int8_t        finderInfo[32];         /* information used by the Finder */
 
1649
+
 
1650
+       HFSPlusForkData  allocationFile;        /* allocation bitmap file */
 
1651
+       HFSPlusForkData  extentsFile;           /* extents B-tree file */
 
1652
+       HFSPlusForkData  catalogFile;           /* catalog B-tree file */
 
1653
+       HFSPlusForkData  attributesFile;        /* extended attributes B-tree file */
 
1654
+       HFSPlusForkData  startupFile;           /* boot file (secondary loader) */
 
1655
+}PACKED_S;
 
1656
+typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader;
 
1657
+
 
1658
+
 
1659
+/* B-tree structures */
 
1660
+
 
1661
+enum BTreeKeyLimits{
 
1662
+       kMaxKeyLength   = 520
 
1663
+}PACKED_S;
 
1664
+
 
1665
+union BTreeKey{
 
1666
+       u_int8_t        length8;
 
1667
+       u_int16_t       length16;
 
1668
+       u_int8_t        rawData [kMaxKeyLength+2];
 
1669
+}PACKED_S;
 
1670
+typedef union BTreeKey BTreeKey;
 
1671
+
 
1672
+/* BTNodeDescriptor -- Every B-tree node starts with these fields. */
 
1673
+struct BTNodeDescriptor {
 
1674
+       u_int32_t       fLink;                  /* next node at this level*/
 
1675
+       u_int32_t       bLink;                  /* previous node at this level*/
 
1676
+       int8_t          kind;                   /* kind of node (leaf, index, header, map)*/
 
1677
+       u_int8_t        height;                 /* zero for header, map; child is one more than parent*/
 
1678
+       u_int16_t       numRecords;             /* number of records in this node*/
 
1679
+       u_int16_t       reserved;               /* reserved - initialized as zero */
 
1680
+}PACKED_S;
 
1681
+typedef struct BTNodeDescriptor BTNodeDescriptor;
 
1682
+
 
1683
+/* Constants for BTNodeDescriptor kind */
 
1684
+enum {
 
1685
+       kBTLeafNode     = -1,
 
1686
+       kBTIndexNode    = 0,
 
1687
+       kBTHeaderNode   = 1,
 
1688
+       kBTMapNode      = 2
 
1689
+}PACKED_S;
 
1690
+
 
1691
+/* BTHeaderRec -- The first record of a B-tree header node */
 
1692
+struct BTHeaderRec {
 
1693
+       u_int16_t       treeDepth;              /* maximum height (usually leaf nodes) */
 
1694
+       u_int32_t       rootNode;               /* node number of root node */
 
1695
+       u_int32_t       leafRecords;            /* number of leaf records in all leaf nodes */
 
1696
+       u_int32_t       firstLeafNode;          /* node number of first leaf node */
 
1697
+       u_int32_t       lastLeafNode;           /* node number of last leaf node */
 
1698
+       u_int16_t       nodeSize;               /* size of a node, in bytes */
 
1699
+       u_int16_t       maxKeyLength;           /* reserved */
 
1700
+       u_int32_t       totalNodes;             /* total number of nodes in tree */
 
1701
+       u_int32_t       freeNodes;              /* number of unused (free) nodes in tree */
 
1702
+       u_int16_t       reserved1;              /* unused */
 
1703
+       u_int32_t       clumpSize;              /* reserved */
 
1704
+       u_int8_t        btreeType;              /* reserved */
 
1705
+       u_int8_t        keyCompareType;         /* Key string Comparison Type */
 
1706
+       u_int32_t       attributes;             /* persistent attributes about the tree */
 
1707
+       u_int32_t       reserved3[16];          /* reserved */
 
1708
+}PACKED_S;
 
1709
+typedef struct BTHeaderRec BTHeaderRec;
 
1710
+
 
1711
+/* Constants for BTHeaderRec attributes */
 
1712
+enum {
 
1713
+       kBTBadCloseMask          = 0x00000001,  /* reserved */
 
1714
+       kBTBigKeysMask           = 0x00000002,  /* key length field is 16 bits */
 
1715
+       kBTVariableIndexKeysMask = 0x00000004   /* keys in index nodes are variable length */
 
1716
+}PACKED_S;
 
1717
+
 
1718
+
 
1719
+/* Catalog Key Name Comparison Type */
 
1720
+enum {
 
1721
+       kHFSCaseFolding   = 0xCF,  /* case folding (case-insensitive) */
 
1722
+       kHFSBinaryCompare = 0xBC  /* binary compare (case-sensitive) */
 
1723
+}PACKED_S;
 
1724
+
 
1725
+/* JournalInfoBlock - Structure that describes where our journal lives */
 
1726
+struct JournalInfoBlock {
 
1727
+       u_int32_t       flags;
 
1728
+       u_int32_t       device_signature[8];  // signature used to locate our device.
 
1729
+       u_int64_t       offset;               // byte offset to the journal on the device
 
1730
+       u_int64_t       size;                 // size in bytes of the journal
 
1731
+       u_int32_t       reserved[32];
 
1732
+}PACKED_S;
 
1733
+typedef struct JournalInfoBlock JournalInfoBlock;
 
1734
+
 
1735
+enum {
 
1736
+    kJIJournalInFSMask          = 0x00000001,
 
1737
+    kJIJournalOnOtherDeviceMask = 0x00000002,
 
1738
+    kJIJournalNeedInitMask      = 0x00000004
 
1739
+}PACKED_S;
 
1740
+
 
1741
+#ifdef __cplusplus
 
1742
+}
 
1743
+#endif
 
1744
+
 
1745
+#endif /* __HFS_FORMAT__ */
 
1746
Index: hfsprogs-332.14/include/hfs/hfs_mount.h
 
1747
===================================================================
 
1748
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
 
1749
+++ hfsprogs-332.14/include/hfs/hfs_mount.h     2007-07-17 13:02:59.000000000 -0300
 
1750
@@ -0,0 +1,78 @@
 
1751
+/*
 
1752
+ * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
 
1753
+ *
 
1754
+ * @APPLE_LICENSE_HEADER_START@
 
1755
+ * 
 
1756
+ * The contents of this file constitute Original Code as defined in and
 
1757
+ * are subject to the Apple Public Source License Version 1.1 (the
 
1758
+ * "License").  You may not use this file except in compliance with the
 
1759
+ * License.  Please obtain a copy of the License at
 
1760
+ * http://www.apple.com/publicsource and read it before using this file.
 
1761
+ * 
 
1762
+ * This Original Code and all software distributed under the License are
 
1763
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 
1764
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 
1765
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 
1766
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
 
1767
+ * License for the specific language governing rights and limitations
 
1768
+ * under the License.
 
1769
+ * 
 
1770
+ * @APPLE_LICENSE_HEADER_END@
 
1771
+ */
 
1772
+/*
 
1773
+ * Copyright (c) 1997-2002 Apple Computer, Inc. All Rights Reserved
 
1774
+ *
 
1775
+ */
 
1776
+
 
1777
+#ifndef _HFS_MOUNT_H_
 
1778
+#define _HFS_MOUNT_H_
 
1779
+
 
1780
+#include <sys/appleapiopts.h>
 
1781
+
 
1782
+#include <sys/mount.h>
 
1783
+#include <sys/time.h>
 
1784
+
 
1785
+/*
 
1786
+ * Arguments to mount HFS-based filesystems
 
1787
+ */
 
1788
+
 
1789
+#define OVERRIDE_UNKNOWN_PERMISSIONS 0
 
1790
+
 
1791
+#define UNKNOWNUID ((uid_t)99)
 
1792
+#define UNKNOWNGID ((gid_t)99)
 
1793
+#define UNKNOWNPERMISSIONS (S_IRWXU | S_IROTH | S_IXOTH)               /* 705 */
 
1794
+
 
1795
+#ifdef __APPLE_API_UNSTABLE
 
1796
+struct hfs_mount_args {
 
1797
+#ifndef KERNEL
 
1798
+       char    *fspec;                 /* block special device to mount */
 
1799
+#endif
 
1800
+       uid_t   hfs_uid;                /* uid that owns hfs files (standard HFS only) */
 
1801
+       gid_t   hfs_gid;                /* gid that owns hfs files (standard HFS only) */
 
1802
+       mode_t  hfs_mask;               /* mask to be applied for hfs perms  (standard HFS only) */
 
1803
+       u_int32_t hfs_encoding;         /* encoding for this volume (standard HFS only) */
 
1804
+       struct  timezone hfs_timezone;  /* user time zone info (standard HFS only) */
 
1805
+       int             flags;                  /* mounting flags, see below */
 
1806
+       int     journal_tbuffer_size;   /* size in bytes of the journal transaction buffer */
 
1807
+       int             journal_flags;          /* flags to pass to journal_open/create */
 
1808
+       int             journal_disable;        /* don't use journaling (potentially dangerous) */
 
1809
+};
 
1810
+
 
1811
+#define HFSFSMNT_NOXONFILES    0x1     /* disable execute permissions for files */
 
1812
+#define HFSFSMNT_WRAPPER       0x2     /* mount HFS wrapper (if it exists) */
 
1813
+#define HFSFSMNT_EXTENDED_ARGS  0x4     /* indicates new fields after "flags" are valid */
 
1814
+
 
1815
+/*
 
1816
+ * Sysctl values for HFS
 
1817
+ */
 
1818
+#define HFS_ENCODINGBIAS       1           /* encoding matching CJK bias */
 
1819
+#define HFS_EXTEND_FS          2
 
1820
+#define HFS_ENCODINGHINT       3           /* guess encoding for string */
 
1821
+#define HFS_ENABLE_JOURNALING   0x082969
 
1822
+#define HFS_DISABLE_JOURNALING  0x031272
 
1823
+#define HFS_GET_JOURNAL_INFO    0x6a6e6c69
 
1824
+#define HFS_SET_PKG_EXTENSIONS  0x121031
 
1825
+
 
1826
+#endif /* __APPLE_API_UNSTABLE */
 
1827
+
 
1828
+#endif /* ! _HFS_MOUNT_H_ */
 
1829
Index: hfsprogs-332.14/include/missing.h
 
1830
===================================================================
 
1831
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
 
1832
+++ hfsprogs-332.14/include/missing.h   2007-07-17 13:02:59.000000000 -0300
 
1833
@@ -0,0 +1,113 @@
 
1834
+#ifndef _MISSING_H_
 
1835
+#define _MISSING_H_
 
1836
+
 
1837
+#include <endian.h>
 
1838
+#include <byteswap.h>
 
1839
+#include <errno.h>
 
1840
+#include <stdint.h>
 
1841
+
 
1842
+#define MAXBSIZE               (256 * 4096)
 
1843
+
 
1844
+#ifndef true
 
1845
+#define true                   1
 
1846
+#endif
 
1847
+#ifndef false
 
1848
+#define false                  0
 
1849
+#endif
 
1850
+
 
1851
+/* Mac types */
 
1852
+
 
1853
+/* 8 Bit */
 
1854
+#ifndef UInt8
 
1855
+#define UInt8                  uint8_t
 
1856
+#endif
 
1857
+#ifndef u_int8_t
 
1858
+#define u_int8_t               UInt8
 
1859
+#endif
 
1860
+#ifndef SInt8
 
1861
+#define SInt8                  int8_t
 
1862
+#endif
 
1863
+
 
1864
+/* 16 Bit */
 
1865
+#ifndef UInt16
 
1866
+#define UInt16                 uint16_t
 
1867
+#endif
 
1868
+#ifndef u_int16_t
 
1869
+#define u_int16_t              UInt16
 
1870
+#endif
 
1871
+#ifndef SInt16
 
1872
+#define SInt16                 int16_t
 
1873
+#endif
 
1874
+
 
1875
+/* 32 Bit */
 
1876
+#ifndef UInt32
 
1877
+#define UInt32                 uint32_t
 
1878
+#endif
 
1879
+#ifndef u_int32_t
 
1880
+#define u_int32_t              UInt32
 
1881
+#endif
 
1882
+#ifndef SInt32
 
1883
+#define SInt32                 int32_t
 
1884
+#endif
 
1885
+
 
1886
+/* 64 Bit */
 
1887
+#ifndef UInt64
 
1888
+#define UInt64                 uint64_t
 
1889
+#endif
 
1890
+#ifndef u_int64_t
 
1891
+#define u_int64_t              UInt64
 
1892
+#endif
 
1893
+#ifndef SInt64
 
1894
+#define SInt64                 int64_t
 
1895
+#endif
 
1896
+
 
1897
+#define UniChar                        u_int16_t
 
1898
+#define Boolean                        u_int8_t
 
1899
+
 
1900
+#define UF_NODUMP      0x00000001
 
1901
+
 
1902
+/* syslimits.h */
 
1903
+#define NAME_MAX       255
 
1904
+
 
1905
+/* Byteswap stuff */
 
1906
+#define NXSwapHostLongToBig(x)         cpu_to_be64(x)
 
1907
+#define NXSwapBigShortToHost(x)        be16_to_cpu(x)
 
1908
+#define OSSwapBigToHostInt16(x)                be16_to_cpu(x)
 
1909
+#define NXSwapBigLongToHost(x)         be32_to_cpu(x)
 
1910
+#define OSSwapBigToHostInt32(x)                be32_to_cpu(x)
 
1911
+#define NXSwapBigLongLongToHost(x)     be64_to_cpu(x)
 
1912
+#define OSSwapBigToHostInt64(x)                be64_to_cpu(x)
 
1913
+
 
1914
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 
1915
+/* Big Endian Swaps */
 
1916
+#ifndef be16_to_cpu
 
1917
+#define be16_to_cpu(x) bswap_16(x)
 
1918
+#endif
 
1919
+#ifndef be32_to_cpu
 
1920
+#define be32_to_cpu(x) bswap_32(x)
 
1921
+#endif
 
1922
+#ifndef be64_to_cpu
 
1923
+#define be64_to_cpu(x) bswap_64(x)
 
1924
+#endif
 
1925
+#ifndef cpu_to_be64
 
1926
+#define cpu_to_be64(x) bswap_64(x) 
 
1927
+#endif
 
1928
+#elif __BYTE_ORDER == __BIG_ENDIAN
 
1929
+/* Big endian doesn't swap */
 
1930
+#ifndef be16_to_cpu
 
1931
+#define be16_to_cpu(x) (x)
 
1932
+#endif
 
1933
+#ifndef be32_to_cpu
 
1934
+#define be32_to_cpu(x) (x)
 
1935
+#endif
 
1936
+#ifndef be64_to_cpu
 
1937
+#define be64_to_cpu(x) (x)
 
1938
+#endif
 
1939
+#ifndef cpu_to_be64
 
1940
+#define cpu_to_be64(x)         (x)
 
1941
+#endif
 
1942
+#endif
 
1943
+
 
1944
+#define KAUTH_FILESEC_XATTR "com.apple.system.Security"
 
1945
+
 
1946
+#endif
 
1947
Index: hfsprogs-332.14/include/sys/appleapiopts.h
 
1948
===================================================================
 
1949
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
 
1950
+++ hfsprogs-332.14/include/sys/appleapiopts.h  2007-07-17 13:02:59.000000000 -0300
 
1951
@@ -0,0 +1,56 @@
 
1952
+/*
 
1953
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
 
1954
+ *
 
1955
+ * @APPLE_LICENSE_HEADER_START@
 
1956
+ * 
 
1957
+ * The contents of this file constitute Original Code as defined in and
 
1958
+ * are subject to the Apple Public Source License Version 1.1 (the
 
1959
+ * "License").  You may not use this file except in compliance with the
 
1960
+ * License.  Please obtain a copy of the License at
 
1961
+ * http://www.apple.com/publicsource and read it before using this file.
 
1962
+ * 
 
1963
+ * This Original Code and all software distributed under the License are
 
1964
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 
1965
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 
1966
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 
1967
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
 
1968
+ * License for the specific language governing rights and limitations
 
1969
+ * under the License.
 
1970
+ * 
 
1971
+ * @APPLE_LICENSE_HEADER_END@
 
1972
+ */
 
1973
+
 
1974
+#ifndef __SYS_APPLEAPIOPTS_H__
 
1975
+#define __SYS_APPLEAPIOPTS_H__
 
1976
+
 
1977
+
 
1978
+#ifndef __APPLE_API_STANDARD
 
1979
+#define __APPLE_API_STANDARD
 
1980
+#endif /* __APPLE_API_STANDARD */
 
1981
+
 
1982
+#ifndef __APPLE_API_STABLE
 
1983
+#define __APPLE_API_STABLE
 
1984
+#endif /* __APPLE_API_STABLE */
 
1985
+
 
1986
+#ifndef __APPLE_API_STRICT_CONFORMANCE
 
1987
+
 
1988
+#ifndef __APPLE_API_EVOLVING
 
1989
+#define __APPLE_API_EVOLVING
 
1990
+#endif /* __APPLE_API_EVOLVING */
 
1991
+
 
1992
+#ifndef __APPLE_API_UNSTABLE
 
1993
+#define __APPLE_API_UNSTABLE
 
1994
+#endif /* __APPLE_API_UNSTABLE */
 
1995
+
 
1996
+#ifndef __APPLE_API_PRIVATE
 
1997
+#define __APPLE_API_PRIVATE
 
1998
+#endif /* __APPLE_API_PRIVATE */
 
1999
+
 
2000
+#ifndef __APPLE_API_OBSOLETE
 
2001
+#define __APPLE_API_OBSOLETE
 
2002
+#endif /* __APPLE_API_OBSOLETE */
 
2003
+
 
2004
+#endif /* __APPLE_API_STRICT_CONFORMANCE */
 
2005
+
 
2006
+#endif /* __SYS_APPLEAPIOPTS_H__ */
 
2007
+
 
2008
Index: hfsprogs-332.14/newfs_hfs.tproj/Makefile.lnx
 
2009
===================================================================
 
2010
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
 
2011
+++ hfsprogs-332.14/newfs_hfs.tproj/Makefile.lnx        2007-07-17 13:02:59.000000000 -0300
 
2012
@@ -0,0 +1,12 @@
 
2013
+CFILES = hfs_endian.c makehfs.c newfs_hfs.c
 
2014
+OFILES = $(CFILES:.c=.o)
 
2015
+
 
2016
+all: newfs_hfs
 
2017
+
 
2018
+newfs_hfs: $(OFILES)
 
2019
+       ${CC} ${CFLAGS} -o newfs_hfs ${OFILES} -lssl
 
2020
+
 
2021
+clean:
 
2022
+       $(RM) newfs_hfs $(OFILES)
 
2023
+
 
2024
+.PHONY : FORCE clean
 
2025
Index: hfsprogs-332.14/newfs_hfs.tproj/hfs_endian.c
 
2026
===================================================================
 
2027
--- hfsprogs-332.14.orig/newfs_hfs.tproj/hfs_endian.c   2006-02-20 18:45:15.000000000 -0300
 
2028
+++ hfsprogs-332.14/newfs_hfs.tproj/hfs_endian.c        2007-07-17 13:02:59.000000000 -0300
 
2029
@@ -30,7 +30,12 @@
 
2030
 #include <sys/types.h>
 
2031
 #include <sys/stat.h>
 
2032
 
 
2033
+#if LINUX
 
2034
+#include "missing.h"
 
2035
+#else
 
2036
 #include <architecture/byte_order.h>
 
2037
+#endif
 
2038
+
 
2039
 #include <hfs/hfs_format.h>
 
2040
 
 
2041
 #include "hfs_endian.h"
 
2042
Index: hfsprogs-332.14/newfs_hfs.tproj/hfs_endian.h
 
2043
===================================================================
 
2044
--- hfsprogs-332.14.orig/newfs_hfs.tproj/hfs_endian.h   2006-02-20 18:45:15.000000000 -0300
 
2045
+++ hfsprogs-332.14/newfs_hfs.tproj/hfs_endian.h        2007-07-17 13:02:59.000000000 -0300
 
2046
@@ -29,7 +29,12 @@
 
2047
  * volume format.
 
2048
  */
 
2049
 #include <hfs/hfs_format.h>
 
2050
+#if LINUX
 
2051
+#include <endian.h>
 
2052
+#include <byteswap.h>
 
2053
+#else
 
2054
 #include <architecture/byte_order.h>
 
2055
+#endif
 
2056
 
 
2057
 /*********************/
 
2058
 /* BIG ENDIAN Macros */
 
2059
Index: hfsprogs-332.14/newfs_hfs.tproj/makehfs.c
 
2060
===================================================================
 
2061
--- hfsprogs-332.14.orig/newfs_hfs.tproj/makehfs.c      2006-02-20 18:45:15.000000000 -0300
 
2062
+++ hfsprogs-332.14/newfs_hfs.tproj/makehfs.c   2007-07-17 13:02:59.000000000 -0300
 
2063
@@ -31,10 +31,16 @@
 
2064
 #include <sys/param.h>
 
2065
 #include <sys/types.h>
 
2066
 #include <sys/time.h>
 
2067
+#if LINUX
 
2068
+#include <time.h>
 
2069
+#include "missing.h"
 
2070
+#endif
 
2071
 #include <sys/errno.h>
 
2072
 #include <sys/stat.h>
 
2073
 #include <sys/sysctl.h>
 
2074
+#if !LINUX
 
2075
 #include <sys/vmmeter.h>
 
2076
+#endif
 
2077
 
 
2078
 #include <err.h>
 
2079
 #include <errno.h>
 
2080
@@ -47,13 +53,14 @@
 
2081
 
 
2082
 #include <openssl/sha.h>
 
2083
 
 
2084
+#if !LINUX
 
2085
 #include <architecture/byte_order.h>
 
2086
 
 
2087
 #include <CoreFoundation/CFString.h>
 
2088
 #include <CoreFoundation/CFStringEncodingExt.h>
 
2089
 
 
2090
 extern Boolean _CFStringGetFileSystemRepresentation(CFStringRef string, UInt8 *buffer, CFIndex maxBufLen);
 
2091
-
 
2092
+#endif
 
2093
 
 
2094
 #include <hfs/hfs_format.h>
 
2095
 #include <hfs/hfs_mount.h>
 
2096
@@ -129,7 +136,9 @@
 
2097
 static void MarkBitInAllocationBuffer __P((HFSPlusVolumeHeader *header,
 
2098
                UInt32 allocationBlock, void* sectorBuffer, UInt32 *sector));
 
2099
 
 
2100
+#if !LINUX
 
2101
 static UInt32 GetDefaultEncoding();
 
2102
+#endif
 
2103
 
 
2104
 static UInt32 UTCToLocal __P((UInt32 utcTime));
 
2105
 
 
2106
@@ -158,11 +167,14 @@
 
2107
 
 
2108
 #define ROUNDUP(x, u)  (((x) % (u) == 0) ? (x) : ((x)/(u) + 1) * (u))
 
2109
 
 
2110
-#define ENCODING_TO_BIT(e)                               \
 
2111
+#if LINUX
 
2112
+#define ENCODING_TO_BIT(e)       (e)                    
 
2113
+#else
 
2114
+#define ENCODING_TO_BIT(e)
 
2115
           ((e) < 48 ? (e) :                              \
 
2116
           ((e) == kCFStringEncodingMacUkrainian ? 48 :   \
 
2117
           ((e) == kCFStringEncodingMacFarsi ? 49 : 0)))
 
2118
-
 
2119
+#endif
 
2120
 /*
 
2121
  * make_hfs
 
2122
  *     
 
2123
@@ -528,6 +540,7 @@
 
2124
         * Map UTF-8 input into a Mac encoding.
 
2125
         * On conversion errors "untitled" is used as a fallback.
 
2126
         */
 
2127
+#if !LINUX
 
2128
        {
 
2129
                UniChar unibuf[kHFSMaxVolumeNameChars];
 
2130
                CFStringRef cfstr;
 
2131
@@ -553,7 +566,11 @@
 
2132
                bcopy(&mdbp->drVN[1], defaults->volumeName, mdbp->drVN[0]);
 
2133
                defaults->volumeName[mdbp->drVN[0]] = '\0';
 
2134
        }
 
2135
+#endif
 
2136
        /* Save the encoding hint in the Finder Info (field 4). */
 
2137
+       mdbp->drVN[0] = strlen(defaults->volumeName);
 
2138
+       bcopy(defaults->volumeName,&mdbp->drVN[1],mdbp->drVN[0]);
 
2139
+       
 
2140
        mdbp->drFndrInfo[4] = SET_HFS_TEXT_ENCODING(defaults->encodingHint);
 
2141
 
 
2142
        mdbp->drWrCnt = kWriteSeqNum;
 
2143
@@ -1100,9 +1117,11 @@
 
2144
        UInt16                                  nodeSize;
 
2145
        SInt16                                  offset;
 
2146
        UInt32                                  unicodeBytes;
 
2147
+#if !LINUX
 
2148
        UInt8 canonicalName[256];
 
2149
        CFStringRef cfstr;
 
2150
        Boolean cfOK;
 
2151
+#endif
 
2152
        int index = 0;
 
2153
 
 
2154
        nodeSize = dp->catalogNodeSize;
 
2155
@@ -1122,7 +1141,9 @@
 
2156
         * First record is always the root directory...
 
2157
         */
 
2158
        ckp = (HFSPlusCatalogKey *)((UInt8 *)buffer + offset);
 
2159
-       
 
2160
+#if LINUX      
 
2161
+       ConvertUTF8toUnicode(dp->volumeName, sizeof(ckp->nodeName.unicode), ckp->nodeName.unicode, &ckp->nodeName.length);
 
2162
+#else
 
2163
        /* Use CFString functions to get a HFSPlus Canonical name */
 
2164
        cfstr = CFStringCreateWithCString(kCFAllocatorDefault, (char *)dp->volumeName, kCFStringEncodingUTF8);
 
2165
        cfOK = _CFStringGetFileSystemRepresentation(cfstr, canonicalName, sizeof(canonicalName));
 
2166
@@ -1139,6 +1160,7 @@
 
2167
                      dp->volumeName, kDefaultVolumeNameStr);
 
2168
        }
 
2169
        CFRelease(cfstr);
 
2170
+#endif
 
2171
        ckp->nodeName.length = SWAP_BE16 (ckp->nodeName.length);
 
2172
 
 
2173
        unicodeBytes = sizeof(UniChar) * SWAP_BE16 (ckp->nodeName.length);
 
2174
@@ -1821,15 +1843,15 @@
 
2175
        off_t sector;
 
2176
 
 
2177
        if ((byteCount % driveInfo->sectorSize) != 0)
 
2178
-               errx(1, "WriteBuffer: byte count %ld is not sector size multiple", byteCount);
 
2179
+               errx(1, "WriteBuffer: byte count %i is not sector size multiple", byteCount);
 
2180
 
 
2181
        sector = driveInfo->sectorOffset + startingSector;
 
2182
 
 
2183
        if (lseek(driveInfo->fd, sector * driveInfo->sectorSize, SEEK_SET) < 0)
 
2184
-               err(1, "seek (sector %qd)", sector);
 
2185
+               err(1, "seek (sector %lld)", sector);
 
2186
 
 
2187
        if (write(driveInfo->fd, buffer, byteCount) != byteCount)
 
2188
-               err(1, "write (sector %qd, %ld bytes)", sector, byteCount);
 
2189
+               err(1, "write (sector %lld, %i bytes)", sector, byteCount);
 
2190
 }
 
2191
 
 
2192
 
 
2193
@@ -1913,7 +1935,7 @@
 
2194
        return quotient;
 
2195
 }
 
2196
 
 
2197
-
 
2198
+#if !LINUX
 
2199
 #define __kCFUserEncodingFileName ("/.CFUserTextEncoding")
 
2200
 
 
2201
 static UInt32
 
2202
@@ -1939,7 +1961,7 @@
 
2203
     }
 
2204
     return 0;
 
2205
 }
 
2206
-
 
2207
+#endif
 
2208
 
 
2209
 static int
 
2210
 ConvertUTF8toUnicode(const UInt8* source, UInt32 bufsize, UniChar* unibuf,
 
2211
@@ -2006,6 +2028,9 @@
 
2212
 static int
 
2213
 getencodinghint(unsigned char *name)
 
2214
 {
 
2215
+#if LINUX
 
2216
+       return(0);
 
2217
+#else
 
2218
         int mib[3];
 
2219
         size_t buflen = sizeof(int);
 
2220
         struct vfsconf vfc;
 
2221
@@ -2023,7 +2048,8 @@
 
2222
        return (hint);
 
2223
 error:
 
2224
        hint = GetDefaultEncoding();
 
2225
-       return (hint);
 
2226
+       return (0);
 
2227
+#endif
 
2228
 }
 
2229
 
 
2230
 
 
2231
@@ -2034,12 +2060,14 @@
 
2232
        unsigned char digest[20];
 
2233
        time_t now;
 
2234
        clock_t uptime;
 
2235
-       int mib[2];
 
2236
-       int sysdata;
 
2237
-       char sysctlstring[128];
 
2238
        size_t datalen;
 
2239
        double sysloadavg[3];
 
2240
+#if !LINUX
 
2241
+       int sysdata;
 
2242
+       int mib[2];
 
2243
+       char sysctlstring[128];
 
2244
        struct vmtotal sysvmtotal;
 
2245
+#endif
 
2246
        
 
2247
        do {
 
2248
                /* Initialize the SHA-1 context for processing: */
 
2249
@@ -2052,52 +2080,58 @@
 
2250
                SHA1_Update(&context, &uptime, sizeof(uptime));
 
2251
                
 
2252
                /* The kernel's boot time: */
 
2253
+#if !LINUX
 
2254
                mib[0] = CTL_KERN;
 
2255
                mib[1] = KERN_BOOTTIME;
 
2256
                datalen = sizeof(sysdata);
 
2257
                sysctl(mib, 2, &sysdata, &datalen, NULL, 0);
 
2258
                SHA1_Update(&context, &sysdata, datalen);
 
2259
-               
 
2260
+#endif
 
2261
                /* The system's host id: */
 
2262
+#if !LINUX
 
2263
                mib[0] = CTL_KERN;
 
2264
                mib[1] = KERN_HOSTID;
 
2265
                datalen = sizeof(sysdata);
 
2266
                sysctl(mib, 2, &sysdata, &datalen, NULL, 0);
 
2267
                SHA1_Update(&context, &sysdata, datalen);
 
2268
-
 
2269
+#endif
 
2270
                /* The system's host name: */
 
2271
+#if !LINUX
 
2272
                mib[0] = CTL_KERN;
 
2273
                mib[1] = KERN_HOSTNAME;
 
2274
                datalen = sizeof(sysctlstring);
 
2275
                sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
 
2276
                SHA1_Update(&context, sysctlstring, datalen);
 
2277
-
 
2278
+#endif
 
2279
                /* The running kernel's OS release string: */
 
2280
+#if !LINUX
 
2281
                mib[0] = CTL_KERN;
 
2282
                mib[1] = KERN_OSRELEASE;
 
2283
                datalen = sizeof(sysctlstring);
 
2284
                sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
 
2285
                SHA1_Update(&context, sysctlstring, datalen);
 
2286
-
 
2287
+#endif
 
2288
                /* The running kernel's version string: */
 
2289
+#if !LINUX
 
2290
                mib[0] = CTL_KERN;
 
2291
                mib[1] = KERN_VERSION;
 
2292
                datalen = sizeof(sysctlstring);
 
2293
                sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
 
2294
                SHA1_Update(&context, sysctlstring, datalen);
 
2295
-
 
2296
+#endif
 
2297
                /* The system's load average: */
 
2298
                datalen = sizeof(sysloadavg);
 
2299
                getloadavg(sysloadavg, 3);
 
2300
                SHA1_Update(&context, &sysloadavg, datalen);
 
2301
 
 
2302
                /* The system's VM statistics: */
 
2303
+#if !LINUX
 
2304
                mib[0] = CTL_VM;
 
2305
                mib[1] = VM_METER;
 
2306
                datalen = sizeof(sysvmtotal);
 
2307
                sysctl(mib, 2, &sysvmtotal, &datalen, NULL, 0);
 
2308
                SHA1_Update(&context, &sysvmtotal, datalen);
 
2309
-
 
2310
+#endif
 
2311
                /* The current GMT (26 ASCII characters): */
 
2312
                time(&now);
 
2313
                strncpy(randomInputBuffer, asctime(gmtime(&now)), 26);  /* "Mon Mar 27 13:46:26 2000" */
 
2314
Index: hfsprogs-332.14/newfs_hfs.tproj/newfs_hfs.c
 
2315
===================================================================
 
2316
--- hfsprogs-332.14.orig/newfs_hfs.tproj/newfs_hfs.c    2006-02-20 18:45:15.000000000 -0300
 
2317
+++ hfsprogs-332.14/newfs_hfs.tproj/newfs_hfs.c 2007-07-17 13:02:59.000000000 -0300
 
2318
@@ -38,8 +38,13 @@
 
2319
 #include <sys/mount.h>
 
2320
 #include <sys/param.h>
 
2321
 #include <sys/stat.h>
 
2322
+#if LINUX
 
2323
+#include <time.h>
 
2324
+#endif
 
2325
 
 
2326
+#if !LINUX
 
2327
 #include <IOKit/storage/IOMediaBSDClient.h>
 
2328
+#endif
 
2329
 
 
2330
 #include <hfs/hfs_format.h>
 
2331
 #include "newfs_hfs.h"
 
2332
@@ -73,7 +78,9 @@
 
2333
 
 
2334
 char   *progname;
 
2335
 char   gVolumeName[kHFSPlusMaxFileNameChars + 1] = {kDefaultVolumeNameStr};
 
2336
-char   rawdevice[MAXPATHLEN];
 
2337
+#if !LINUX
 
2338
+char   rawdevice[MAXPATHLEN]; 
 
2339
+#endif
 
2340
 char   blkdevice[MAXPATHLEN];
 
2341
 UInt32 gBlockSize = 0;
 
2342
 UInt32 gNextCNID = kHFSFirstUserCatalogNodeID;
 
2343
@@ -137,8 +144,10 @@
 
2344
        extern int optind;
 
2345
        int ch;
 
2346
        int forceHFS;
 
2347
+#if !LINUX
 
2348
        char *cp, *special;
 
2349
        struct statfs *mp;
 
2350
+#endif
 
2351
        int n;
 
2352
        
 
2353
        if ((progname = strrchr(*argv, '/')))
 
2354
@@ -238,7 +247,9 @@
 
2355
 
 
2356
        if (argc != 1)
 
2357
                usage();
 
2358
-
 
2359
+#if LINUX
 
2360
+       (void) sprintf(blkdevice, "%s", argv[0]);
 
2361
+#else
 
2362
        special = argv[0];
 
2363
        cp = strrchr(special, '/');
 
2364
        if (cp != 0)
 
2365
@@ -247,6 +258,7 @@
 
2366
                special++;
 
2367
        (void) sprintf(rawdevice, "%sr%s", _PATH_DEV, special);
 
2368
        (void) sprintf(blkdevice, "%s%s", _PATH_DEV, special);
 
2369
+#endif
 
2370
 
 
2371
        if (forceHFS && gJournaled) {
 
2372
                fprintf(stderr, "-h -J: incompatible options specified\n");
 
2373
@@ -268,6 +280,9 @@
 
2374
        /*
 
2375
         * Check if target device is aready mounted
 
2376
         */
 
2377
+#if LINUX
 
2378
+       // FIXME
 
2379
+#else
 
2380
        n = getmntinfo(&mp, MNT_NOWAIT);
 
2381
        if (n == 0)
 
2382
                fatal("%s: getmntinfo: %s", blkdevice, strerror(errno));
 
2383
@@ -277,14 +292,19 @@
 
2384
                        fatal("%s is mounted on %s", blkdevice, mp->f_mntonname);
 
2385
                ++mp;
 
2386
        }
 
2387
+#endif
 
2388
 
 
2389
-       if (hfs_newfs(rawdevice, forceHFS, true) < 0) {
 
2390
+       if (hfs_newfs(blkdevice, forceHFS, true) < 0) {
 
2391
+#if LINUX
 
2392
+               err(1, NULL);
 
2393
+#else
 
2394
                /* On ENXIO error use the block device (to get de-blocking) */
 
2395
                if (errno == ENXIO) {
 
2396
                        if (hfs_newfs(blkdevice, forceHFS, false) < 0)
 
2397
                                err(1, NULL);
 
2398
                } else
 
2399
                        err(1, NULL);
 
2400
+#endif
 
2401
        }
 
2402
 
 
2403
        exit(0);
 
2404
@@ -458,7 +478,7 @@
 
2405
                        fatal("%s: block size is too small for %lld sectors", optarg, gBlockSize, sectorCount);
 
2406
 
 
2407
                if (gBlockSize < HFSOPTIMALBLKSIZE)
 
2408
-                       warnx("Warning: %ld is a non-optimal block size (4096 would be a better choice)", gBlockSize);
 
2409
+                       warnx("Warning: %i is a non-optimal block size (4096 would be a better choice)", gBlockSize);
 
2410
        }
 
2411
 }
 
2412
 
 
2413
@@ -472,7 +492,9 @@
 
2414
        int fso = 0;
 
2415
        int retval = 0;
 
2416
        hfsparams_t defaults = {0};
 
2417
+#if !LINUX
 
2418
        u_int64_t maxSectorsPerIO;
 
2419
+#endif
 
2420
 
 
2421
        if (gNoCreate) {
 
2422
                fso = open( device, O_RDONLY | O_NDELAY, 0 );
 
2423
@@ -485,7 +507,33 @@
 
2424
 
 
2425
        if (fstat( fso, &stbuf) < 0)
 
2426
                fatal("%s: %s", device, strerror(errno));
 
2427
+#if LINUX
 
2428
+       dip.sectorSize = 512;
 
2429
+       dip.sectorsPerIO = 256;
 
2430
 
 
2431
+#ifndef        BLKGETSIZE
 
2432
+#define        BLKGETSIZE              _IO(0x12,96)
 
2433
+#endif
 
2434
+#ifndef        BLKGETSIZE64
 
2435
+#define BLKGETSIZE64           _IOR(0x12,114,size_t)
 
2436
+#endif
 
2437
+        
 
2438
+       if (S_ISREG(stbuf.st_mode)) {
 
2439
+                dip.totalSectors = stbuf.st_size / 512;
 
2440
+        } 
 
2441
+       else if (S_ISBLK(stbuf.st_mode)) {
 
2442
+                unsigned long size;
 
2443
+                u_int64_t size64;
 
2444
+                if (!ioctl(fso, BLKGETSIZE64, &size64))
 
2445
+                        dip.totalSectors = size64 / 512;
 
2446
+                else if (!ioctl(fso, BLKGETSIZE, &size))
 
2447
+                        dip.totalSectors = size;
 
2448
+                else
 
2449
+                        fatal("%s: %s", device, strerror(errno));
 
2450
+        } 
 
2451
+       else
 
2452
+                fatal("%s: is not a block device", device);
 
2453
+#else
 
2454
        if (ioctl(fso, DKIOCGETBLOCKCOUNT, &dip.totalSectors) < 0)
 
2455
                fatal("%s: %s", device, strerror(errno));
 
2456
 
 
2457
@@ -493,14 +541,17 @@
 
2458
                fatal("%s: %s", device, strerror(errno));
 
2459
 
 
2460
        if (ioctl(fso, DKIOCGETMAXBLOCKCOUNTWRITE, &maxSectorsPerIO) < 0)
 
2461
-               dip.sectorsPerIO = (128 * 1024) / dip.sectorSize;  /* use 128K as default */
 
2462
+               dip.sectorsPerIO = (128 * 1024) / dip.sectorSize; /* use 128K as default */
 
2463
        else
 
2464
                dip.sectorsPerIO = MIN(maxSectorsPerIO, (1024 * 1024) / dip.sectorSize);
 
2465
+#endif
 
2466
+       
 
2467
         /*
 
2468
-         * The make_hfs code currentlydoes 512 byte sized I/O.
 
2469
+         * The make_hfs code currently does 512 byte sized I/O.
 
2470
          * If the sector size is bigger than 512, start over
 
2471
          * using the block device (to get de-blocking).
 
2472
          */       
 
2473
+#if !LINUX
 
2474
         if (dip.sectorSize != kBytesPerSector) {
 
2475
                if (isRaw) {
 
2476
                        close(fso);
 
2477
@@ -515,7 +566,8 @@
 
2478
                        dip.sectorSize = kBytesPerSector;
 
2479
                }
 
2480
         }
 
2481
-  
 
2482
+#endif
 
2483
+
 
2484
        dip.fd = fso;
 
2485
        dip.sectorOffset = 0;
 
2486
        time(&createtime);
 
2487
@@ -693,7 +745,7 @@
 
2488
        defaults->catalogClumpSize = clumpSize;
 
2489
        defaults->catalogNodeSize = catnodesiz;
 
2490
        if (gBlockSize < 4096 && gBlockSize < catnodesiz)
 
2491
-               warnx("Warning: block size %ld is less than catalog b-tree node size %ld", gBlockSize, catnodesiz);
 
2492
+               warnx("Warning: block size %i is less than catalog b-tree node size %i", gBlockSize, catnodesiz);
 
2493
 
 
2494
        if (extclumpblks == 0) {
 
2495
                clumpSize = CalcHFSPlusBTreeClumpSize(gBlockSize, extnodesiz, sectorCount, FALSE);
 
2496
@@ -706,7 +758,7 @@
 
2497
        defaults->extentsClumpSize = clumpSize;
 
2498
        defaults->extentsNodeSize = extnodesiz;
 
2499
        if (gBlockSize < extnodesiz)
 
2500
-               warnx("Warning: block size %ld is less than extents b-tree node size %ld", gBlockSize, extnodesiz);
 
2501
+               warnx("Warning: block size %i is less than extents b-tree node size %i", gBlockSize, extnodesiz);
 
2502
 
 
2503
        if (atrclumpblks == 0) {
 
2504
                clumpSize = 0;
 
2505
@@ -754,22 +806,22 @@
 
2506
 
 
2507
        if (gNoCreate) {
 
2508
                if (!gWrapper)
 
2509
-                       printf("%qd sectors (%lu bytes per sector)\n", sectorCount, sectorSize);
 
2510
+                       printf("%lld sectors (%u bytes per sector)\n", sectorCount, sectorSize);
 
2511
                printf("HFS Plus format parameters:\n");
 
2512
                printf("\tvolume name: \"%s\"\n", gVolumeName);
 
2513
-               printf("\tblock-size: %lu\n", defaults->blockSize);
 
2514
-               printf("\ttotal blocks: %lu\n", totalBlocks);
 
2515
+               printf("\tblock-size: %u\n", defaults->blockSize);
 
2516
+               printf("\ttotal blocks: %u\n", totalBlocks);
 
2517
                if (gJournaled)
 
2518
                        printf("\tjournal-size: %dk\n", (int)defaults->journalSize/1024);
 
2519
-               printf("\tfirst free catalog node id: %lu\n", defaults->nextFreeFileID);
 
2520
-               printf("\tcatalog b-tree node size: %lu\n", defaults->catalogNodeSize);
 
2521
-               printf("\tinitial catalog file size: %lu\n", defaults->catalogClumpSize);
 
2522
-               printf("\textents b-tree node size: %lu\n", defaults->extentsNodeSize);
 
2523
-               printf("\tinitial extents file size: %lu\n", defaults->extentsClumpSize);
 
2524
-               printf("\tinitial allocation file size: %lu (%lu blocks)\n",
 
2525
+               printf("\tfirst free catalog node id: %u\n", defaults->nextFreeFileID);
 
2526
+               printf("\tcatalog b-tree node size: %u\n", defaults->catalogNodeSize);
 
2527
+               printf("\tinitial catalog file size: %u\n", defaults->catalogClumpSize);
 
2528
+               printf("\textents b-tree node size: %u\n", defaults->extentsNodeSize);
 
2529
+               printf("\tinitial extents file size: %u\n", defaults->extentsClumpSize);
 
2530
+               printf("\tinitial allocation file size: %u (%u blocks)\n",
 
2531
                        defaults->allocationClumpSize, defaults->allocationClumpSize / gBlockSize);
 
2532
-               printf("\tdata fork clump size: %lu\n", defaults->dataClumpSize);
 
2533
-               printf("\tresource fork clump size: %lu\n", defaults->rsrcClumpSize);
 
2534
+               printf("\tdata fork clump size: %u\n", defaults->dataClumpSize);
 
2535
+               printf("\tresource fork clump size: %u\n", defaults->rsrcClumpSize);
 
2536
                if (defaults->flags & kUseAccessPerms) {
 
2537
                        printf("\tuser ID: %d\n", (int)defaults->owner);
 
2538
                        printf("\tgroup ID: %d\n", (int)defaults->group);
 
2539
@@ -844,17 +896,17 @@
 
2540
        }
 
2541
        
 
2542
        if (gNoCreate) {
 
2543
-               printf("%ld sectors at %ld bytes per sector\n", sectorCount, sectorSize);
 
2544
+               printf("%i sectors at %i bytes per sector\n", sectorCount, sectorSize);
 
2545
                printf("%s format parameters:\n", gWrapper ? "HFS Wrapper" : "HFS");
 
2546
                printf("\tvolume name: \"%s\"\n", gVolumeName);
 
2547
-               printf("\tblock-size: %ld\n", defaults->blockSize);
 
2548
-               printf("\ttotal blocks: %ld\n", sectorCount / (alBlkSize / sectorSize) );
 
2549
-               printf("\tfirst free catalog node id: %ld\n", defaults->nextFreeFileID);
 
2550
-               printf("\tinitial catalog file size: %ld\n", defaults->catalogClumpSize);
 
2551
-               printf("\tinitial extents file size: %ld\n", defaults->extentsClumpSize);
 
2552
-               printf("\tfile clump size: %ld\n", defaults->dataClumpSize);
 
2553
+               printf("\tblock-size: %i\n", defaults->blockSize);
 
2554
+               printf("\ttotal blocks: %i\n", sectorCount / (alBlkSize / sectorSize) );
 
2555
+               printf("\tfirst free catalog node id: %i\n", defaults->nextFreeFileID);
 
2556
+               printf("\tinitial catalog file size: %i\n", defaults->catalogClumpSize);
 
2557
+               printf("\tinitial extents file size: %i\n", defaults->extentsClumpSize);
 
2558
+               printf("\tfile clump size: %i\n", defaults->dataClumpSize);
 
2559
                if (hfsgrowblks)
 
2560
-                       printf("\twrapper growable from %ld to %ld sectors\n", sectorCount, hfsgrowblks);
 
2561
+                       printf("\twrapper growable from %i to %i sectors\n", sectorCount, hfsgrowblks);
 
2562
        }
 
2563
 }
 
2564
 
 
2565
Index: hfsprogs-332.14/newfs_hfs.tproj/newfs_hfs.h
 
2566
===================================================================
 
2567
--- hfsprogs-332.14.orig/newfs_hfs.tproj/newfs_hfs.h    2006-02-20 18:45:15.000000000 -0300
 
2568
+++ hfsprogs-332.14/newfs_hfs.tproj/newfs_hfs.h 2007-07-17 13:02:59.000000000 -0300
 
2569
@@ -19,8 +19,12 @@
 
2570
  * 
 
2571
  * @APPLE_LICENSE_HEADER_END@
 
2572
  */
 
2573
 
2574
-#include <CoreFoundation/CFBase.h>
 
2575
+
 
2576
+#if LINUX
 
2577
+#include "missing.h"
 
2578
+#else
 
2579
+#include <CoreFoundation/CFBase.h>*/
 
2580
+#endif
 
2581
 
 
2582
 /*
 
2583
  * Mac OS Finder flags
 
2584
@@ -122,33 +126,33 @@
 
2585
 #define kDTDF_FileID   16
 
2586
 #define kDTDF_Name     "Desktop DF"
 
2587
 #define kDTDF_Chars    10
 
2588
-#define kDTDF_Type     'DTFL'
 
2589
-#define kDTDF_Creator  'DMGR'
 
2590
+#define kDTDF_Type     0x4454464C /* 'DTFL' */
 
2591
+#define kDTDF_Creator  0x444D4752 /* 'DMGR' */
 
2592
 
 
2593
 #define kDTDB_FileID   17
 
2594
 #define kDTDB_Name     "Desktop DB"
 
2595
 #define kDTDB_Chars    10
 
2596
-#define kDTDB_Type     'BTFL'
 
2597
-#define kDTDB_Creator  'DMGR'
 
2598
+#define kDTDB_Type     0x4254464C /* 'BTFL' */
 
2599
+#define kDTDB_Creator  0x444D4752 /* 'DMGR' */
 
2600
 #define kDTDB_Size     1024
 
2601
 
 
2602
 #define kReadMe_FileID 18
 
2603
 #define kReadMe_Name   "ReadMe"
 
2604
 #define kReadMe_Chars  6
 
2605
-#define kReadMe_Type   'ttro'
 
2606
-#define kReadMe_Creator        'ttxt'
 
2607
+#define kReadMe_Type   0x7474726F /* 'ttro' */
 
2608
+#define kReadMe_Creator        0x74747974 /* 'ttxt' */
 
2609
 
 
2610
 #define kFinder_FileID 19
 
2611
 #define kFinder_Name   "Finder"
 
2612
 #define kFinder_Chars  6
 
2613
-#define kFinder_Type   'FNDR'
 
2614
-#define kFinder_Creator        'MACS'
 
2615
+#define kFinder_Type   0x464E4452 /* 'FNDR' */
 
2616
+#define kFinder_Creator        0x4D414353 /* 'MACS' */
 
2617
 
 
2618
 #define kSystem_FileID 20
 
2619
 #define kSystem_Name   "System"
 
2620
 #define kSystem_Chars  6
 
2621
-#define kSystem_Type   'zsys'
 
2622
-#define kSystem_Creator        'MACS'
 
2623
+#define kSystem_Type   0x7A737973 /* 'zsys' */
 
2624
+#define kSystem_Creator        0x4D414353 /* 'MACS' */
 
2625
 
 
2626
 
 
2627