]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/hfs/hfscommon/BTree/BTreeScanner.c
xnu-517.12.7.tar.gz
[apple/xnu.git] / bsd / hfs / hfscommon / BTree / BTreeScanner.c
index 014069807e94da6d338a15b17565f3d83770eb5d..06e15a8078a44dd22f57883c6a46f5d25a3df843 100644 (file)
@@ -22,6 +22,7 @@
  *     @(#)BTreeScanner.c
  */
 #include <sys/kernel.h>
+#include "../../hfs_endian.h"
 
 #include "../headers/BTreeScanner.h"
 
@@ -179,6 +180,23 @@ static int FindNextLeafNode(       BTScanState *scanState, Boolean avoidIO )
                        (u_int8_t *) scanState->currentNodePtr += scanState->btcb->nodeSize;
                }
                
+#if BYTE_ORDER == LITTLE_ENDIAN
+               {
+               BlockDescriptor block;
+               FileReference fref;
+
+               /* Fake a BlockDescriptor */
+               block.buffer = scanState->currentNodePtr;
+               block.blockSize = scanState->btcb->nodeSize;
+               block.blockReadFromDisk = 1;
+               block.isModified = 0;
+               
+               fref = scanState->btcb->fileRefNum;
+               
+               SWAP_BT_NODE(&block, ISHFSPLUS(VTOVCB(fref)), VTOC(fref)->c_fileid, 0);
+               }
+#endif
+
                // Make sure this is a valid node
                if ( CheckNode( scanState->btcb, scanState->currentNodePtr ) != noErr )
                {
@@ -221,7 +239,7 @@ static int ReadMultipleNodes( BTScanState *theScanStatePtr )
        // release old buffer if we have one
        if ( theScanStatePtr->bufferPtr != NULL )
        {
-               theScanStatePtr->bufferPtr->b_flags |= (B_INVAL | B_AGE);
+           theScanStatePtr->bufferPtr->b_flags |= (B_INVAL | B_AGE);
                brelse( theScanStatePtr->bufferPtr );
                theScanStatePtr->bufferPtr = NULL;
                theScanStatePtr->currentNodePtr = NULL;
@@ -249,10 +267,10 @@ static int ReadMultipleNodes( BTScanState *theScanStatePtr )
        
        // now read blocks from the device 
        myErr = bread(  myDevPtr, 
-                                       myPhyBlockNum, 
-                                       myBufferSize,  
-                                       NOCRED, 
-                                       &theScanStatePtr->bufferPtr );
+                                                       myPhyBlockNum, 
+                                                       myBufferSize,  
+                                                       NOCRED, 
+                                                       &theScanStatePtr->bufferPtr );
        if ( myErr != E_NONE )
        {
                goto ExitThisRoutine;
@@ -374,7 +392,7 @@ int  BTScanTerminate(       BTScanState *           scanState,
        if ( scanState->bufferPtr != NULL )
        {
                scanState->bufferPtr->b_flags |= (B_INVAL | B_AGE);
-               brelse( scanState->bufferPtr ); 
+               brelse( scanState->bufferPtr );
                scanState->bufferPtr = NULL;
                scanState->currentNodePtr = NULL;
        }