+ dk->dk_openpart = dk->dk_copenpart | dk->dk_bopenpart;
+ dk->dk_wlabel = wlab;
+ }
+ break;
+
+ case DIOCWFORMAT:
+ {
+ register struct format_op *fop;
+ struct uio auio;
+ struct iovec aiov;
+
+ if ((flag & FWRITE) == 0) {
+ error = EBADF;
+ break;
+ }
+ fop = (struct format_op *)data;
+ aiov.iov_base = fop->df_buf;
+ aiov.iov_len = fop->df_count;
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_resid = fop->df_count;
+ auio.uio_segflg = UIO_USERSPACE;
+ auio.uio_offset = fop->df_startblk * lp->d_secsize;
+ dk->dk_operrsta = fop->dk_operrsta;
+ dk->dk_ecode = fop->dk_ecode;
+ /*
+ * Don't return errors, as the format op won't get copied
+ * out if we return nonzero. Callers must check the returned
+ * count.
+ */
+ (void) physio(vdformat, (struct buf *)NULL, dev,
+ (cmd == DIOCWFORMAT ? B_WRITE : B_READ), minphys, &auio);
+ fop->df_count -= auio.uio_resid;
+ fop->dk_operrsta = dk->dk_operrsta;
+ fop->dk_ecode = dk->dk_ecode;