]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/hfs/hfscommon/Misc/VolumeAllocation.c
xnu-517.3.15.tar.gz
[apple/xnu.git] / bsd / hfs / hfscommon / Misc / VolumeAllocation.c
index 8893ad1b4726d1dd601ac210a8f58774877960e8..747eb994ee6a45d707178b8bb8371dfb53f1a2db 100644 (file)
@@ -1348,6 +1348,15 @@ static OSErr BlockFindContiguous(
        UInt32  blockRef;
        UInt32  wordsPerBlock;
 
+       if (!useMetaZone) {
+               struct hfsmount *hfsmp = VCBTOHFS(vcb);
+
+               
+               if ((hfsmp->hfs_flags & HFS_METADATA_ZONE) &&
+                   (startingBlock <= hfsmp->hfs_metazone_end))
+                       startingBlock = hfsmp->hfs_metazone_end + 1;
+       }
+
        if ((endingBlock - startingBlock) < minBlocks)
        {
                //      The set of blocks we're checking is smaller than the minimum number
@@ -1428,8 +1437,9 @@ static OSErr BlockFindContiguous(
                                 */
                                if (!useMetaZone) {
                                        currentBlock = NextBitmapBlock(vcb, currentBlock);
-                                       if (currentBlock >= stopBlock)
-                                               break;
+                                       if (currentBlock >= stopBlock) {
+                                               goto LoopExit;
+                                       }
                                }
 
                                err = ReadBitmapBlock(vcb, currentBlock, &buffer, &blockRef);
@@ -1516,7 +1526,7 @@ FoundUnused:
 
                                        nextBlock = NextBitmapBlock(vcb, currentBlock);
                                        if (nextBlock != currentBlock) {
-                                               break;  /* allocation gap, so stop */
+                                               goto LoopExit;  /* allocation gap, so stop */
                                        }
                                }
 
@@ -1585,7 +1595,7 @@ FoundUsed:
                                ++vcb->vcbFreeExtCnt;
                }
        } while (currentBlock < stopBlock);
-
+LoopExit:
 
        //      Return the outputs.
        if (foundBlocks < minBlocks)