diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2016-05-17 23:28:04 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2016-05-17 23:28:04 +0000 |
commit | 7ea1fc8d50313ece3562a9695b3ad570dc67db7c (patch) | |
tree | 1adb2bda87381811ce01e1375b9933adc5fddd68 | |
parent | 1b526da513b789d2e2d90f49deba8d80568f4b2c (diff) |
Backout the previous fix for the sendsyslog(2) with LOG_CONS solution.
Permanently holding /dev/console open in the kernel works only until
init(8) calls revoke(2). After that the console device vnode cannot
be used anymore. It still resulted in a hanging init(8) if it tried
to syslog(3) something. With the backout also dmesg -s works again.
-rw-r--r-- | sys/kern/init_main.c | 26 | ||||
-rw-r--r-- | sys/kern/subr_log.c | 4 | ||||
-rw-r--r-- | sys/sys/systm.h | 4 |
3 files changed, 11 insertions, 23 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 87f76c07bd6..9a2afd89a8c 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.252 2016/05/10 23:54:00 bluhm Exp $ */ +/* $OpenBSD: init_main.c,v 1.253 2016/05/17 23:28:03 bluhm Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -120,7 +120,7 @@ struct proc *reaperproc; extern struct user *proc0paddr; -struct vnode *rootvp, *swapdev_vp, *consolevp; +struct vnode *rootvp, *swapdev_vp; int boothowto; struct timespec boottime; int ncpus = 1; @@ -133,7 +133,7 @@ long __guard_local __attribute__((section(".openbsd.randomdata"))); /* XXX return int so gcc -Werror won't complain */ int main(void *); -void open_console(struct proc *); +void check_console(struct proc *); void start_init(void *); void start_cleaner(void *); void start_update(void *); @@ -570,30 +570,20 @@ static char *initpaths[] = { }; void -open_console(struct proc *p) +check_console(struct proc *p) { struct nameidata nd; - struct vnode *vp; int error; NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/console", p); - error = vn_open(&nd, FWRITE, 0); + error = namei(&nd); if (error) { if (error == ENOENT) printf("warning: /dev/console does not exist\n"); else printf("warning: /dev/console error %d\n", error); - return; - } - vp = nd.ni_vp; - VOP_UNLOCK(vp, p); - if (!ISSET(vp->v_flag, VISTTY)) { - printf("warning: /dev/console is not a tty device\n"); - vn_close(vp, FWRITE, p->p_ucred, p); - return; - } - - consolevp = vp; + } else + vrele(nd.ni_vp); } /* @@ -626,7 +616,7 @@ start_init(void *arg) while (start_init_exec == 0) (void) tsleep((void *)&start_init_exec, PWAIT, "initexec", 0); - open_console(p); + check_console(p); /* process 0 ignores SIGCHLD, but we can't */ p->p_p->ps_sigacts->ps_flags = 0; diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 1d11ef02232..15ef3812152 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_log.c,v 1.39 2016/05/10 23:54:00 bluhm Exp $ */ +/* $OpenBSD: subr_log.c,v 1.40 2016/05/17 23:28:03 bluhm Exp $ */ /* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */ /* @@ -415,7 +415,7 @@ dosendsyslog(struct proc *p, const char *buf, size_t nbyte, int flags, if (syslogf) FREF(syslogf); - else if (!ISSET(flags, LOG_CONS) || consolevp == NULL) + else if (!ISSET(flags, LOG_CONS)) return (ENOTCONN); else { /* diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 83e16052820..1c65c0387f0 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systm.h,v 1.112 2016/05/10 23:54:01 bluhm Exp $ */ +/* $OpenBSD: systm.h,v 1.113 2016/05/17 23:28:03 bluhm Exp $ */ /* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */ /*- @@ -99,8 +99,6 @@ extern struct vnode *rootvp; /* vnode equivalent to above */ extern dev_t swapdev; /* swapping device */ extern struct vnode *swapdev_vp;/* vnode equivalent to above */ -extern struct vnode *consolevp; /* vnode of console tty device */ - struct proc; struct process; #define curproc curcpu()->ci_curproc |