diff options
author | 2016-05-18 23:28:43 +0000 | |
---|---|---|
committer | 2016-05-18 23:28:43 +0000 | |
commit | c156aeae077f3bdbadf63be87829a539c93bdce7 (patch) | |
tree | c9d796c2622b2a582d06a29ddbf6a48251a21a75 | |
parent | Introduce a per-platform init_mainbus() hook that can be used to attach (diff) | |
download | wireguard-openbsd-c156aeae077f3bdbadf63be87829a539c93bdce7.tar.xz wireguard-openbsd-c156aeae077f3bdbadf63be87829a539c93bdce7.zip |
Use constty and cn_devvp for checking wether to use cnwrite(). That
makes console redirection with senssyslog(2) and LOG_CONS work
again. Also merge the two if else if else blocks into one.
OK deraadt@
-rw-r--r-- | sys/kern/subr_log.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index e3f66708dec..0ae2e3baed9 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_log.c,v 1.41 2016/05/17 23:43:47 bluhm Exp $ */ +/* $OpenBSD: subr_log.c,v 1.42 2016/05/18 23:28:43 bluhm Exp $ */ /* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */ /* @@ -465,11 +465,25 @@ dosendsyslog(struct proc *p, const char *buf, size_t nbyte, int flags, #endif len = auio.uio_resid; - if (syslogf) + if (syslogf) { error = sosend(syslogf->f_data, NULL, &auio, NULL, NULL, 0); - else if (cn_devvp) + if (error == 0) + len -= auio.uio_resid; + } else if (constty || cn_devvp) { error = cnwrite(0, &auio, 0); - else { + if (error == 0) + len -= auio.uio_resid; + aiov.iov_base = "\r\n"; + aiov.iov_len = 2; + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + auio.uio_segflg = UIO_SYSSPACE; + auio.uio_rw = UIO_WRITE; + auio.uio_procp = p; + auio.uio_offset = 0; + auio.uio_resid = aiov.iov_len; + cnwrite(0, &auio, 0); + } else { /* XXX console redirection breaks down... */ if (sflg == UIO_USERSPACE) { kbuf = malloc(len, M_TEMP, M_WAITOK); @@ -487,26 +501,10 @@ dosendsyslog(struct proc *p, const char *buf, size_t nbyte, int flags, } if (sflg == UIO_USERSPACE) free(kbuf, M_TEMP, len); - } - - if (error == 0) - len -= auio.uio_resid; - - if (syslogf) - ; - else if (cn_devvp) { - aiov.iov_base = "\r\n"; - aiov.iov_len = 2; - auio.uio_iov = &aiov; - auio.uio_iovcnt = 1; - auio.uio_segflg = UIO_SYSSPACE; - auio.uio_rw = UIO_WRITE; - auio.uio_procp = p; - auio.uio_offset = 0; - auio.uio_resid = aiov.iov_len; - cnwrite(0, &auio, 0); - } else + if (error == 0) + len -= auio.uio_resid; cnputc('\n'); + } #ifdef KTRACE if (ktriov != NULL) { |