OSErr BlockDeallocate ( SVCB *vcb, // Which volume to deallocate space on UInt32 firstBlock, // First block in range to deallocate UInt32 numBlocks) // Number of contiguous blocks to deallocate { OSErr err; // // If no blocks to deallocate, then exit early // if (numBlocks == 0) { err = noErr; goto Exit; } // // Call internal routine to free the sequence of blocks // err = BlockMarkFree(vcb, firstBlock, numBlocks); if (err) goto Exit; // // Update the volume's free block count, and mark the VCB as dirty. // vcb->vcbFreeBlocks += numBlocks; MarkVCBDirty(vcb); Exit: return err; }
__private_extern__ OSErr BlockDeallocate ( ExtendedVCB *vcb, // Which volume to deallocate space on u_int32_t firstBlock, // First block in range to deallocate u_int32_t numBlocks) // Number of contiguous blocks to deallocate { OSErr err; // // If no blocks to deallocate, then exit early // if (numBlocks == 0) { err = noErr; goto Exit; } // // Call internal routine to free the sequence of blocks // err = BlockMarkFree(vcb, firstBlock, numBlocks); if (err) goto Exit; // // Update the volume's free block count, and mark the VCB as dirty. // HFS_MOUNT_LOCK(vcb, TRUE); vcb->freeBlocks += numBlocks; if (vcb->nextAllocation == (firstBlock + numBlocks)) HFS_UPDATE_NEXT_ALLOCATION(vcb, (vcb->nextAllocation - numBlocks)); MarkVCBDirty(vcb); HFS_MOUNT_UNLOCK(vcb, TRUE); hfs_generate_volume_notifications(VCBTOHFS(vcb)); Exit: return err; }