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
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
11
+ for d in $(SUBDIRS); do $(MAKE) -C $$d -f Makefile.lnx $@; done
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
19
+CFILES = fsck_hfs.c strings.c utilities.c cache.c
20
+OFILES = $(CFILES:.c=.o)
24
+fsck_hfs: $(OFILES) dfalib/libdfa.a
26
+dfalib/libdfa.a: FORCE
27
+ $(MAKE) -C dfalib -f Makefile.lnx libdfa.a
30
+ $(RM) fsck_hfs $(OFILES)
31
+ $(MAKE) -C dfalib -f Makefile.lnx 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
45
#include <sys/types.h>
46
+#endif /* __LINUX__ */
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
59
#pragma unused (version)
62
BTreeControlBlockPtr btreePtr;
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
72
-// Panic("\pSearchTree: curNodeNum is zero!");
73
+ Panic("SearchTree: curNodeNum is zero!");
74
err = fsBTInvalidNodeErr;
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...");
85
//////////////////////// Update Parent(s) ///////////////////////////////
90
- PanicIf ( (level == btreePtr->treeDepth), "\p InsertLevel: unfinished insert!?");
91
+ PanicIf ( (level == btreePtr->treeDepth), "InsertLevel: unfinished insert!?");
96
index = treePathTable [level].index;
97
parentNodeNum = treePathTable [level].node;
99
- PanicIf ( parentNodeNum == 0, "\p InsertLevel: parent node is zero!?");
100
+ PanicIf ( parentNodeNum == 0, "InsertLevel: parent node is zero!?");
102
err = GetNode (btreePtr, parentNodeNum, &parentNode); // released as target node in next level up
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!");
111
// need to delete and re-insert this parent key/ptr
112
// we delete it here and it gets re-inserted in the
114
(void) ReleaseNode (btreePtr, targetNode);
115
(void) ReleaseNode (btreePtr, &siblingNode);
117
- Panic ("\p InsertLevel: an error occured!");
118
+ Panic ("InsertLevel: an error occured!");
126
- PanicIf ( targetNode->buffer == siblingNode->buffer, "\p InsertNode: targetNode == siblingNode, huh?");
127
+ PanicIf ( targetNode->buffer == siblingNode->buffer, "InsertNode: targetNode == siblingNode, huh?");
129
leftNodeNum = ((NodeDescPtr) targetNode->buffer)->bLink;
130
rightNodeNum = ((NodeDescPtr) targetNode->buffer)->fLink;
133
if ( leftNodeNum > 0 )
135
- PanicIf ( siblingNode->buffer != nil, "\p InsertNode: siblingNode already aquired!");
136
+ PanicIf ( siblingNode->buffer != nil, "InsertNode: siblingNode already aquired!");
138
if ( siblingNode->buffer == nil )
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!" );
147
if ( !key->skipRotate ) // are rotates allowed?
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!");
156
DeleteRecord (btreePtr, targetNodePtr, index);
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!!");
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);
171
- Panic ("\pRotateLeft: InsertKeyRecord (left) returned false!");
172
+ Panic ("RotateLeft: InsertKeyRecord (left) returned false!");
173
err = fsBTBadRotateErr;
176
@@ -1031,7 +1031,7 @@
177
didItFit = RotateRecordLeft (btreePtr, leftNode, rightNode);
180
- Panic ("\pRotateLeft: RotateRecordLeft returned false!");
181
+ Panic ("RotateLeft: RotateRecordLeft returned false!");
182
err = fsBTBadRotateErr;
185
@@ -1048,7 +1048,7 @@
186
keyPtr, keyLength, recPtr, recSize);
189
- Panic ("\pRotateLeft: InsertKeyRecord (right) returned false!");
190
+ Panic ("RotateLeft: InsertKeyRecord (right) returned false!");
191
err = fsBTBadRotateErr;
194
@@ -1117,7 +1117,7 @@
195
right = rightNode->buffer;
196
left = leftNode->buffer;
198
- PanicIf ( right->bLink != 0 && left == 0, "\p SplitLeft: left sibling missing!?" );
199
+ PanicIf ( right->bLink != 0 && left == 0, " SplitLeft: left sibling missing!?" );
201
//�� type should be kLeafNode or kIndexNode
203
@@ -1240,8 +1240,8 @@
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");
213
/////////////////////// Initialize New Root Node ////////////////////////////
214
@@ -1264,7 +1264,7 @@
215
didItFit = InsertKeyRecord ( btreePtr, rootNode.buffer, 0, keyPtr, keyLength,
216
(UInt8 *) &rightNode->bLink, 4 );
218
- PanicIf ( !didItFit, "\pAddNewRootNode:InsertKeyRecord failed for left index record");
219
+ PanicIf ( !didItFit, "AddNewRootNode:InsertKeyRecord failed for left index record");
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 );
227
- PanicIf ( !didItFit, "\pAddNewRootNode:InsertKeyRecord failed for right index record");
228
+ PanicIf ( !didItFit, "AddNewRootNode:InsertKeyRecord failed for right index record");
232
@@ -1355,7 +1355,7 @@
234
rightPtr = rightNodePtr->buffer;
236
- PanicIf ( leftPtr->fLink != 0 && rightPtr == 0, "\p SplitRight: right sibling missing!?" );
237
+ PanicIf ( leftPtr->fLink != 0 && rightPtr == 0, "SplitRight: right sibling missing!?" );
239
//�� type should be kLeafNode or kIndexNode
241
@@ -1557,7 +1557,7 @@
242
keyPtr, keyLength, recPtr, recSize);
245
- Panic ("\pRotateRight: InsertKeyRecord (left) returned false!");
246
+ Panic ("RotateRight: InsertKeyRecord (left) returned false!");
247
err = fsBTBadRotateErr;
250
@@ -1572,7 +1572,7 @@
251
didItFit = RotateRecordRight( btreePtr, leftNodePtr, rightNodePtr );
254
- Panic ("\pRotateRight: RotateRecordRight returned false!");
255
+ Panic ("RotateRight: RotateRecordRight returned false!");
256
err = fsBTBadRotateErr;
259
@@ -1583,7 +1583,7 @@
260
keyPtr, keyLength, recPtr, recSize);
263
- Panic ("\pRotateRight: InsertKeyRecord (left) returned false!");
264
+ Panic ("RotateRight: InsertKeyRecord (left) returned false!");
265
err = fsBTBadRotateErr;
268
@@ -1607,7 +1607,7 @@
269
keyPtr, keyLength, recPtr, recSize);
272
- Panic ("\pRotateRight: InsertKeyRecord (right) returned false!");
273
+ Panic ("RotateRight: InsertKeyRecord (right) returned false!");
274
err = fsBTBadRotateErr;
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
282
* @APPLE_LICENSE_HEADER_END@
286
+#include "missing.h"
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
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)
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
316
CopyMemory(&resultIterator->key, foundKey, CalcKeySize(btcb, &resultIterator->key)); //�� warning, this could overflow user's buffer!!!
318
if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, *dataSize) )
319
- DebugStr("\pSearchBTreeRecord: bad record?");
320
+ DebugStr("SearchBTreeRecord: bad record?");
325
CopyMemory(&iterator->key, key, CalcKeySize(btcb, &iterator->key)); //�� warning, this could overflow user's buffer!!!
327
if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, *dataSize) )
328
- DebugStr("\pGetBTreeRecord: bad record?");
329
+ DebugStr("GetBTreeRecord: bad record?");
334
CopyMemory(key, &iterator.key, CalcKeySize(btcb, (BTreeKey *) key)); //�� should we range check against maxkeylen?
336
if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, dataSize) )
337
- DebugStr("\pInsertBTreeRecord: bad record?");
338
+ DebugStr("InsertBTreeRecord: bad record?");
340
result = BTInsertRecord( fcb, &iterator, &btRecord, dataSize );
343
CopyMemory(key, &iterator.key, CalcKeySize(btcb, (BTreeKey *) key)); //�� should we range check against maxkeylen?
345
if ( DEBUG_BUILD && !ValidHFSRecord(newData, btcb, dataSize) )
346
- DebugStr("\pReplaceBTreeRecord: bad record?");
347
+ DebugStr("ReplaceBTreeRecord: bad record?");
349
result = BTReplaceRecord( fcb, &iterator, &btRecord, dataSize );
353
SetEndOfForkProc ( SFCB *filePtr, FSSize minEOF, FSSize maxEOF )
356
#pragma unused (maxEOF)
360
UInt32 actualSectorsAdded;
365
- DebugStr("\pSetEndOfForkProc: minEOF is smaller than current size!");
366
+ DebugStr("SetEndOfForkProc: minEOF is smaller than current size!");
371
// Make sure we got at least as much space as we needed
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");
380
if ( (keyLen < 6) || (keyLen > btcb->maxKeyLength) )
383
- DebugStr("\pCheckBTreeKey: bad key length!");
384
+ DebugStr("CheckBTreeKey: bad key length!");
385
return fsBTInvalidKeyLengthErr;
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
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) );
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
408
#include <sys/ioctl.h>
412
+#include <sys/stat.h>
414
#include <IOKit/storage/IOMediaBSDClient.h>
427
OSErr GetDeviceSize(int driveRefNum, UInt64 *numBlocks, UInt32 *blockSize)
430
UInt64 devBlockCount = 0;
431
int devBlockSize = 0;
435
+ devBlockSize = 512;
438
+#define BLKGETSIZE _IO(0x12,96)
440
+#ifndef BLKGETSIZE64
441
+#define BLKGETSIZE64 _IOR(0x12,114,size_t)
443
+ if (fstat(driveRefNum, &stbuf) < 0){
444
+ printf("Error: %s\n", strerror(errno));
448
+ if (S_ISREG(stbuf.st_mode)) {
449
+ devBlockCount = stbuf.st_size / 512;
451
+ else if (S_ISBLK(stbuf.st_mode)) {
452
+ unsigned long size;
454
+ if (!ioctl(driveRefNum, BLKGETSIZE64, &size64))
455
+ devBlockCount = size64 / 512;
456
+ else if (!ioctl(driveRefNum, BLKGETSIZE, &size))
457
+ devBlockCount = size;
459
+ printf("Error: %s\n", strerror(errno));
465
+ printf("Device is not a block device");
469
if (ioctl(driveRefNum, DKIOCGETBLOCKCOUNT, &devBlockCount) < 0) {
470
printf("ioctl(DKIOCGETBLOCKCOUNT) for fd %d: %s\n", driveRefNum, strerror(errno));
473
printf("ioctl(DKIOCGETBLOCKSIZE) for fd %d: %s\n", driveRefNum, strerror(errno));
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
485
* The name portion of the key is compared using a 16-bit binary comparison.
486
* This is called from the b-tree code.
492
CompareAttributeKeys(const AttributeKey *searchKey, const AttributeKey *trialKey)
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 @@
500
static OSErr FixWrapperExtents( SGlobPtr GPtr, RepairOrderPtr p )
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
518
+#include "missing.h"
520
#include <sys/types.h>
527
typedef u_int32_t HFSCatalogNodeID;
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
543
// GPtr->realVCB Real in-memory vcb
544
//------------------------------------------------------------------------------
549
OSErr GetVolumeFeatures( SGlobPtr GPtr )
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
568
#include <sys/ioctl.h>
570
#include <sys/disk.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.
584
ioctl( GPtr->DrvNum, DKIOCISWRITABLE, &isWriteable );
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
594
#include "BTreeScanner.h"
595
#include "hfs_endian.h"
598
+#define XATTR_MAXNAMELEN 127
601
#include <sys/xattr.h>
603
#include <sys/kauth.h>
604
-#include <sys/errno.h>
605
#include <sys/syslimits.h>
607
+#include <sys/errno.h>
611
@@ -1434,4 +1439,8 @@
616
+#undef XATTR_MAXNAMELEN
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
625
#include <sys/types.h>
626
#include <sys/stat.h>
629
+#include "missing.h"
631
#include <architecture/byte_order.h>
633
#include <hfs/hfs_format.h>
635
#include "Scavenger.h"
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
651
* This file prototypes endian swapping routines for the HFS/HFS Plus
655
#include <hfs/hfs_format.h>
658
+#include <byteswap.h>
660
#include <architecture/byte_order.h>
662
#include "SRuntime.h"
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
670
#include <sys/types.h>
671
#include <sys/stat.h>
672
#include <sys/param.h>
674
#include <sys/ucred.h>
676
#include <sys/mount.h>
677
#include <sys/ioctl.h>
679
#include <sys/disk.h>
682
#include <hfs/hfs_mount.h>
684
@@ -170,10 +174,12 @@
687
debug = 0; /* debugging is for command line only */
692
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
693
(void)signal(SIGINT, catch);
697
(void) fprintf(stderr, "%s: missing special-device\n", progname);
700
int chkLev, repLev, logLev;
701
int blockDevice_fd, canWrite;
702
char *unraw, *mntonname;
704
struct statfs *fsinfo;
706
int fs_fd=-1; // fd to the root-dir of the fs we're checking (only w/lfag == 1)
718
result = getmntinfo(&fsinfo, MNT_NOWAIT);
736
struct statfs stfs_buf;
738
* Check to see if root is mounted read-write.
739
@@ -315,18 +328,24 @@
742
ckfini(flags & MNT_RDONLY);
746
/* XXX free any allocated memory here */
748
if (hotroot && fsmodified) {
750
struct hfs_mount_args args;
753
* We modified the root. Do a mount update on
754
* it, unless it is read-write, so we can continue.
757
printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
761
if (flags & MNT_RDONLY) {
762
bzero(&args, sizeof(args));
763
flags |= MNT_UPDATE | MNT_RELOAD;
765
goto ExitThisRoutine;
770
printf("\n***** REBOOT NOW *****\n");
772
@@ -380,11 +400,13 @@
773
printf("Can't stat %s: %s\n", dev, strerror(errno));
777
if ((statb.st_mode & S_IFMT) != S_IFCHR) {
778
pfatal("%s is not a character device", dev);
779
if (reply("CONTINUE") == 0)
783
if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
784
printf("Can't open %s: %s\n", dev, strerror(errno));
786
@@ -407,10 +429,14 @@
789
/* Get device block size to initialize cache */
791
+ devBlockSize = 512;
793
if (ioctl(fsreadfd, DKIOCGETBLOCKSIZE, &devBlockSize) < 0) {
794
pfatal ("Can't get device block size\n");
798
/* Initialize the cache */
799
if (CacheInit (&fscache, fsreadfd, fswritefd, devBlockSize,
800
CACHE_IOSIZE, CACHE_BLOCKS, CACHE_HASHSIZE) != EOK) {
801
@@ -431,11 +457,15 @@
803
static void getWriteAccess( char *dev, int *blockDevice_fdPtr, int *canWritePtr )
812
struct statfs * myBufPtr;
817
@@ -456,18 +486,19 @@
819
goto ExitThisRoutine;
822
// get count of mounts then get the info for each
826
myMountsCount = getfsstat( NULL, 0, MNT_NOWAIT );
827
if ( myMountsCount < 0 )
828
goto ExitThisRoutine;
830
myPtr = (void *) malloc( sizeof(struct statfs) * myMountsCount );
832
goto ExitThisRoutine;
833
myMountsCount = getfsstat( myPtr,
834
- (sizeof(struct statfs) * myMountsCount),
836
+ (sizeof(struct statfs) * myMountsCount),
838
if ( myMountsCount < 0 )
839
goto ExitThisRoutine;
846
*canWritePtr = 1; // single user will get us here, f_mntfromname is not /dev/diskXXXX
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);
860
if ((stchar.st_mode & S_IFMT) == S_IFCHR) {
863
printf("%s is not a character device\n", raw);
867
} else if ((stblock.st_mode & S_IFMT) == S_IFCHR && !retried) {
868
newname = unrawname(newname);
872
(void)strcpy(rawbuf, name);
874
- (void)strcat(rawbuf, "/r");
876
+ (void)strcat(rawbuf, "/");
878
+ (void)strcat(rawbuf,"/r");
880
(void)strcat(rawbuf, &dp[1]);
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
889
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
891
+ * @APPLE_LICENSE_HEADER_START@
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.
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.
907
+ * @APPLE_LICENSE_HEADER_END@
910
+ * Copyright (c) 1989, 1993
911
+ * The Regents of the University of California. All rights reserved.
913
+ * This code is derived from software contributed to Berkeley by
916
+ * Redistribution and use in source and binary forms, with or without
917
+ * modification, are permitted provided that the following conditions
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.
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
944
+ * @(#)bitstring.h 8.1 (Berkeley) 7/19/93
947
+#ifndef _BITSTRING_H_
948
+#define _BITSTRING_H_
950
+typedef unsigned char bitstr_t;
952
+/* internal macros */
953
+ /* byte of the bitstring bit is in */
954
+#define _bit_byte(bit) \
957
+ /* mask for the bit within its byte */
958
+#define _bit_mask(bit) \
961
+/* external macros */
962
+ /* bytes in a bitstring of nbits bits */
963
+#define bitstr_size(nbits) \
964
+ ((((nbits) - 1) >> 3) + 1)
966
+ /* allocate a bitstring */
967
+#define bit_alloc(nbits) \
968
+ (bitstr_t *)calloc(1, \
969
+ (unsigned int)bitstr_size(nbits) * sizeof(bitstr_t))
971
+ /* allocate a bitstring on the stack */
972
+#define bit_decl(name, nbits) \
973
+ (name)[bitstr_size(nbits)]
975
+ /* is bit N of bitstring name set? */
976
+#define bit_test(name, bit) \
977
+ ((name)[_bit_byte(bit)] & _bit_mask(bit))
979
+ /* set bit N of bitstring name */
980
+#define bit_set(name, bit) \
981
+ (name)[_bit_byte(bit)] |= _bit_mask(bit)
983
+ /* clear bit N of bitstring name */
984
+#define bit_clear(name, bit) \
985
+ (name)[_bit_byte(bit)] &= ~_bit_mask(bit)
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))); \
997
+ _name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \
998
+ while (++_startbyte < _stopbyte) \
999
+ _name[_startbyte] = 0; \
1000
+ _name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \
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)))); \
1014
+ _name[_startbyte] |= 0xff << ((_start)&0x7); \
1015
+ while (++_startbyte < _stopbyte) \
1016
+ _name[_startbyte] = 0xff; \
1017
+ _name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \
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); \
1033
+ *(value) = _value; \
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); \
1048
+ *(value) = _value; \
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
1058
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
1060
+ * @APPLE_LICENSE_HEADER_START@
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.
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.
1076
+ * @APPLE_LICENSE_HEADER_END@
1078
+#ifndef __HFS_FORMAT__
1079
+#define __HFS_FORMAT__
1081
+#include "missing.h"
1083
+#include <sys/appleapiopts.h>
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.
1091
+ * http://developer.apple.com/technotes/tn/tn1150.html
1099
+/* some on-disk hfs structures have 68K alignment (misaligned) */
1101
+#define PACKED_S __attribute__((packed))
1103
+/* Signatures used to differentiate between HFS and HFS Plus volumes */
1105
+ kHFSSigWord = 0x4244, /* 'BD' in ASCII */
1106
+ kHFSPlusSigWord = 0x482B, /* 'H+' in ASCII */
1107
+ kHFSXSigWord = 0x4858, /* 'HX' in ASCII */
1109
+ kHFSPlusVersion = 0x0004, /* 'H+' volumes are version 4 only */
1110
+ kHFSXVersion = 0x0005, /* 'HX' volumes start with version 5 */
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 */
1118
+#ifdef __APPLE_API_PRIVATE
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
1124
+ * To make this folder name sort last, it has embedded null prefix.
1125
+ * (0xC0, 0x80 in UTF-8)
1127
+#define HFSPLUSMETADATAFOLDER "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
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.
1135
+ * e.g. iNode7182000 and temp3296
1137
+#define HFS_INODE_PREFIX "iNode"
1138
+#define HFS_DELETE_PREFIX "temp"
1140
+#endif /* __APPLE_API_PRIVATE */
1143
+ * Indirect link files (hard links) have the following type/creator.
1146
+ kHardLinkFileType = 0x686C6E6B, /* 'hlnk' */
1147
+ kHFSPlusCreator = 0x6866732B /* 'hfs+' */
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 */
1158
+typedef struct HFSUniStr255 HFSUniStr255;
1159
+typedef const HFSUniStr255 *ConstHFSUniStr255Param;
1160
+#endif /* _HFSUNISTR255_DEFINED_ */
1163
+ kHFSMaxVolumeNameChars = 27,
1164
+ kHFSMaxFileNameChars = 31,
1165
+ kHFSPlusMaxFileNameChars = 255
1169
+/* Extent overflow file data structures */
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 */
1178
+typedef struct HFSExtentKey HFSExtentKey;
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 */
1188
+typedef struct HFSPlusExtentKey HFSPlusExtentKey;
1190
+/* Number of extent descriptors per extent record */
1192
+ kHFSExtentDensity = 3,
1193
+ kHFSPlusExtentDensity = 8
1196
+/* HFS extent descriptor */
1197
+struct HFSExtentDescriptor {
1198
+ u_int16_t startBlock; /* first allocation block */
1199
+ u_int16_t blockCount; /* number of allocation blocks */
1201
+typedef struct HFSExtentDescriptor HFSExtentDescriptor;
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 */
1208
+typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor;
1210
+/* HFS extent record */
1211
+typedef HFSExtentDescriptor HFSExtentRecord[3];
1213
+/* HFS Plus extent record */
1214
+typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
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 */
1223
+ int16_t v; /* file's location */
1225
+ } PACKED_S fdLocation;
1228
+typedef struct FndrFileInfo FndrFileInfo;
1230
+struct FndrDirInfo {
1231
+ struct { /* folder's window rectangle */
1237
+ unsigned short frFlags; /* Finder flags */
1239
+ u_int16_t v; /* folder's location */
1241
+ }PACKED_S frLocation;
1244
+typedef struct FndrDirInfo FndrDirInfo;
1246
+struct FndrOpaqueInfo {
1247
+ int8_t opaque[16];
1249
+typedef struct FndrOpaqueInfo FndrOpaqueInfo;
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 */
1259
+typedef struct HFSPlusForkData HFSPlusForkData;
1262
+/* Mac OS X has 16 bytes worth of "BSD" info.
1264
+ * Note: Mac OS 9 implementations and applications
1265
+ * should preserve, but not change, this information.
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 */
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;
1279
+typedef struct HFSPlusBSDInfo HFSPlusBSDInfo;
1282
+/* Catalog file data structures */
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
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 */
1305
+typedef struct HFSCatalogKey HFSCatalogKey;
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 */
1313
+typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
1315
+/* Catalog record types */
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 */
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 */
1331
+/* Catalog file record flags */
1333
+ kHFSFileLockedBit = 0x0000, /* file is locked and cannot be written to */
1334
+ kHFSFileLockedMask = 0x0001,
1336
+ kHFSThreadExistsBit = 0x0001, /* a file thread record exists for this file */
1337
+ kHFSThreadExistsMask = 0x0002,
1339
+ kHFSHasAttributesBit = 0x0002, /* object has extended attributes */
1340
+ kHFSHasAttributesMask = 0x0004,
1342
+ kHFSHasSecurityBit = 0x0003, /* object has security data (ACLs) */
1343
+ kHFSHasSecurityMask = 0x0008
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 */
1360
+typedef struct HFSCatalogFolder HFSCatalogFolder;
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 */
1379
+typedef struct HFSPlusCatalogFolder HFSPlusCatalogFolder;
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 */
1403
+typedef struct HFSCatalogFile HFSCatalogFile;
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 */
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 */
1426
+typedef struct HFSPlusCatalogFile HFSPlusCatalogFile;
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 */
1435
+typedef struct HFSCatalogThread HFSCatalogThread;
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) */
1444
+typedef struct HFSPlusCatalogThread HFSPlusCatalogThread;
1446
+#ifdef __APPLE_API_UNSTABLE
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.
1452
+ kHFSPlusAttrInlineData = 0x10, /* if size < kAttrOverflowSize */
1453
+ kHFSPlusAttrForkData = 0x20, /* if size >= kAttrOverflowSize */
1454
+ kHFSPlusAttrExtents = 0x30 /* overflow extents for large attributes */
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.
1464
+struct HFSPlusAttrForkData {
1465
+ u_int32_t recordType; /* == kHFSPlusAttrForkData*/
1466
+ u_int32_t reserved;
1467
+ HFSPlusForkData theFork; /* size and first extents of value*/
1469
+typedef struct HFSPlusAttrForkData HFSPlusAttrForkData;
1472
+ HFSPlusAttrExtents
1473
+ This record contains information about overflow extents for large,
1474
+ fragmented attributes.
1476
+struct HFSPlusAttrExtents {
1477
+ u_int32_t recordType; /* == kHFSPlusAttrExtents*/
1478
+ u_int32_t reserved;
1479
+ HFSPlusExtentRecord extents; /* additional extents*/
1481
+typedef struct HFSPlusAttrExtents HFSPlusAttrExtents;
1484
+ * Atrributes B-tree Data Record
1486
+ * For small attributes, whose entire value is stored
1487
+ * within a single B-tree record.
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 */
1495
+typedef struct HFSPlusAttrData HFSPlusAttrData;
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];
1505
+typedef struct HFSPlusAttrInlineData HFSPlusAttrInlineData;
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;
1516
+typedef union HFSPlusAttrRecord HFSPlusAttrRecord;
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) */
1528
+typedef struct HFSPlusAttrKey HFSPlusAttrKey;
1530
+#define kHFSPlusAttrKeyMaximumLength (sizeof(HFSPlusAttrKey) - sizeof(u_int16_t))
1531
+#define kHFSPlusAttrKeyMinimumLength (kHFSPlusAttrKeyMaximumLength - (127 * sizeof(u_int16_t)))
1533
+#endif /* __APPLE_API_UNSTABLE */
1536
+/* Key and node lengths */
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
1549
+/* HFS and HFS Plus volume attribute bits */
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 */
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
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 */
1608
+typedef struct HFSMasterDirectoryBlock HFSMasterDirectoryBlock;
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 */
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) */
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 */
1633
+ u_int32_t fileCount; /* number of files in volume */
1634
+ u_int32_t folderCount; /* number of directories in volume */
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 */
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 */
1645
+ u_int32_t writeCount; /* volume write count */
1646
+ u_int64_t encodingsBitmap; /* which encodings have been use on this volume */
1648
+ u_int8_t finderInfo[32]; /* information used by the Finder */
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) */
1656
+typedef struct HFSPlusVolumeHeader HFSPlusVolumeHeader;
1659
+/* B-tree structures */
1661
+enum BTreeKeyLimits{
1662
+ kMaxKeyLength = 520
1667
+ u_int16_t length16;
1668
+ u_int8_t rawData [kMaxKeyLength+2];
1670
+typedef union BTreeKey BTreeKey;
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 */
1681
+typedef struct BTNodeDescriptor BTNodeDescriptor;
1683
+/* Constants for BTNodeDescriptor kind */
1687
+ kBTHeaderNode = 1,
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 */
1709
+typedef struct BTHeaderRec BTHeaderRec;
1711
+/* Constants for BTHeaderRec attributes */
1713
+ kBTBadCloseMask = 0x00000001, /* reserved */
1714
+ kBTBigKeysMask = 0x00000002, /* key length field is 16 bits */
1715
+ kBTVariableIndexKeysMask = 0x00000004 /* keys in index nodes are variable length */
1719
+/* Catalog Key Name Comparison Type */
1721
+ kHFSCaseFolding = 0xCF, /* case folding (case-insensitive) */
1722
+ kHFSBinaryCompare = 0xBC /* binary compare (case-sensitive) */
1725
+/* JournalInfoBlock - Structure that describes where our journal lives */
1726
+struct JournalInfoBlock {
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];
1733
+typedef struct JournalInfoBlock JournalInfoBlock;
1736
+ kJIJournalInFSMask = 0x00000001,
1737
+ kJIJournalOnOtherDeviceMask = 0x00000002,
1738
+ kJIJournalNeedInitMask = 0x00000004
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
1752
+ * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
1754
+ * @APPLE_LICENSE_HEADER_START@
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.
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.
1770
+ * @APPLE_LICENSE_HEADER_END@
1773
+ * Copyright (c) 1997-2002 Apple Computer, Inc. All Rights Reserved
1777
+#ifndef _HFS_MOUNT_H_
1778
+#define _HFS_MOUNT_H_
1780
+#include <sys/appleapiopts.h>
1782
+#include <sys/mount.h>
1783
+#include <sys/time.h>
1786
+ * Arguments to mount HFS-based filesystems
1789
+#define OVERRIDE_UNKNOWN_PERMISSIONS 0
1791
+#define UNKNOWNUID ((uid_t)99)
1792
+#define UNKNOWNGID ((gid_t)99)
1793
+#define UNKNOWNPERMISSIONS (S_IRWXU | S_IROTH | S_IXOTH) /* 705 */
1795
+#ifdef __APPLE_API_UNSTABLE
1796
+struct hfs_mount_args {
1798
+ char *fspec; /* block special device to mount */
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) */
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 */
1816
+ * Sysctl values for HFS
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
1826
+#endif /* __APPLE_API_UNSTABLE */
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
1834
+#ifndef _MISSING_H_
1835
+#define _MISSING_H_
1837
+#include <endian.h>
1838
+#include <byteswap.h>
1840
+#include <stdint.h>
1842
+#define MAXBSIZE (256 * 4096)
1855
+#define UInt8 uint8_t
1858
+#define u_int8_t UInt8
1861
+#define SInt8 int8_t
1866
+#define UInt16 uint16_t
1869
+#define u_int16_t UInt16
1872
+#define SInt16 int16_t
1877
+#define UInt32 uint32_t
1880
+#define u_int32_t UInt32
1883
+#define SInt32 int32_t
1888
+#define UInt64 uint64_t
1891
+#define u_int64_t UInt64
1894
+#define SInt64 int64_t
1897
+#define UniChar u_int16_t
1898
+#define Boolean u_int8_t
1900
+#define UF_NODUMP 0x00000001
1903
+#define NAME_MAX 255
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)
1914
+#if __BYTE_ORDER == __LITTLE_ENDIAN
1915
+/* Big Endian Swaps */
1916
+#ifndef be16_to_cpu
1917
+#define be16_to_cpu(x) bswap_16(x)
1919
+#ifndef be32_to_cpu
1920
+#define be32_to_cpu(x) bswap_32(x)
1922
+#ifndef be64_to_cpu
1923
+#define be64_to_cpu(x) bswap_64(x)
1925
+#ifndef cpu_to_be64
1926
+#define cpu_to_be64(x) bswap_64(x)
1928
+#elif __BYTE_ORDER == __BIG_ENDIAN
1929
+/* Big endian doesn't swap */
1930
+#ifndef be16_to_cpu
1931
+#define be16_to_cpu(x) (x)
1933
+#ifndef be32_to_cpu
1934
+#define be32_to_cpu(x) (x)
1936
+#ifndef be64_to_cpu
1937
+#define be64_to_cpu(x) (x)
1939
+#ifndef cpu_to_be64
1940
+#define cpu_to_be64(x) (x)
1944
+#define KAUTH_FILESEC_XATTR "com.apple.system.Security"
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
1953
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
1955
+ * @APPLE_LICENSE_HEADER_START@
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.
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.
1971
+ * @APPLE_LICENSE_HEADER_END@
1974
+#ifndef __SYS_APPLEAPIOPTS_H__
1975
+#define __SYS_APPLEAPIOPTS_H__
1978
+#ifndef __APPLE_API_STANDARD
1979
+#define __APPLE_API_STANDARD
1980
+#endif /* __APPLE_API_STANDARD */
1982
+#ifndef __APPLE_API_STABLE
1983
+#define __APPLE_API_STABLE
1984
+#endif /* __APPLE_API_STABLE */
1986
+#ifndef __APPLE_API_STRICT_CONFORMANCE
1988
+#ifndef __APPLE_API_EVOLVING
1989
+#define __APPLE_API_EVOLVING
1990
+#endif /* __APPLE_API_EVOLVING */
1992
+#ifndef __APPLE_API_UNSTABLE
1993
+#define __APPLE_API_UNSTABLE
1994
+#endif /* __APPLE_API_UNSTABLE */
1996
+#ifndef __APPLE_API_PRIVATE
1997
+#define __APPLE_API_PRIVATE
1998
+#endif /* __APPLE_API_PRIVATE */
2000
+#ifndef __APPLE_API_OBSOLETE
2001
+#define __APPLE_API_OBSOLETE
2002
+#endif /* __APPLE_API_OBSOLETE */
2004
+#endif /* __APPLE_API_STRICT_CONFORMANCE */
2006
+#endif /* __SYS_APPLEAPIOPTS_H__ */
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
2013
+CFILES = hfs_endian.c makehfs.c newfs_hfs.c
2014
+OFILES = $(CFILES:.c=.o)
2018
+newfs_hfs: $(OFILES)
2019
+ ${CC} ${CFLAGS} -o newfs_hfs ${OFILES} -lssl
2022
+ $(RM) newfs_hfs $(OFILES)
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
2030
#include <sys/types.h>
2031
#include <sys/stat.h>
2034
+#include "missing.h"
2036
#include <architecture/byte_order.h>
2039
#include <hfs/hfs_format.h>
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
2049
#include <hfs/hfs_format.h>
2051
+#include <endian.h>
2052
+#include <byteswap.h>
2054
#include <architecture/byte_order.h>
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
2064
#include <sys/param.h>
2065
#include <sys/types.h>
2066
#include <sys/time.h>
2069
+#include "missing.h"
2071
#include <sys/errno.h>
2072
#include <sys/stat.h>
2073
#include <sys/sysctl.h>
2075
#include <sys/vmmeter.h>
2082
#include <openssl/sha.h>
2085
#include <architecture/byte_order.h>
2087
#include <CoreFoundation/CFString.h>
2088
#include <CoreFoundation/CFStringEncodingExt.h>
2090
extern Boolean _CFStringGetFileSystemRepresentation(CFStringRef string, UInt8 *buffer, CFIndex maxBufLen);
2094
#include <hfs/hfs_format.h>
2095
#include <hfs/hfs_mount.h>
2097
static void MarkBitInAllocationBuffer __P((HFSPlusVolumeHeader *header,
2098
UInt32 allocationBlock, void* sectorBuffer, UInt32 *sector));
2101
static UInt32 GetDefaultEncoding();
2104
static UInt32 UTCToLocal __P((UInt32 utcTime));
2106
@@ -158,11 +167,14 @@
2108
#define ROUNDUP(x, u) (((x) % (u) == 0) ? (x) : ((x)/(u) + 1) * (u))
2110
-#define ENCODING_TO_BIT(e) \
2112
+#define ENCODING_TO_BIT(e) (e)
2114
+#define ENCODING_TO_BIT(e)
2116
((e) == kCFStringEncodingMacUkrainian ? 48 : \
2117
((e) == kCFStringEncodingMacFarsi ? 49 : 0)))
2124
* Map UTF-8 input into a Mac encoding.
2125
* On conversion errors "untitled" is used as a fallback.
2129
UniChar unibuf[kHFSMaxVolumeNameChars];
2131
@@ -553,7 +566,11 @@
2132
bcopy(&mdbp->drVN[1], defaults->volumeName, mdbp->drVN[0]);
2133
defaults->volumeName[mdbp->drVN[0]] = '\0';
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]);
2140
mdbp->drFndrInfo[4] = SET_HFS_TEXT_ENCODING(defaults->encodingHint);
2142
mdbp->drWrCnt = kWriteSeqNum;
2143
@@ -1100,9 +1117,11 @@
2146
UInt32 unicodeBytes;
2148
UInt8 canonicalName[256];
2154
nodeSize = dp->catalogNodeSize;
2155
@@ -1122,7 +1141,9 @@
2156
* First record is always the root directory...
2158
ckp = (HFSPlusCatalogKey *)((UInt8 *)buffer + offset);
2161
+ ConvertUTF8toUnicode(dp->volumeName, sizeof(ckp->nodeName.unicode), ckp->nodeName.unicode, &ckp->nodeName.length);
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);
2171
ckp->nodeName.length = SWAP_BE16 (ckp->nodeName.length);
2173
unicodeBytes = sizeof(UniChar) * SWAP_BE16 (ckp->nodeName.length);
2174
@@ -1821,15 +1843,15 @@
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);
2181
sector = driveInfo->sectorOffset + startingSector;
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);
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);
2193
@@ -1913,7 +1935,7 @@
2199
#define __kCFUserEncodingFileName ("/.CFUserTextEncoding")
2202
@@ -1939,7 +1961,7 @@
2210
ConvertUTF8toUnicode(const UInt8* source, UInt32 bufsize, UniChar* unibuf,
2211
@@ -2006,6 +2028,9 @@
2213
getencodinghint(unsigned char *name)
2219
size_t buflen = sizeof(int);
2221
@@ -2023,7 +2048,8 @@
2224
hint = GetDefaultEncoding();
2231
@@ -2034,12 +2060,14 @@
2232
unsigned char digest[20];
2237
- char sysctlstring[128];
2239
double sysloadavg[3];
2243
+ char sysctlstring[128];
2244
struct vmtotal sysvmtotal;
2248
/* Initialize the SHA-1 context for processing: */
2249
@@ -2052,52 +2080,58 @@
2250
SHA1_Update(&context, &uptime, sizeof(uptime));
2252
/* The kernel's boot time: */
2255
mib[1] = KERN_BOOTTIME;
2256
datalen = sizeof(sysdata);
2257
sysctl(mib, 2, &sysdata, &datalen, NULL, 0);
2258
SHA1_Update(&context, &sysdata, datalen);
2261
/* The system's host id: */
2264
mib[1] = KERN_HOSTID;
2265
datalen = sizeof(sysdata);
2266
sysctl(mib, 2, &sysdata, &datalen, NULL, 0);
2267
SHA1_Update(&context, &sysdata, datalen);
2270
/* The system's host name: */
2273
mib[1] = KERN_HOSTNAME;
2274
datalen = sizeof(sysctlstring);
2275
sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
2276
SHA1_Update(&context, sysctlstring, datalen);
2279
/* The running kernel's OS release string: */
2282
mib[1] = KERN_OSRELEASE;
2283
datalen = sizeof(sysctlstring);
2284
sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
2285
SHA1_Update(&context, sysctlstring, datalen);
2288
/* The running kernel's version string: */
2291
mib[1] = KERN_VERSION;
2292
datalen = sizeof(sysctlstring);
2293
sysctl(mib, 2, sysctlstring, &datalen, NULL, 0);
2294
SHA1_Update(&context, sysctlstring, datalen);
2297
/* The system's load average: */
2298
datalen = sizeof(sysloadavg);
2299
getloadavg(sysloadavg, 3);
2300
SHA1_Update(&context, &sysloadavg, datalen);
2302
/* The system's VM statistics: */
2306
datalen = sizeof(sysvmtotal);
2307
sysctl(mib, 2, &sysvmtotal, &datalen, NULL, 0);
2308
SHA1_Update(&context, &sysvmtotal, datalen);
2311
/* The current GMT (26 ASCII characters): */
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
2319
#include <sys/mount.h>
2320
#include <sys/param.h>
2321
#include <sys/stat.h>
2327
#include <IOKit/storage/IOMediaBSDClient.h>
2330
#include <hfs/hfs_format.h>
2331
#include "newfs_hfs.h"
2335
char gVolumeName[kHFSPlusMaxFileNameChars + 1] = {kDefaultVolumeNameStr};
2336
-char rawdevice[MAXPATHLEN];
2338
+char rawdevice[MAXPATHLEN];
2340
char blkdevice[MAXPATHLEN];
2341
UInt32 gBlockSize = 0;
2342
UInt32 gNextCNID = kHFSFirstUserCatalogNodeID;
2343
@@ -137,8 +144,10 @@
2353
if ((progname = strrchr(*argv, '/')))
2360
+ (void) sprintf(blkdevice, "%s", argv[0]);
2363
cp = strrchr(special, '/');
2367
(void) sprintf(rawdevice, "%sr%s", _PATH_DEV, special);
2368
(void) sprintf(blkdevice, "%s%s", _PATH_DEV, special);
2371
if (forceHFS && gJournaled) {
2372
fprintf(stderr, "-h -J: incompatible options specified\n");
2375
* Check if target device is aready mounted
2380
n = getmntinfo(&mp, MNT_NOWAIT);
2382
fatal("%s: getmntinfo: %s", blkdevice, strerror(errno));
2383
@@ -277,14 +292,19 @@
2384
fatal("%s is mounted on %s", blkdevice, mp->f_mntonname);
2389
- if (hfs_newfs(rawdevice, forceHFS, true) < 0) {
2390
+ if (hfs_newfs(blkdevice, forceHFS, true) < 0) {
2394
/* On ENXIO error use the block device (to get de-blocking) */
2395
if (errno == ENXIO) {
2396
if (hfs_newfs(blkdevice, forceHFS, false) < 0)
2405
fatal("%s: block size is too small for %lld sectors", optarg, gBlockSize, sectorCount);
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);
2416
hfsparams_t defaults = {0};
2418
u_int64_t maxSectorsPerIO;
2422
fso = open( device, O_RDONLY | O_NDELAY, 0 );
2423
@@ -485,7 +507,33 @@
2425
if (fstat( fso, &stbuf) < 0)
2426
fatal("%s: %s", device, strerror(errno));
2428
+ dip.sectorSize = 512;
2429
+ dip.sectorsPerIO = 256;
2432
+#define BLKGETSIZE _IO(0x12,96)
2434
+#ifndef BLKGETSIZE64
2435
+#define BLKGETSIZE64 _IOR(0x12,114,size_t)
2438
+ if (S_ISREG(stbuf.st_mode)) {
2439
+ dip.totalSectors = stbuf.st_size / 512;
2441
+ else if (S_ISBLK(stbuf.st_mode)) {
2442
+ unsigned long size;
2444
+ if (!ioctl(fso, BLKGETSIZE64, &size64))
2445
+ dip.totalSectors = size64 / 512;
2446
+ else if (!ioctl(fso, BLKGETSIZE, &size))
2447
+ dip.totalSectors = size;
2449
+ fatal("%s: %s", device, strerror(errno));
2452
+ fatal("%s: is not a block device", device);
2454
if (ioctl(fso, DKIOCGETBLOCKCOUNT, &dip.totalSectors) < 0)
2455
fatal("%s: %s", device, strerror(errno));
2457
@@ -493,14 +541,17 @@
2458
fatal("%s: %s", device, strerror(errno));
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 */
2464
dip.sectorsPerIO = MIN(maxSectorsPerIO, (1024 * 1024) / dip.sectorSize);
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).
2474
if (dip.sectorSize != kBytesPerSector) {
2478
dip.sectorSize = kBytesPerSector;
2485
dip.sectorOffset = 0;
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);
2494
if (extclumpblks == 0) {
2495
clumpSize = CalcHFSPlusBTreeClumpSize(gBlockSize, extnodesiz, sectorCount, FALSE);
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);
2503
if (atrclumpblks == 0) {
2505
@@ -754,22 +806,22 @@
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);
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 @@
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);
2560
- printf("\twrapper growable from %ld to %ld sectors\n", sectorCount, hfsgrowblks);
2561
+ printf("\twrapper growable from %i to %i sectors\n", sectorCount, hfsgrowblks);
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
2571
* @APPLE_LICENSE_HEADER_END@
2574
-#include <CoreFoundation/CFBase.h>
2577
+#include "missing.h"
2579
+#include <CoreFoundation/CFBase.h>*/
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' */
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
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' */
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' */
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' */