+ count = 0;
+ count *= blksize;
+ if (count && (count < maxiocount))
+ maxiocount = count;
+
+ error = do_ioctl(p1, p2, DKIOCGETMAXBLOCKCOUNTWRITE, (caddr_t) &count);
+ if (error)
+ count = 0;
+ count *= blksize;
+ if (count && (count < maxiocount))
+ maxiocount = count;
+
+ error = do_ioctl(p1, p2, DKIOCGETMAXBYTECOUNTREAD, (caddr_t) &count);
+ if (error)
+ count = 0;
+ if (count && (count < maxiocount))
+ maxiocount = count;
+
+ error = do_ioctl(p1, p2, DKIOCGETMAXBYTECOUNTWRITE, (caddr_t) &count);
+ if (error)
+ count = 0;
+ if (count && (count < maxiocount))
+ maxiocount = count;
+
+ error = do_ioctl(p1, p2, DKIOCGETMAXSEGMENTBYTECOUNTREAD, (caddr_t) &count);
+ if (error)
+ count = 0;
+ if (count && (count < maxiocount))
+ maxiocount = count;
+
+ error = do_ioctl(p1, p2, DKIOCGETMAXSEGMENTBYTECOUNTWRITE, (caddr_t) &count);
+ if (error)
+ count = 0;
+ if (count && (count < maxiocount))
+ maxiocount = count;
+
+ kprintf("max io 0x%qx bytes\n", maxiocount);
+ if (maxiocount_result)
+ *maxiocount_result = maxiocount;
+
+ if (solid_state)
+ {
+ int isssd = 0;
+ error = do_ioctl(p1, p2, DKIOCISSOLIDSTATE, (caddr_t)&isssd);
+ if (error)
+ *solid_state = FALSE;
+ else
+ *solid_state = isssd;
+ }
+
+ // generate the block list
+
+ error = 0;
+ if (ref->vp->v_type == VREG)
+ {
+ f_offset = 0;
+ while(f_offset < (off_t) va.va_data_size)
+ {
+ size_t io_size = 1*1024*1024*1024;
+ daddr64_t blkno;
+
+ error = VNOP_BLOCKMAP(ref->vp, f_offset, io_size, &blkno, (size_t *)&io_size, NULL, 0, NULL);
+ if (error)
+ goto out;
+ callback(callback_ref, ((uint64_t) blkno) * blksize, (uint64_t) io_size);
+ f_offset += io_size;
+ }
+ callback(callback_ref, 0ULL, 0ULL);
+ }
+ else if ((ref->vp->v_type == VBLK) || (ref->vp->v_type == VCHR))
+ {
+ error = do_ioctl(p1, p2, DKIOCGETBLOCKCOUNT, (caddr_t) &size);
+ if (error)
+ goto out;
+ size *= blksize;
+ callback(callback_ref, 0ULL, size);
+ callback(callback_ref, size, 0ULL);
+ }
+
+ if (device_result)
+ *device_result = device;