-/*
- * Check if there are any overflow extents that overlap.
- */
-static int
-hfs_overlapped_overflow_extents(struct hfsmount *hfsmp, u_int32_t startblk, u_int32_t catblks, u_int32_t fileID, int rsrcfork)
-{
- struct BTreeIterator * iterator = NULL;
- struct FSBufferDescriptor btdata;
- HFSPlusExtentRecord extrec;
- HFSPlusExtentKey *extkeyptr;
- FCB *fcb;
- u_int32_t block;
- u_int8_t forktype;
- int overlapped = 0;
- int i;
- int error;
-
- forktype = rsrcfork ? 0xFF : 0;
- if (kmem_alloc(kernel_map, (vm_offset_t *)&iterator, sizeof(*iterator))) {
- return (0);
- }
- bzero(iterator, sizeof(*iterator));
- extkeyptr = (HFSPlusExtentKey *)&iterator->key;
- extkeyptr->keyLength = kHFSPlusExtentKeyMaximumLength;
- extkeyptr->forkType = forktype;
- extkeyptr->fileID = fileID;
- extkeyptr->startBlock = catblks;
-
- btdata.bufferAddress = &extrec;
- btdata.itemSize = sizeof(extrec);
- btdata.itemCount = 1;
-
- fcb = VTOF(hfsmp->hfs_extents_vp);
-
- error = BTSearchRecord(fcb, iterator, &btdata, NULL, iterator);
- while (error == 0) {
- /* Stop when we encounter a different file. */
- if ((extkeyptr->fileID != fileID) ||
- (extkeyptr->forkType != forktype)) {
- break;
- }
- /*
- * Check if the file overlaps target space.
- */
- for (i = 0; i < kHFSPlusExtentDensity; ++i) {
- if (extrec[i].blockCount == 0) {
- break;
- }
- block = extrec[i].startBlock + extrec[i].blockCount;
- if (block >= startblk) {
- overlapped = 1;
- break;
- }
- }
- /* Look for more records. */
- error = BTIterateRecord(fcb, kBTreeNextRecord, iterator, &btdata, NULL);
- }
-
- kmem_free(kernel_map, (vm_offset_t)iterator, sizeof(*iterator));
- return (overlapped);
-}
-
-
-/*
- * Calculate the progress of a file system resize operation.
- */
-__private_extern__
-int
-hfs_resize_progress(struct hfsmount *hfsmp, u_int32_t *progress)
-{
- if ((hfsmp->hfs_flags & HFS_RESIZE_IN_PROGRESS) == 0) {
- return (ENXIO);
- }
-
- if (hfsmp->hfs_resize_totalfiles > 0)
- *progress = (hfsmp->hfs_resize_filesmoved * 100) / hfsmp->hfs_resize_totalfiles;
- else
- *progress = 0;
-
- return (0);
-}
-
-