-/* $OpenBSD: kern_ktrace.c,v 1.16 2000/04/19 10:13:22 art Exp $ */
+/* $OpenBSD: kern_ktrace.c,v 1.17 2000/04/19 10:56:41 art Exp $ */
/* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */
/*
int ktrops __P((struct proc *, struct proc *, int, int, struct vnode *));
int ktrsetchildren __P((struct proc *, struct proc *, int, int,
struct vnode *));
-void ktrwrite __P((struct vnode *, struct ktr_header *));
+int ktrwrite __P((struct vnode *, struct ktr_header *));
int ktrcanset __P((struct proc *, struct proc *));
void
ktp->ktr_rw = rw;
kth.ktr_buf = (caddr_t)ktp;
- kth.ktr_len = buflen;
cp = (caddr_t)((char *)ktp + sizeof (struct ktr_genio));
-
buflen -= sizeof(struct ktr_genio);
+
while (resid > 0) {
/*
* Don't allow this process to hog the cpu when doing
*/
if (p->p_schedflags & PSCHED_SHOULDYIELD)
preempt(NULL);
+
cnt = min(iov->iov_len, buflen);
+ if (cnt > resid)
+ cnt = resid;
if (copyin(iov->iov_base, cp, cnt))
- goto done;
- ktrwrite(vp, &kth);
- if ((iov->iov_len -= cnt) <= 0)
+ break;
+
+ kth.ktr_len = cnt + sizeof(struct ktr_genio);
+
+ if (ktrwrite(vp, &kth) != 0)
+ break;
+
+ iov->iov_len -= cnt;
+ iov->iov_base += cnt;
+
+ if (iov->iov_len == 0)
iov++;
+
+ resid -= cnt;
}
-done:
+
FREE(ktp, M_TEMP);
p->p_traceflag &= ~KTRFAC_ACTIVE;
/*NOTREACHED*/
}
-void
+int
ktrwrite(vp, kth)
struct vnode *vp;
struct ktr_header *kth;
int error;
if (vp == NULL)
- return;
+ return 0;
auio.uio_iov = &aiov[0];
auio.uio_offset = 0;
auio.uio_segflg = UIO_SYSSPACE;
error = VOP_WRITE(vp, &auio, IO_UNIT|IO_APPEND, p->p_ucred);
VOP_UNLOCK(vp, 0, p);
if (!error)
- return;
+ return 0;
/*
* If error encountered, give up tracing on this vnode.
*/
vrele(vp);
}
}
+
+ return error;
}
/*