From: bluhm Date: Mon, 28 Jul 2014 20:30:01 +0000 (+0000) Subject: I/O ktrace of sendsyslog(2) did not work. As uiomove() adjusts X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c6cdd80053fc8a07882742dc9cc66ed020b07697;p=openbsd I/O ktrace of sendsyslog(2) did not work. As uiomove() adjusts iov_len to 0, we need a propper length calculation. While there, use -1 for the file descriptor because 0 is reserved for stdin. OK deraadt@ guenther@ --- diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index b64872a82d8..55d8fcab89b 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_log.c,v 1.21 2014/07/12 18:43:32 tedu Exp $ */ +/* $OpenBSD: subr_log.c,v 1.22 2014/07/28 20:30:01 bluhm Exp $ */ /* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */ /* @@ -349,6 +349,7 @@ sys_sendsyslog(struct proc *p, void *v, register_t *retval) struct iovec aiov; struct uio auio; struct file *f; + size_t len; int error; if (syslogf == NULL) @@ -374,12 +375,15 @@ sys_sendsyslog(struct proc *p, void *v, register_t *retval) } #endif + len = auio.uio_resid; error = sosend(f->f_data, NULL, &auio, NULL, NULL, 0); + if (error == 0) + len -= auio.uio_resid; #ifdef KTRACE if (ktriov != NULL) { if (error == 0) - ktrgenio(p, 0, UIO_WRITE, ktriov, aiov.iov_len); + ktrgenio(p, -1, UIO_WRITE, ktriov, len); free(ktriov, M_TEMP, 0); } #endif