Partially fix `sysctl machdep.console_device'. The fix will be complete

when syscons stops mapping the console to minor MAXCONS.  There is
usually no corresponding device in /dev, and the correct device has
minor 0.

cons.c:
Initialize cn_tty properly, so that CPU_CONSDEV can work.
Comment about too many variants of the console tty pointer.

machdep.c:
Return device NODEV and not error EFAULT when there is no console device.
This commit is contained in:
Bruce Evans 1995-06-26 07:39:52 +00:00
parent 77370fd9ed
commit 4ebf8117df
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=9326
4 changed files with 28 additions and 10 deletions

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.127 1995/05/25 07:41:20 davidg Exp $
* $Id: machdep.c,v 1.128 1995/05/30 07:59:33 rgrimes Exp $
*/
#include "npx.h"
@ -998,6 +998,7 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
size_t newlen;
struct proc *p;
{
dev_t consdev;
int error;
/* all sysctl names at this level are terminal */
@ -1006,8 +1007,9 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
switch (name[0]) {
case CPU_CONSDEV:
return (sysctl_rdstruct(oldp, oldlenp, newp, &cn_tty->t_dev,
sizeof cn_tty->t_dev));
consdev = (cn_tty == NULL ? NODEV : cn_tty->t_dev);
return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
sizeof consdev));
case CPU_ADJKERNTZ:
error = sysctl_int(oldp, oldlenp, newp, newlen, &adjkerntz);
if (!error && newp)

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
* $Id: cons.c,v 1.28 1995/05/30 07:59:18 rgrimes Exp $
* $Id: cons.c,v 1.29 1995/06/14 04:52:39 bde Exp $
*/
#include <sys/param.h>
@ -106,10 +106,17 @@ cninit()
cn_phys_open = cdp->d_open;
cdp->d_open = cnopen;
cn_tp = (*cdp->d_devtotty)(cn_tab->cn_dev);
/*
* XXX there are too many tty pointers. cn_tty is only used for
* sysctl(CPU_CONSDEV) (not for tprintf like the above comment
* says). cn_tp in struct consdev hasn't been initialized
* (except statically to NULL) or used (except to initialize
* cn_tty to the wrong value) for a year or two.
*/
cn_tty = cn_tp;
/*
* Turn on console
*/
cn_tty = cp->cn_tp;
(*cp->cn_init)(cp);
}

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.127 1995/05/25 07:41:20 davidg Exp $
* $Id: machdep.c,v 1.128 1995/05/30 07:59:33 rgrimes Exp $
*/
#include "npx.h"
@ -998,6 +998,7 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
size_t newlen;
struct proc *p;
{
dev_t consdev;
int error;
/* all sysctl names at this level are terminal */
@ -1006,8 +1007,9 @@ cpu_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
switch (name[0]) {
case CPU_CONSDEV:
return (sysctl_rdstruct(oldp, oldlenp, newp, &cn_tty->t_dev,
sizeof cn_tty->t_dev));
consdev = (cn_tty == NULL ? NODEV : cn_tty->t_dev);
return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev,
sizeof consdev));
case CPU_ADJKERNTZ:
error = sysctl_int(oldp, oldlenp, newp, newlen, &adjkerntz);
if (!error && newp)

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
* $Id: cons.c,v 1.28 1995/05/30 07:59:18 rgrimes Exp $
* $Id: cons.c,v 1.29 1995/06/14 04:52:39 bde Exp $
*/
#include <sys/param.h>
@ -106,10 +106,17 @@ cninit()
cn_phys_open = cdp->d_open;
cdp->d_open = cnopen;
cn_tp = (*cdp->d_devtotty)(cn_tab->cn_dev);
/*
* XXX there are too many tty pointers. cn_tty is only used for
* sysctl(CPU_CONSDEV) (not for tprintf like the above comment
* says). cn_tp in struct consdev hasn't been initialized
* (except statically to NULL) or used (except to initialize
* cn_tty to the wrong value) for a year or two.
*/
cn_tty = cn_tp;
/*
* Turn on console
*/
cn_tty = cp->cn_tp;
(*cp->cn_init)(cp);
}