/packages/sysutils/diskdev_cmds/patches/diskdev_cmds-332.14-main.patch
http://github.com/OpenELEC/OpenELEC.tv · Patch · 2713 lines · 2554 code · 159 blank · 0 comment · 0 complexity · 26a2fbca3cb0cb14e8109b25084f81d1 MD5 · raw file
Large files are truncated click here to view the full file
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/cache.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/cache.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/cache.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/cache.c 2008-07-01 22:30:11.000000000 +0200
- @@ -26,7 +26,11 @@
- #include <stdlib.h>
- #include <sys/mman.h>
- #include <sys/stat.h>
- +#if LINUX
- +#include "missing.h"
- +#else
- #include <sys/types.h>
- +#endif /* __LINUX__ */
- #include <sys/uio.h>
- #include <unistd.h>
- #include <string.h>
- Files diskdev_cmds-332.14/fsck_hfs.tproj/cache.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/cache.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BlockCache.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BlockCache.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BlockCache.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BlockCache.c 2008-07-01 22:30:11.000000000 +0200
- @@ -20,6 +20,9 @@
- * @APPLE_LICENSE_HEADER_END@
- */
-
- +#if LINUX
- +#include "missing.h"
- +#endif
- #include "SRuntime.h"
- #include "Scavenger.h"
- #include "../cache.h"
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BlockCache.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BlockCache.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeAllocate.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeAllocate.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTree.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTree.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTree.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTree.c 2008-07-01 22:30:11.000000000 +0200
- @@ -1705,7 +1705,9 @@
- UInt16 version,
- BTreeInfoRec *info )
- {
- +#if !LINUX
- #pragma unused (version)
- +#endif
-
- BTreeControlBlockPtr btreePtr;
-
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeMiscOps.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeMiscOps.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeNodeOps.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeNodeOps.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTree.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTree.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeScanner.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeScanner.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeTreeOps.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeTreeOps.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeTreeOps.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeTreeOps.c 2008-07-01 22:30:11.000000000 +0200
- @@ -223,7 +223,7 @@
- //
- if (curNodeNum == 0)
- {
- -// Panic("\pSearchTree: curNodeNum is zero!");
- + Panic("SearchTree: curNodeNum is zero!");
- err = fsBTInvalidNodeErr;
- goto ErrorExit;
- }
- @@ -433,7 +433,7 @@
- M_ExitOnError (err);
-
- if ( DEBUG_BUILD && updateParent && newRoot )
- - DebugStr("\p InsertLevel: New root from primary key, update from secondary key...");
- + DebugStr("InsertLevel: New root from primary key, update from secondary key...");
- }
-
- //////////////////////// Update Parent(s) ///////////////////////////////
- @@ -448,7 +448,7 @@
-
- secondaryKey = nil;
-
- - PanicIf ( (level == btreePtr->treeDepth), "\p InsertLevel: unfinished insert!?");
- + PanicIf ( (level == btreePtr->treeDepth), "InsertLevel: unfinished insert!?");
-
- ++level;
-
- @@ -456,7 +456,7 @@
- index = treePathTable [level].index;
- parentNodeNum = treePathTable [level].node;
-
- - PanicIf ( parentNodeNum == 0, "\p InsertLevel: parent node is zero!?");
- + PanicIf ( parentNodeNum == 0, "InsertLevel: parent node is zero!?");
-
- err = GetNode (btreePtr, parentNodeNum, &parentNode); // released as target node in next level up
- M_ExitOnError (err);
- @@ -470,7 +470,7 @@
- {
- //ее╩debug: check if ptr == targetNodeNum
- GetRecordByIndex (btreePtr, parentNode.buffer, index, &keyPtr, &recPtr, &recSize);
- - PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, "\p InsertLevel: parent ptr doesn't match target node!");
- + PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, "InsertLevel: parent ptr doesn't match target node!");
-
- // need to delete and re-insert this parent key/ptr
- // we delete it here and it gets re-inserted in the
- @@ -532,7 +532,7 @@
- (void) ReleaseNode (btreePtr, targetNode);
- (void) ReleaseNode (btreePtr, &siblingNode);
-
- - Panic ("\p InsertLevel: an error occured!");
- + Panic ("InsertLevel: an error occured!");
-
- return err;
-
- @@ -566,7 +566,7 @@
-
- *rootSplit = false;
-
- - PanicIf ( targetNode->buffer == siblingNode->buffer, "\p InsertNode: targetNode == siblingNode, huh?");
- + PanicIf ( targetNode->buffer == siblingNode->buffer, "InsertNode: targetNode == siblingNode, huh?");
-
- leftNodeNum = ((NodeDescPtr) targetNode->buffer)->bLink;
- rightNodeNum = ((NodeDescPtr) targetNode->buffer)->fLink;
- @@ -606,7 +606,7 @@
-
- if ( leftNodeNum > 0 )
- {
- - PanicIf ( siblingNode->buffer != nil, "\p InsertNode: siblingNode already aquired!");
- + PanicIf ( siblingNode->buffer != nil, "InsertNode: siblingNode already aquired!");
-
- if ( siblingNode->buffer == nil )
- {
- @@ -614,7 +614,7 @@
- M_ExitOnError (err);
- }
-
- - PanicIf ( ((NodeDescPtr) siblingNode->buffer)->fLink != nodeNum, "\p InsertNode, RotateLeft: invalid sibling link!" );
- + PanicIf ( ((NodeDescPtr) siblingNode->buffer)->fLink != nodeNum, "InsertNode, RotateLeft: invalid sibling link!" );
-
- if ( !key->skipRotate ) // are rotates allowed?
- {
- @@ -703,7 +703,7 @@
-
- targetNodeNum = treePathTable[level].node;
- targetNodePtr = targetNode->buffer;
- - PanicIf (targetNodePtr == nil, "\pDeleteTree: targetNode has nil buffer!");
- + PanicIf (targetNodePtr == nil, "DeleteTree: targetNode has nil buffer!");
-
- DeleteRecord (btreePtr, targetNodePtr, index);
-
- @@ -797,7 +797,7 @@
-
- //ее╩debug: check if ptr == targetNodeNum
- GetRecordByIndex (btreePtr, parentNode.buffer, index, &keyPtr, &recPtr, &recSize);
- - PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, "\p DeleteTree: parent ptr doesn't match targetNodeNum!!");
- + PanicIf( (*(UInt32 *) recPtr) != targetNodeNum, " DeleteTree: parent ptr doesn't match targetNodeNum!!");
-
- // need to delete and re-insert this parent key/ptr
- DeleteRecord (btreePtr, parentNode.buffer, index);
- @@ -1018,7 +1018,7 @@
- keyPtr, keyLength, recPtr, recSize);
- if ( !didItFit )
- {
- - Panic ("\pRotateLeft: InsertKeyRecord (left) returned false!");
- + Panic ("RotateLeft: InsertKeyRecord (left) returned false!");
- err = fsBTBadRotateErr;
- goto ErrorExit;
- }
- @@ -1031,7 +1031,7 @@
- didItFit = RotateRecordLeft (btreePtr, leftNode, rightNode);
- if ( !didItFit )
- {
- - Panic ("\pRotateLeft: RotateRecordLeft returned false!");
- + Panic ("RotateLeft: RotateRecordLeft returned false!");
- err = fsBTBadRotateErr;
- goto ErrorExit;
- }
- @@ -1048,7 +1048,7 @@
- keyPtr, keyLength, recPtr, recSize);
- if ( !didItFit )
- {
- - Panic ("\pRotateLeft: InsertKeyRecord (right) returned false!");
- + Panic ("RotateLeft: InsertKeyRecord (right) returned false!");
- err = fsBTBadRotateErr;
- goto ErrorExit;
- }
- @@ -1117,7 +1117,7 @@
- right = rightNode->buffer;
- left = leftNode->buffer;
-
- - PanicIf ( right->bLink != 0 && left == 0, "\p SplitLeft: left sibling missing!?" );
- + PanicIf ( right->bLink != 0 && left == 0, " SplitLeft: left sibling missing!?" );
-
- //ее type should be kLeafNode or kIndexNode
-
- @@ -1240,8 +1240,8 @@
- Boolean didItFit;
- UInt16 keyLength;
-
- - PanicIf (leftNode == nil, "\pAddNewRootNode: leftNode == nil");
- - PanicIf (rightNode == nil, "\pAddNewRootNode: rightNode == nil");
- + PanicIf (leftNode == nil, "AddNewRootNode: leftNode == nil");
- + PanicIf (rightNode == nil, "AddNewRootNode: rightNode == nil");
-
-
- /////////////////////// Initialize New Root Node ////////////////////////////
- @@ -1264,7 +1264,7 @@
- didItFit = InsertKeyRecord ( btreePtr, rootNode.buffer, 0, keyPtr, keyLength,
- (UInt8 *) &rightNode->bLink, 4 );
-
- - PanicIf ( !didItFit, "\pAddNewRootNode:InsertKeyRecord failed for left index record");
- + PanicIf ( !didItFit, "AddNewRootNode:InsertKeyRecord failed for left index record");
-
-
- //////////////////// Insert Right Node Index Record /////////////////////////
- @@ -1275,7 +1275,7 @@
- didItFit = InsertKeyRecord ( btreePtr, rootNode.buffer, 1, keyPtr, keyLength,
- (UInt8 *) &leftNode->fLink, 4 );
-
- - PanicIf ( !didItFit, "\pAddNewRootNode:InsertKeyRecord failed for right index record");
- + PanicIf ( !didItFit, "AddNewRootNode:InsertKeyRecord failed for right index record");
-
-
- #if DEBUG_TREEOPS
- @@ -1355,7 +1355,7 @@
- }
- rightPtr = rightNodePtr->buffer;
-
- - PanicIf ( leftPtr->fLink != 0 && rightPtr == 0, "\p SplitRight: right sibling missing!?" );
- + PanicIf ( leftPtr->fLink != 0 && rightPtr == 0, "SplitRight: right sibling missing!?" );
-
- //ее type should be kLeafNode or kIndexNode
-
- @@ -1557,7 +1557,7 @@
- keyPtr, keyLength, recPtr, recSize);
- if ( !didItFit )
- {
- - Panic ("\pRotateRight: InsertKeyRecord (left) returned false!");
- + Panic ("RotateRight: InsertKeyRecord (left) returned false!");
- err = fsBTBadRotateErr;
- goto ErrorExit;
- }
- @@ -1572,7 +1572,7 @@
- didItFit = RotateRecordRight( btreePtr, leftNodePtr, rightNodePtr );
- if ( !didItFit )
- {
- - Panic ("\pRotateRight: RotateRecordRight returned false!");
- + Panic ("RotateRight: RotateRecordRight returned false!");
- err = fsBTBadRotateErr;
- goto ErrorExit;
- }
- @@ -1583,7 +1583,7 @@
- keyPtr, keyLength, recPtr, recSize);
- if ( !didItFit )
- {
- - Panic ("\pRotateRight: InsertKeyRecord (left) returned false!");
- + Panic ("RotateRight: InsertKeyRecord (left) returned false!");
- err = fsBTBadRotateErr;
- goto ErrorExit;
- }
- @@ -1607,7 +1607,7 @@
- keyPtr, keyLength, recPtr, recSize);
- if ( !didItFit )
- {
- - Panic ("\pRotateRight: InsertKeyRecord (right) returned false!");
- + Panic ("RotateRight: InsertKeyRecord (right) returned false!");
- err = fsBTBadRotateErr;
- goto ErrorExit;
- }
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/BTreeTreeOps.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/BTreeTreeOps.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/CatalogCheck.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/CatalogCheck.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/HardLinkCheck.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/HardLinkCheck.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/hfs_endian.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/hfs_endian.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/hfs_endian.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/hfs_endian.c 2008-07-02 00:10:48.000000000 +0200
- @@ -31,7 +31,11 @@
- #include <sys/types.h>
- #include <sys/stat.h>
-
- +#if LINUX
- +#include "missing.h"
- +#else
- #include <architecture/byte_order.h>
- +#endif
- #include <hfs/hfs_format.h>
-
- #include "Scavenger.h"
- @@ -194,7 +198,7 @@
- BTNodeDescriptor *srcDesc = src->buffer;
- BTreeControlBlockPtr btcb = fcb->fcbBtree;
- UInt16 *srcOffs = NULL;
- - UInt32 i;
- + int i;
- int error = 0;
-
- // WriteError(fcb->fcbVolume->vcbGPtr, E_BadNode, fcb->fcbFileID, src->blockNum);
- @@ -433,7 +437,7 @@
- BTNodeDescriptor *srcDesc = src->buffer;
- UInt16 *srcOffs = (UInt16 *)((char *)src->buffer + (src->blockSize - (srcDesc->numRecords * sizeof (UInt16))));
- char *nextRecord; /* Points to start of record following current one */
- - UInt32 i;
- + int i;
- UInt32 j;
-
- if (fileID == kHFSExtentsFileID) {
- @@ -559,7 +563,7 @@
- /* Make sure name length is consistent with key length */
- if (keyLength < sizeof(srcKey->parentID) + sizeof(srcKey->nodeName.length) +
- srcKey->nodeName.length*sizeof(srcKey->nodeName.unicode[0])) {
- - if (debug) printf("hfs_swap_HFSPlusBTInternalNode: catalog record #%d keyLength=%d expected=%lu\n",
- + if (debug) printf("hfs_swap_HFSPlusBTInternalNode: catalog record #%d keyLength=%d expected=%i\n",
- srcDesc->numRecords-i, keyLength, sizeof(srcKey->parentID) + sizeof(srcKey->nodeName.length) +
- srcKey->nodeName.length*sizeof(srcKey->nodeName.unicode[0]));
- WriteError(fcb->fcbVolume->vcbGPtr, E_KeyLen, fcb->fcbFileID, src->blockNum);
- @@ -854,7 +858,7 @@
- UInt16 *srcOffs = (UInt16 *)((char *)src->buffer + (src->blockSize - (srcDesc->numRecords * sizeof (UInt16))));
- char *nextRecord; /* Points to start of record following current one */
-
- - UInt32 i;
- + int i;
- UInt32 j;
-
- if (fileID == kHFSExtentsFileID) {
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/hfs_endian.h diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/hfs_endian.h
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/hfs_endian.h 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/hfs_endian.h 2008-07-01 22:30:11.000000000 +0200
- @@ -27,9 +27,14 @@
- *
- * This file prototypes endian swapping routines for the HFS/HFS Plus
- * volume format.
- - */
- +*/
- #include <hfs/hfs_format.h>
- +#if LINUX
- +#include <endian.h>
- +#include <byteswap.h>
- +#else
- #include <architecture/byte_order.h>
- +#endif
- #include "SRuntime.h"
-
- /*********************/
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/hfs_endian.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/hfs_endian.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/libdfa.a and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/libdfa.a differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/Makefile.lnx diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/Makefile.lnx
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/Makefile.lnx 1970-01-01 01:00:00.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/Makefile.lnx 2008-07-01 22:30:11.000000000 +0200
- @@ -0,0 +1,15 @@
- +CFILES = hfs_endian.c BlockCache.c\
- + BTree.c BTreeAllocate.c BTreeMiscOps.c \
- + BTreeNodeOps.c BTreeScanner.c BTreeTreeOps.c\
- + CatalogCheck.c HardLinkCheck.c\
- + SBTree.c SControl.c SVerify1.c SVerify2.c\
- + SRepair.c SRebuildCatalogBTree.c\
- + SUtils.c SKeyCompare.c SDevice.c SExtents.c SAllocate.c\
- + SCatalog.c SStubs.c VolumeBitmapCheck.c
- +OFILES = $(CFILES:.c=.o)
- +
- +libdfa.a: $(OFILES)
- + $(AR) rc $@ $?
- +
- +clean:
- + $(RM) $(OFILES) libdfa.a
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SAllocate.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SAllocate.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SBTree.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SBTree.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SBTree.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SBTree.c 2008-07-01 22:30:11.000000000 +0200
- @@ -93,7 +93,7 @@
- CopyMemory(&resultIterator->key, foundKey, CalcKeySize(btcb, &resultIterator->key)); //ее warning, this could overflow user's buffer!!!
-
- if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, *dataSize) )
- - DebugStr("\pSearchBTreeRecord: bad record?");
- + DebugStr("SearchBTreeRecord: bad record?");
- }
-
- ErrorExit:
- @@ -190,7 +190,7 @@
- CopyMemory(&iterator->key, key, CalcKeySize(btcb, &iterator->key)); //ее warning, this could overflow user's buffer!!!
-
- if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, *dataSize) )
- - DebugStr("\pGetBTreeRecord: bad record?");
- + DebugStr("GetBTreeRecord: bad record?");
-
- }
-
- @@ -222,7 +222,7 @@
- CopyMemory(key, &iterator.key, CalcKeySize(btcb, (BTreeKey *) key)); //ее should we range check against maxkeylen?
-
- if ( DEBUG_BUILD && !ValidHFSRecord(data, btcb, dataSize) )
- - DebugStr("\pInsertBTreeRecord: bad record?");
- + DebugStr("InsertBTreeRecord: bad record?");
-
- result = BTInsertRecord( fcb, &iterator, &btRecord, dataSize );
-
- @@ -284,7 +284,7 @@
- CopyMemory(key, &iterator.key, CalcKeySize(btcb, (BTreeKey *) key)); //ее should we range check against maxkeylen?
-
- if ( DEBUG_BUILD && !ValidHFSRecord(newData, btcb, dataSize) )
- - DebugStr("\pReplaceBTreeRecord: bad record?");
- + DebugStr("ReplaceBTreeRecord: bad record?");
-
- result = BTReplaceRecord( fcb, &iterator, &btRecord, dataSize );
-
- @@ -301,7 +301,9 @@
- OSStatus
- SetEndOfForkProc ( SFCB *filePtr, FSSize minEOF, FSSize maxEOF )
- {
- +#if !LINUX
- #pragma unused (maxEOF)
- +#endif
-
- OSStatus result;
- UInt32 actualSectorsAdded;
- @@ -321,7 +323,7 @@
- else
- {
- if ( DEBUG_BUILD )
- - DebugStr("\pSetEndOfForkProc: minEOF is smaller than current size!");
- + DebugStr("SetEndOfForkProc: minEOF is smaller than current size!");
- return -1;
- }
-
- @@ -347,7 +349,7 @@
- // Make sure we got at least as much space as we needed
- //
- if (filePtr->fcbLogicalSize < minEOF) {
- - Panic("\pSetEndOfForkProc: disk too full to extend B-tree file");
- + Panic("SetEndOfForkProc: disk too full to extend B-tree file");
- return dskFulErr;
- }
-
- @@ -419,7 +421,7 @@
- if ( (keyLen < 6) || (keyLen > btcb->maxKeyLength) )
- {
- if ( DEBUG_BUILD )
- - DebugStr("\pCheckBTreeKey: bad key length!");
- + DebugStr("CheckBTreeKey: bad key length!");
- return fsBTInvalidKeyLengthErr;
- }
-
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SBTree.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SBTree.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SCatalog.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SCatalog.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/Scavenger.h diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/Scavenger.h
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/Scavenger.h 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/Scavenger.h 2008-07-01 22:30:11.000000000 +0200
- @@ -35,11 +35,16 @@
- #include "BTreeScanner.h"
- #include "hfs_endian.h"
-
- +#if LINUX
- +#define XATTR_MAXNAMELEN 127
- +#include <limits.h>
- +#else
- #include <sys/xattr.h>
- #include <sys/acl.h>
- #include <sys/kauth.h>
- -#include <sys/errno.h>
- #include <sys/syslimits.h>
- +#endif
- +#include <sys/errno.h>
-
- #ifdef __cplusplus
- extern "C" {
- @@ -1434,4 +1439,8 @@
- };
- #endif
-
- +#if LINUX
- +#undef XATTR_MAXNAMELEN
- +#endif
- +
- #endif /* __SCAVENGER__ */
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SControl.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SControl.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SControl.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SControl.c 2008-07-01 22:30:11.000000000 +0200
- @@ -739,7 +739,7 @@
- pointer = (ScavStaticStructures *) AllocateClearMemory( sizeof(ScavStaticStructures) );
- if ( pointer == nil ) {
- if ( GPtr->logLevel >= kDebugLog ) {
- - printf( "\t error %d - could not allocate %ld bytes of memory \n",
- + printf( "\t error %d - could not allocate %i bytes of memory \n",
- R_NoMem, sizeof(ScavStaticStructures) );
- }
- return( R_NoMem );
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SControl.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SControl.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SDevice.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SDevice.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SDevice.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SDevice.c 2008-07-01 22:30:11.000000000 +0200
- @@ -28,24 +28,61 @@
- #include <unistd.h>
- #include <errno.h>
- #include <sys/ioctl.h>
- -
- +#if LINUX
- +#include <fcntl.h>
- +#include <sys/stat.h>
- +#else
- #include <IOKit/storage/IOMediaBSDClient.h>
- -
- +#endif /* LINUX */
- #else
- -
- #include <Files.h>
- #include <Device.h>
- #include <Disks.h>
-
- -#endif
- -
- +#endif
-
- OSErr GetDeviceSize(int driveRefNum, UInt64 *numBlocks, UInt32 *blockSize)
- {
- #if BSD
- UInt64 devBlockCount = 0;
- int devBlockSize = 0;
- +#if LINUX
- + struct stat stbuf;
- +
- + devBlockSize = 512;
-
- +#ifndef BLKGETSIZE
- +#define BLKGETSIZE _IO(0x12,96)
- +#endif
- +#ifndef BLKGETSIZE64
- +#define BLKGETSIZE64 _IOR(0x12,114,size_t)
- +#endif
- + if (fstat(driveRefNum, &stbuf) < 0){
- + printf("Error: %s\n", strerror(errno));
- + return(-1);
- + }
- +
- + if (S_ISREG(stbuf.st_mode)) {
- + devBlockCount = stbuf.st_size / 512;
- + }
- + else if (S_ISBLK(stbuf.st_mode)) {
- + unsigned long size;
- + u_int64_t size64;
- + if (!ioctl(driveRefNum, BLKGETSIZE64, &size64))
- + devBlockCount = size64 / 512;
- + else if (!ioctl(driveRefNum, BLKGETSIZE, &size))
- + devBlockCount = size;
- + else{
- + printf("Error: %s\n", strerror(errno));
- + return(-1);
- + }
- +
- + }
- + else{
- + printf("Device is not a block device");
- + return(-1);
- + }
- +#elif BSD
- if (ioctl(driveRefNum, DKIOCGETBLOCKCOUNT, &devBlockCount) < 0) {
- printf("ioctl(DKIOCGETBLOCKCOUNT) for fd %d: %s\n", driveRefNum, strerror(errno));
- return (-1);
- @@ -55,6 +92,7 @@
- printf("ioctl(DKIOCGETBLOCKSIZE) for fd %d: %s\n", driveRefNum, strerror(errno));
- return (-1);
- }
- +#endif /* BSD */
-
- if (devBlockSize != 512) {
- *numBlocks = (devBlockCount * (UInt64)devBlockSize) / 512;
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SDevice.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SDevice.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SExtents.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SExtents.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SKeyCompare.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SKeyCompare.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SKeyCompare.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SKeyCompare.c 2008-07-01 22:30:11.000000000 +0200
- @@ -454,7 +454,9 @@
- * The name portion of the key is compared using a 16-bit binary comparison.
- * This is called from the b-tree code.
- */
- +#if !LINUX
- __private_extern__
- +#endif
- SInt32
- CompareAttributeKeys(const AttributeKey *searchKey, const AttributeKey *trialKey)
- {
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SKeyCompare.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SKeyCompare.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SRebuildCatalogBTree.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SRebuildCatalogBTree.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SRepair.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SRepair.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SRepair.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SRepair.c 2008-07-01 22:30:11.000000000 +0200
- @@ -1593,7 +1593,9 @@
-
- static OSErr FixWrapperExtents( SGlobPtr GPtr, RepairOrderPtr p )
- {
- +#if !LINUX
- #pragma unused (p)
- +#endif
-
- OSErr err;
- HFSMasterDirectoryBlock *mdb;
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SRepair.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SRepair.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SRuntime.h diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SRuntime.h
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SRuntime.h 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SRuntime.h 2008-07-01 22:30:11.000000000 +0200
- @@ -27,8 +27,11 @@
- #define __SRUNTIME__
-
- #if BSD
- -
- +#if LINUX
- +#include "missing.h"
- +#else
- #include <sys/types.h>
- +#endif
- #include <stdlib.h>
- #include <string.h>
- #include <stdio.h>
- @@ -91,10 +94,12 @@
-
- typedef u_int32_t HFSCatalogNodeID;
-
- +#if !LINUX
- enum {
- false = 0,
- true = 1
- };
- +#endif
-
- /* OS error codes */
- enum {
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SStubs.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SStubs.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SUtils.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SUtils.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SUtils.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SUtils.c 2008-07-01 22:30:11.000000000 +0200
- @@ -380,7 +380,8 @@
- // GPtr->realVCB Real in-memory vcb
- //------------------------------------------------------------------------------
-
- -#if !BSD
- +#if BSD
- +#if !LINUX
- OSErr GetVolumeFeatures( SGlobPtr GPtr )
- {
- OSErr err;
- @@ -418,7 +419,7 @@
- return( noErr );
- }
- #endif
- -
- +#endif
-
-
- /*-------------------------------------------------------------------------------
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SUtils.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SUtils.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SVerify1.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SVerify1.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SVerify2.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SVerify2.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SVerify2.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SVerify2.c 2008-07-01 22:30:11.000000000 +0200
- @@ -32,7 +32,9 @@
- */
-
- #include <sys/ioctl.h>
- +#if !LINUX
- #include <sys/disk.h>
- +#endif
-
- #include "BTree.h"
- #include "BTreePrivate.h"
- @@ -1240,8 +1242,13 @@
- * clump size for read-only media is irrelevant we skip the clump size
- * check to avoid non useful warnings.
- */
- +#if LINUX
- + // FIXME
- + isWriteable = 1;
- +#else
- isWriteable = 0;
- ioctl( GPtr->DrvNum, DKIOCISWRITABLE, &isWriteable );
- +#endif
- if ( isWriteable != 0 &&
- volumeHeader->catalogFile.clumpSize != vcb->vcbCatalogFile->fcbClumpSize ) {
- PrintError(GPtr, E_InvalidClumpSize, 0);
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/SVerify2.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/SVerify2.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/dfalib/VolumeBitmapCheck.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/dfalib/VolumeBitmapCheck.o differ
- Files diskdev_cmds-332.14/fsck_hfs.tproj/fsck_hfs and diskdev_cmds-332.14-patched/fsck_hfs.tproj/fsck_hfs differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/fsck_hfs.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/fsck_hfs.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/fsck_hfs.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/fsck_hfs.c 2008-07-01 22:36:12.000000000 +0200
- @@ -24,10 +24,14 @@
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/param.h>
- +#if !LINUX
- #include <sys/ucred.h>
- +#endif
- #include <sys/mount.h>
- #include <sys/ioctl.h>
- +#if !LINUX
- #include <sys/disk.h>
- +#endif
-
- #include <hfs/hfs_mount.h>
-
- @@ -105,7 +109,7 @@
- else
- progname = *argv;
-
- - while ((ch = getopt(argc, argv, "dfglm:npqruy")) != EOF) {
- + while ((ch = getopt(argc, argv, "dfglm:napqruy")) != EOF) {
- switch (ch) {
- case 'd':
- debug++;
- @@ -141,6 +145,7 @@
- yflag = 0;
- break;
-
- + case 'a':
- case 'p':
- preen++;
- break;
- @@ -170,10 +175,12 @@
-
- if (guiControl)
- debug = 0; /* debugging is for command line only */
- -
- +#if LINUX
- +// FIXME
- +#else
- if (signal(SIGINT, SIG_IGN) != SIG_IGN)
- (void)signal(SIGINT, catch);
- -
- +#endif
- if (argc < 1) {
- (void) fprintf(stderr, "%s: missing special-device\n", progname);
- usage();
- @@ -194,7 +201,9 @@
- int chkLev, repLev, logLev;
- int blockDevice_fd, canWrite;
- char *unraw, *mntonname;
- +#if !LINUX
- struct statfs *fsinfo;
- +#endif
- int fs_fd=-1; // fd to the root-dir of the fs we're checking (only w/lfag == 1)
-
- flags = 0;
- @@ -203,7 +212,9 @@
- canWrite = 0;
- unraw = NULL;
- mntonname = NULL;
- -
- +#if LINUX
- + // FIXME
- +#else
- if (lflag) {
- result = getmntinfo(&fsinfo, MNT_NOWAIT);
-
- @@ -233,7 +244,7 @@
- }
- }
- }
- -
- +#endif
- if (debug && preen)
- pwarn("starting\n");
-
- @@ -306,6 +317,9 @@
- }
- }
- } else {
- +#if LINUX
- + // FIXME
- +#else
- struct statfs stfs_buf;
- /*
- * Check to see if root is mounted read-write.
- @@ -315,18 +329,24 @@
- else
- flags = 0;
- ckfini(flags & MNT_RDONLY);
- +#endif
- }
-
- /* XXX free any allocated memory here */
-
- if (hotroot && fsmodified) {
- +#if !LINUX
- struct hfs_mount_args args;
- +#endif
- /*
- * We modified the root. Do a mount update on
- * it, unless it is read-write, so we can continue.
- */
- if (!preen)
- printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
- +#if LINUX
- + // FIXME
- +#else
- if (flags & MNT_RDONLY) {
- bzero(&args, sizeof(args));
- flags |= MNT_UPDATE | MNT_RELOAD;
- @@ -335,6 +355,7 @@
- goto ExitThisRoutine;
- }
- }
- +#endif
- if (!preen)
- printf("\n***** REBOOT NOW *****\n");
- sync();
- @@ -380,11 +401,13 @@
- printf("Can't stat %s: %s\n", dev, strerror(errno));
- return (0);
- }
- +#if !LINUX
- if ((statb.st_mode & S_IFMT) != S_IFCHR) {
- pfatal("%s is not a character device", dev);
- if (reply("CONTINUE") == 0)
- return (0);
- }
- +#endif
- if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
- printf("Can't open %s: %s\n", dev, strerror(errno));
- return (0);
- @@ -407,10 +430,14 @@
- printf("\n");
-
- /* Get device block size to initialize cache */
- +#if LINUX
- + devBlockSize = 512;
- +#else
- if (ioctl(fsreadfd, DKIOCGETBLOCKSIZE, &devBlockSize) < 0) {
- pfatal ("Can't get device block size\n");
- return (0);
- }
- +#endif
- /* Initialize the cache */
- if (CacheInit (&fscache, fsreadfd, fswritefd, devBlockSize,
- CACHE_IOSIZE, CACHE_BLOCKS, CACHE_HASHSIZE) != EOK) {
- @@ -431,11 +458,15 @@
-
- static void getWriteAccess( char *dev, int *blockDevice_fdPtr, int *canWritePtr )
- {
- +#if !LINUX
- int i;
- int myMountsCount;
- +#endif
- void * myPtr;
- char * myCharPtr;
- +#if !LINUX
- struct statfs * myBufPtr;
- +#endif
- void * myNamePtr;
-
- myPtr = NULL;
- @@ -456,18 +487,19 @@
- *canWritePtr = 1;
- goto ExitThisRoutine;
- }
- -
- // get count of mounts then get the info for each
- +#if LINUX
- + // FIXME
- +#else
- myMountsCount = getfsstat( NULL, 0, MNT_NOWAIT );
- if ( myMountsCount < 0 )
- goto ExitThisRoutine;
- -
- myPtr = (void *) malloc( sizeof(struct statfs) * myMountsCount );
- if ( myPtr == NULL )
- goto ExitThisRoutine;
- myMountsCount = getfsstat( myPtr,
- - (sizeof(struct statfs) * myMountsCount),
- - MNT_NOWAIT );
- + (sizeof(struct statfs) * myMountsCount),
- + MNT_NOWAIT );
- if ( myMountsCount < 0 )
- goto ExitThisRoutine;
-
- @@ -481,8 +513,8 @@
- }
- myBufPtr++;
- }
- +#endif
- *canWritePtr = 1; // single user will get us here, f_mntfromname is not /dev/diskXXXX
- -
- ExitThisRoutine:
- if ( myPtr != NULL )
- free( myPtr );
- @@ -504,7 +536,7 @@
- (void) fprintf(stderr, " l = live fsck (lock down and test-only)\n");
- (void) fprintf(stderr, " m arg = octal mode used when creating lost+found directory \n");
- (void) fprintf(stderr, " n = assume a no response \n");
- - (void) fprintf(stderr, " p = just fix normal inconsistencies \n");
- + (void) fprintf(stderr, " p, a = just fix normal inconsistencies \n");
- (void) fprintf(stderr, " q = quick check returns clean, dirty, or failure \n");
- (void) fprintf(stderr, " r = rebuild catalog btree \n");
- (void) fprintf(stderr, " u = usage \n");
- Files diskdev_cmds-332.14/fsck_hfs.tproj/fsck_hfs.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/fsck_hfs.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/Makefile.lnx diskdev_cmds-332.14-patched/fsck_hfs.tproj/Makefile.lnx
- --- diskdev_cmds-332.14/fsck_hfs.tproj/Makefile.lnx 1970-01-01 01:00:00.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/Makefile.lnx 2008-07-01 22:30:11.000000000 +0200
- @@ -0,0 +1,15 @@
- +CFILES = fsck_hfs.c strings.c utilities.c cache.c
- +OFILES = $(CFILES:.c=.o)
- +
- +all: fsck_hfs
- +
- +fsck_hfs: $(OFILES) dfalib/libdfa.a
- +
- +dfalib/libdfa.a: FORCE
- + $(MAKE) -C dfalib -f Makefile.lnx libdfa.a
- +
- +clean:
- + $(RM) fsck_hfs $(OFILES)
- + $(MAKE) -C dfalib -f Makefile.lnx clean
- +
- +.PHONY : FORCE clean
- Files diskdev_cmds-332.14/fsck_hfs.tproj/strings.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/strings.o differ
- diff -druN diskdev_cmds-332.14/fsck_hfs.tproj/utilities.c diskdev_cmds-332.14-patched/fsck_hfs.tproj/utilities.c
- --- diskdev_cmds-332.14/fsck_hfs.tproj/utilities.c 2006-02-20 22:45:15.000000000 +0100
- +++ diskdev_cmds-332.14-patched/fsck_hfs.tproj/utilities.c 2008-07-01 22:30:11.000000000 +0200
- @@ -183,12 +183,14 @@
- printf("Can't stat %s\n", raw);
- return (origname);
- }
- +#if !LINUX
- if ((stchar.st_mode & S_IFMT) == S_IFCHR) {
- return (raw);
- } else {
- printf("%s is not a character device\n", raw);
- return (origname);
- }
- +#endif
- } else if ((stblock.st_mode & S_IFMT) == S_IFCHR && !retried) {
- newname = unrawname(newname);
- retried++;
- @@ -214,7 +216,11 @@
- *dp = 0;
- (void)strcpy(rawbuf, name);
- *dp = '/';
- - (void)strcat(rawbuf, "/r");
- +#if LINUX
- + (void)strcat(rawbuf, "/");
- +#else
- + (void)strcat(rawbuf,"/r");
- +#endif
- (void)strcat(rawbuf, &dp[1]);
-
- return (rawbuf);
- Files diskdev_cmds-332.14/fsck_hfs.tproj/utilities.o and diskdev_cmds-332.14-patched/fsck_hfs.tproj/utilities.o differ
- diff -druN diskdev_cmds-332.14/include/bitstring.h diskdev_cmds-332.14-patched/include/bitstring.h
- --- diskdev_cmds-332.14/include/bitstring.h 1970-01-01 01:00:00.000000000 +0100
- +++ diskdev_cmds-332.14-patched/include/bitstring.h 2008-07-01 22:30:11.000000000 +0200
- @@ -0,0 +1,164 @@
- +/*
- + * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
- + *
- + * @APPLE_LICENSE_HEADER_START@
- + *
- + * The contents of this file constitute Original Code as defined in and
- + * are subject to the Apple Public Source License Version 1.1 (the
- + * "License"). You may not use this file except in compliance with the
- + * License. Please obtain a copy of the License at
- + * http://www.apple.com/publicsource and read it before using this file.
- + *
- + * This Original Code and all software distributed under the License are
- + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- + * License for the specific language governing rights and limitations
- + * under the License.
- + *
- + * @APPLE_LICENSE_HEADER_END@
- + */
- +/*
- + * Copyright (c) 1989, 1993
- + * The Regents of the University of California. All rights reserved.
- + *
- + * This code is derived from software contributed to Berkeley by
- + * Paul Vixie.
- + *
- + * Redistribution and use in source and binary forms, with or without
- + * modification, are permitted provided that the following conditions
- + * are met:
- + * 1. Redistributions of source code must retain the above copyright
- + * notice, this list of conditions and the following disclaimer.
- + * 2. Redistributions in binary form must reproduce the above copyright
- + * notice, this list of conditions and the following disclaimer in the
- + * documentation and/or other materials provided with the distribution.
- + * 3. All advertising materials mentioning features or use of this software
- + * must display the following acknowledgement:
- + * This product includes software developed by the University of
- + * California, Berkeley and its contributors.
- + * 4. Neither the name of the University nor the names of its contributors
- + * may be used to endorse or promote products derived from this software
- + * without specific prior written permission.
- + *
- + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- + * SUCH DAMAGE.
- + *
- + * @(#)bitstring.h 8.1 (Berkeley) 7/19/93
- + */
- +
- +#ifndef _BITSTRING_H_
- +#define _BITSTRING_H_
- +
- +typedef unsigned char bitstr_t;
- +
- +/* internal macros */
- + /* byte of the bitstring bit is in */
- +#define _bit_byte(bit) \
- + ((bit) >> 3)
- +
- + /* mask for the bit within its byte */
- +#define _bit_mask(bit) \
- + (1 << ((bit)&0x7))
- +
- +/* external macros */
- + /* bytes in a bitstring of nbits bits */
- +#define bitstr_size(nbits) \
- + ((((nbits) - 1) >> 3) + 1)
- +
- + /* allocate a bitstring */
- +#define bit_alloc(nbits) \
- + (bitstr_t *)calloc(1, \
- + (unsigned int)bitstr_size(nbits) * sizeof(bitstr_t))
- +
- + /* allocate a bitstring on the stack */
- +#define bit_decl(name, nbits) \
- + (name)[bitstr_size(nbits)]
- +
- + /* is bit N of bitstring name set? */
- +#define bit_test(name, bit) \
- + ((name)[_bit_byte(bit)] & _bit_mask(bit))
- +
- + /* set bit N of bitstring name */
- +#define bit_set(name, bit) \
- + (name)[_bit_byte(bit)] |= _bit_mask(bit)
- +
- + /* clear bit N of bitstring name */
- +#define bit_clear(name, bit) \
- + (name)[_bit_byte(bit)] &= ~_bit_mask(bit)
- +
- + /* clear bits start ... stop in bitstring */
- +#define bit_nclear(name, start, stop) { \
- + register bitstr_t *_name = name; \
- + register int _start = start, _stop = stop; \
- + register int _startbyte = _bit_byte(_start); \
- + register int _stopbyte = _bit_byte(_stop); \
- + if (_startbyte == _stopbyte) { \
- + _name[_startbyte] &= ((0xff >> (8 - (_start&0x7))) | \
- + (0xff << ((_stop&0x7) + 1))); \
- + } else { \
- + _name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \
- + while (++_startbyte < _stopbyte) \
- + _name[_startbyte] = 0; \
- + _name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \
- + } \
- +}
- +
- + /* set bits start ... stop in bitstring */
- +#define bit_nset(name, start, stop) { \
- + register bitstr_t *_name = name; \
- + register int _start = start, _stop = stop; \
- + register int _startbyte = _bit_byte(_start); \
- + register int _stopbyte = _bit_byte(_stop); \
- + if (_startbyte == _stopbyte) { \
- + _name[_startbyte] |= ((0xff << (_start&0x7)) & \
- + (0xff >> (7 - (_stop&0x7)))); \
- + } else { \
- + _name[_startbyte] |= 0xff << ((_start)&0x7); \
- + while (++_startbyte < _stopbyte) \
- + _name[_startbyte] = 0xff; \
- + _name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \
- + } \
- +}
- +
- + /* find first bit clear in name */
- +#define bit_ffc(name, nbits, value) { \
- + register bitstr_t *_name = name; \
- + register int _byte, _nbits = nbits; \
- + register int _stopbyte = _bit_byte(_nbits), _value = -1; \
- + for (_byte = 0; _byte <= _stopbyte; ++_byte) \
- + if (_name[_byte] != 0xff) { \
- + _value = _byte << 3; \
- + for (_stopbyte = _name[_byte]; (_stopbyte&0x1); \
- + ++_value, _stopbyte >>= 1); \
- + break; \
- + } \
- + *(value) = _value; \
- +}
- +
- + /* find first bit set in name */
- +#define bit_ffs(name, nbits, value) { \
- + register bitstr_t *_name = name; \
- + register int _byte, _nbits = nbits; \
- + register int _stopbyte = _bit_byte(_nbits), _value = -1; \
- + for (_byte = 0; _byte <= _stopbyte; ++_byte) \
- + if (_name[_byte]) { \
- + _value = _byte << 3; \
- + for (_stopbyte = _name[_byte]; !(_stopbyte&0x1); \
- + ++_value, _stopbyte >>= 1); \
- + break; \
- + } \
- + *(value) = _value; \
- +}
- +
- +#endif /* !_BITSTRING_H_ */
- diff -druN diskdev_cmds-332.14/include/hfs/hfs_format.h diskdev_cmds-332.14-patched/include/hfs/hfs_format.h
- --- diskdev_cmds-332.14/include/hfs/hfs_format.h 1970-01-01 01:00:00.000000000 +0100
- +++ diskdev_cmds-332.14-patched/include/hfs/hfs_format.h 2008-07-01 22:30:11.000000000 +0200
- @@ -0,0 +1,689 @@
- +/*
- + * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
- + *
- + * @APPLE_LICENSE_HEADER_START@
- + *
- + * The contents of this file constitute Original Code as defined in and
- + * are subject to the Apple Public Source License Version 1.1 (the
- + * "License"). You may not use this file except in compliance with the
- + * License. Please obtain a copy of the License at
- + * http://www.apple.com/publicsource and read it before using this file.
- + *
- + * This Original Code and all software distributed under the License are
- + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- + * License for the specific language governing rights and limitations
- + * under the License.
- + *
- + * @APPLE_LICENSE_HEADER_END@
- + */
- +#ifndef __HFS_FORMAT__
- +#define __HFS_FORMAT__
- +
- +#include "missing.h"
- +
- +#include <sys/appleapiopts.h>
- +
- +/*
- + * hfs_format.c
- + *
- + * This file describes the on-disk format for HFS and HFS Plus volumes.
- + * The HFS Plus volume format is desciibed in detail in Apple Technote 1150.
- + *
- + * http://developer.apple.com/technotes/tn/tn1150.html
- + *
- + */
- +
- +#ifdef __cplusplus
- +extern "C" {
- +#endif
- +
- +/* some on-disk hfs structures have 68K alignment (misaligned) */
- +
- +#define PACKED_S __attribute__((packed))
- +
- +/* Signatures used to differentiate between HFS and HFS Plus volumes */
- +enum {
- + kHFSSigWord = 0x4244, /* 'BD' in ASCII */
- + kHFSPlusSigWord = 0x482B, /* 'H+' in ASCII */
- + kHFSXSigWord = 0x4858, /* 'HX' in ASCII */
- +
- + kHFSPlusVersion = 0x0004, /* 'H+' volumes are version 4 only */
- + kHFSXVersion = 0x0005, /* 'HX' volumes start with version 5 */
- +
- + kHFSPlusMountVersion = 0x31302E30, /* '10.0' for Mac OS X */
- + kHFSJMountVersion = 0x4846534a, /* 'HFSJ' for journaled HFS+ on OS X */
- + kFSKMountVersion = 0x46534b21 /* 'FSK!' for failed journal replay */
- +}PACKED_S;
- +
- +
- +#ifdef __APPLE_API_PRIVATE
- +/*
- + * Mac OS X has a special directory for linked and unlinked files (HFS Plus only).
- + * This directory and its contents are never exported from the filesystem under
- + * Mac OS X.
- + *
- + * To make this folder name sort last, it has embedded null prefix.
- + * (0xC0, 0x80 in UTF-8)
- + */
- +#define HFSPLUSMETADATAFOLDER "\xC0\x80\xC0\x80\xC0\x80\xC0\x80HFS+ Private Data"
- +
- +/*
- + * Files in the HFS Private Data folder have one of the following prefixes
- + * followed by a decimal number (no leading zeros). For indirect nodes this
- + * number is a 32 bit random number. For unlinked (deleted) files that are
- + * still open, the number is the file ID for that file.
- + *
- + * e.g. iNode7182000 and temp3296
- + */
- +#define HFS_INODE_PREFIX "iNode"
- +#define HFS_DELETE_PREFIX "temp"
- +
- +#endif /* __APPLE_API_PRIVATE */
- +
- +/*
- + * Indirect link files (hard links) have the following type/creator.
- + */
- +enum {
- + kHardLinkFileType = 0x686C6E6B, /* 'hlnk' */
- + kHFSPlusCreator = 0x6866732B /* 'hfs+' */
- +}PACKED_S;
- +
- +
- +#ifndef _HFSUNISTR255_DEFINED_
- +#define _HFSUNISTR255_DEFINED_
- +/* Unicode strings are used for HFS Plus file and folder names */
- +struct HFSUniStr255 {
- + u_int16_t length; /* number of unicode characters */
- + u_int16_t unicode[255]; /* unicode characters */
- +} PACKED_S;
- +typedef struct HFSUniStr255 HFSUniStr255;
- +typedef const HFSUniStr255 *ConstHFSUniStr255Param;
- +#endif /* _HFSUNISTR255_DEFINED_ */
- +
- +enum {
- + kHFSMaxVolumeNameChars = 27,
- + kHFSMaxFileNameChars = 31,
- + kHFSPlusMaxFileNameChars = 255
- +}PACKED_S;
- +
- +
- +/* Extent overflow file data structures */
- +
- +/* HFS Extent key */
- +struct HFSExtentKey {
- + u_int8_t keyLength; /* length of key, excluding this field */
- + u_int8_t forkType; /* 0 = data fork, FF = resource fork */
- + u_int32_t fileID; /* file ID */
- + u_int16_t startBlock; /* first file allocation block number in this extent */
- +}PACKED_S;
- +typedef struct HFSExtentKey HFSExtentKey;
- +
- +/* HFS Plus Extent key */
- +struct HFSPlusExtentKey {
- + u_int16_t keyLength; /* length of key, excluding this field */
- + u_int8_t forkType; /* 0 = data fork, FF = resource fork */
- + u_int8_t pad; /* make the other fields align on 32-bit boundary */
- + u_int32_t fileID; /* file ID */
- + u_int32_t startBlock; /* first file allocation block number in this extent */
- +}PACKED_S;
- +typedef struct HFSPlusExtentKey HFSPlusExtentKey;
- +
- +/* Number of extent descriptors per extent record */
- +enum {
- + kHFSExtentDensity = 3,
- + kHFSPlusExtentDensity = 8
- +}PACKED_S;
- +
- +/* HFS extent descriptor */
- +struct HFSExtentDescriptor {
- + u_int16_t startBlock; /* first allocation block */
- + u_int16_t blockCount; /* number of allocation blocks */
- +}PACKED_S;
- +typedef struct HFSExtentDescriptor HFSExtentDescriptor;
- +
- +/* HFS Plus extent descriptor */
- +struct HFSPlusExtentDescriptor {
- + u_int32_t startBlock; /* first allocation block */
- + u_int32_t blockCount; /* number of allocation blocks */
- +}PACKED_S;
- +typedef struct HFSPlusExtentDescriptor HFSPlusExtentDescriptor;
- +
- +/* HFS extent record */
- +typedef HFSExtentDescriptor HFSExtentRecord[3];
- +
- +/* HFS Plus extent record */
- +typedef HFSPlusExtentDescriptor HFSPlusExtentRecord[8];
- +
- +
- +/* Finder information */
- +struct FndrFileInfo {
- + u_int32_t fdType; /* file type */
- + u_int32_t fdCreator; /* file creator */
- + u_int16_t fdFlags; /* Finder flags */
- + struct {
- + int16_t v; /* file's location */
- + int16_t h;
- + } PACKED_S fdLocation;
- + int16_t opaque;
- +}PACKED_S;
- +typedef struct FndrFileInfo FndrFileInfo;
- +
- +struct FndrDirInfo {
- + struct { /* folder's window rectangle */
- + int16_t top;
- + int16_t left;
- + int16_t bottom;
- + int16_t right;
- + }PACKED_S frRect;
- + unsigned short frFlags; /* Finder flags */
- + struct {
- + u_int16_t v; /* folder's location */
- + u_int16_t h;
- + }PACKED_S frLocation;
- + int16_t opaque;
- +}PACKED_S;
- +typedef struct FndrDirInfo FndrDirInfo;
- +
- +struct FndrOpaqueInfo {
- + int8_t opaque[16];
- +}PACKED_S;
- +typedef struct FndrOpaqueInfo FndrOpaqueInfo;
- +
- +
- +/* HFS Plus Fork data info - 80 bytes */
- +struct HFSPlusForkData {
- + u_int64_t logicalSize; /* fork's logical size in bytes */
- + u_int32_t clumpSize; /* fork's clump size in bytes */
- + u_int32_t totalBlocks; /* total blocks used by this fork */
- + HFSPlusExtentRecord extents; /* initial set of extents */
- +}PACKED_S;
- +typedef struct HFSPlusForkData HFSPlusForkData;
- +
- +
- +/* Mac OS X has 16 bytes worth of "BSD" info.
- + *
- + * Note: Mac OS 9 implementations and applications
- + * should preserve, but not change, this information.
- + */
- +struct HFSPlusBSDInfo {
- + u_int32_t ownerID; /* user or group ID of file/folder owner */
- + u_int32_t groupID; /* additional user of group ID */
- + u_int8_t adminFlags; /* super-user changeable flags */
- + u_int8_t ownerFlags; /* owner changeable flags */
- + u_int16_t fileMode; /* file type and permission bits */
- + union {
- + u_int32_t iNodeNum; /* indirect node number (hard links only) */
- + u_int32_t linkCount; /* links that refer to this indirect node */
- + u_int32_t rawDevice; /* special file device (FBLK and FCHR only) */
- + }PACKED_S special;
- +}PACKED_S;
- +typedef struct HFSPlusBSDInfo HFSPlusBSDInfo;
- +
- +
- +/* Catalog file data structures */
- +
- +enum {
- + kHFSRootParentID = 1, /* Parent ID of the root folder */
- + kHFSRootFolderID = 2, /* Folder ID of the root folder */
- + kHFSExtentsFileID = 3, /* File ID of the extents file */
- + kHFSCatalogFileID = 4, /* File ID of the catalog file */
- + kHFSBadBlockFileID = 5, /* File ID of the bad allocation block file */
- + kHFSAllocationFileID = 6, /* File ID of the allocation file (HFS Plus only) */
- + kHFSStartupFileID = 7, /* File ID of the startup file (HFS Plus only) */
- + kHFSAttributesFileID = 8, /* File ID of the attribute file (HFS Plus only) */
- + kHFSRepairCatalogFileID = 14, /* Used when rebuilding Catalog B-tree */
- + kHFSBogusExtentFileID = 15, /* Used for exchanging extents in extents file */
- + kHFSFirstUserCatalogNodeID = 16
- +}PACKED_S;
- +
- +/* HFS catalog key */
- +struct HFSCatalogKey {
- + u_int8_t keyLength; /* key length (in bytes) */
- + u_int8_t reserved; /* reserved (set to zero) */
- + u_int32_t parentID; /* parent folder ID */
- + u_int8_t nodeName[kHFSMaxFileNameChars + 1]; /* catalog node name */
- +}PACKED_S;
- +typedef struct HFSCatalogKey HFSCatalogKey;
- +
- +/* HFS Plus catalog key */
- +struct HFSPlusCatalogKey {
- + u_int16_t keyLength; /* key length (in bytes) */
- + u_int32_t parentID; /* parent folder ID */
- + HFSUniStr255 nodeName; /* catalog node name */
- +}PACKED_S;
- +typedef struct HFSPlusCatalogKey HFSPlusCatalogKey;
- +
- +/* Catalog record types */
- +enum {
- + /* HFS Catalog Records */
- + kHFSFolderRecord = 0x0100, /* Folder record */
- + kHFSFileRecord = 0x0200, /* File record */
- + kHFSFolderThreadRecord = 0x0300, /* Folder thread record */
- + kHFSFileThreadRecord = 0x0400, /* File thread record */
- +
- + /* HFS Plus Catalog Records */
- + kHFSPlusFolderRecord = 1, /* Folder record */
- + kHFSPlusFileRecord = 2, /* File record */
- + kHFSPlusFolderThreadRecord = 3, /* Folder thread record */
- + kHFSPlusFileThreadRecord = 4 /* File thread record */
- +}PACKED_S;
- +
- +
- +/* Catalog file record flags */
- +enum {
- + kHFSFileLockedBit = 0x0000, /* file is locked and cannot be written to */
- + kHFSFileLockedMask = 0x0001,
- +
- + kHFSThreadExistsBit = 0x0001, /* a file thread record exists for this file */
- + kHFSThreadExistsMask = 0x0002,
- +
- + kHFSHasAttributesBit = 0x0002, /* object has extended attributes */
- + kHFSHasAttributesMask = 0x0004,
- +
- + kHFSHasSecurityBit = 0x0003, /* object has security data (ACLs) */
- + kHFSHasSecurityMask = 0x0008
- +}PACKED_S;
- +
- +
- +/* HFS catalog folder record - 70 bytes */
- +struct HFSCatalogFolder {
- + int16_t recordType; /* == kHFSFolderRecord */
- + u_int16_t flags; /* folder flags */
- + u_int16_t valence; /* folder valence */
- + u_int32_t folderID; /* folder ID */
- + u_int32_t createDate; /* date and time of creation */
- + u_int32_t modifyDate; /*…