X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/21362eb3e66fd2c787aee132bce100a44d71a99c..4452a7af2eac33dbad800bcc91f2399d62c18f53:/bsd/hfs/hfs_vfsutils.c diff --git a/bsd/hfs/hfs_vfsutils.c b/bsd/hfs/hfs_vfsutils.c index 6024b382d..a77c6b179 100644 --- a/bsd/hfs/hfs_vfsutils.c +++ b/bsd/hfs/hfs_vfsutils.c @@ -747,7 +747,14 @@ overflow_extents(struct filefork *fp) { u_long blocks; - if (VTOVCB(FTOV(fp))->vcbSigWord == kHFSPlusSigWord) { + // + // If the vnode pointer is NULL then we're being called + // from hfs_remove_orphans() with a faked-up filefork + // and therefore it has to be an HFS+ volume. Otherwise + // we check through the volume header to see what type + // of volume we're on. + // + if (FTOV(fp) == NULL || VTOVCB(FTOV(fp))->vcbSigWord == kHFSPlusSigWord) { if (fp->ff_extents[7].blockCount == 0) return (0); @@ -1311,7 +1318,7 @@ hfs_remove_orphans(struct hfsmount * hfsmp) cnode.c_rsrcfork = NULL; fsize = (u_int64_t)dfork.ff_blocks * (u_int64_t)HFSTOVCB(hfsmp)->blockSize; while (fsize > 0) { - if (fsize > HFS_BIGFILE_SIZE) { + if (fsize > HFS_BIGFILE_SIZE && overflow_extents(&dfork)) { fsize -= HFS_BIGFILE_SIZE; } else { fsize = 0;