Re: no echo console

From: Poul-Henning Kamp <phk_at_phk.freebsd.dk>
Date: Mon, 18 Oct 2004 09:30:10 +0200
In message <19260.1097963444_at_critter.freebsd.dk>, "Poul-Henning Kamp" writes:
>In message <16753.38774.621295.6356_at_ran.psg.com>, Randy Bush writes:
>>> Does it depend on which shell you use for single-user mode ?
>>
>>uh, make the test you want clear, plz.  i am fried today.
>>
>>root's shell is /usr/local/bin/bash (no comments, please:-)
>>
>>i am seeing the problem as root in multiluser.  i don't spend
>>much time in single abuser, so can't say.
>
>Ahh, that's different then.
>
>I'll hunt this one down tomorrow.

Can you try this patch ?

Index: sys/tty.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/tty.h,v
retrieving revision 1.96
diff -u -r1.96 tty.h
--- sys/tty.h	30 Sep 2004 10:38:47 -0000	1.96
+++ sys/tty.h	18 Oct 2004 06:43:10 -0000
_at__at_ -357,6 +357,7 _at__at_
 void	 ttyfree(struct tty *tp);
 void	 ttygone(struct tty *tp);
 void	 ttyinfo(struct tty *tp);
+void	 ttyinitmode(struct tty *tp, int echo, int speed);
 int	 ttyinput(int c, struct tty *tp);
 int	 ttylclose(struct tty *tp, int flag);
 void	 ttyldoptim(struct tty *tp);
Index: kern/tty.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/tty.c,v
retrieving revision 1.238
diff -u -r1.238 tty.c
--- kern/tty.c	15 Oct 2004 09:03:07 -0000	1.238
+++ kern/tty.c	18 Oct 2004 07:24:42 -0000
_at__at_ -2845,11 +2845,7 _at__at_
 	tp->t_timeout = -1;
 	tp->t_dtr_wait = 3 * hz;
 
-	tp->t_init_in.c_iflag = TTYDEF_IFLAG;
-	tp->t_init_in.c_oflag = TTYDEF_OFLAG;
-	tp->t_init_in.c_cflag = TTYDEF_CFLAG;
-	tp->t_init_in.c_lflag = TTYDEF_LFLAG;
-	tp->t_init_in.c_ispeed = tp->t_init_in.c_ospeed = TTYDEF_SPEED;
+	ttyinitmode(tp, 0, 0);
 	bcopy(ttydefchars, tp->t_init_in.c_cc, sizeof tp->t_init_in.c_cc);
 
 	/* Make callout the same as callin */
_at__at_ -3365,23 +3361,45 _at__at_
 }
 
 /*
- * Use more "normal" termios paramters for consoles.
+ * Initialize a tty to sane modes.
  */
 void
-ttyconsolemode(struct tty *tp, int speed)
+ttyinitmode(struct tty *tp, int echo, int speed)
 {
 
+	if (speed == 0)
+		speed = TTYDEF_SPEED;
 	tp->t_init_in.c_iflag = TTYDEF_IFLAG;
 	tp->t_init_in.c_oflag = TTYDEF_OFLAG;
-	tp->t_init_in.c_cflag = TTYDEF_CFLAG | CLOCAL;
-	tp->t_init_in.c_lflag = TTYDEF_LFLAG_ECHO;
-	tp->t_lock_out.c_cflag = tp->t_lock_in.c_cflag = CLOCAL;
+	tp->t_init_in.c_cflag = TTYDEF_CFLAG;
+	if (echo)
+		tp->t_init_in.c_lflag = TTYDEF_LFLAG_ECHO;
+	else
+		tp->t_init_in.c_lflag = TTYDEF_LFLAG;
+
+	tp->t_init_in.c_ispeed = tp->t_init_in.c_ospeed = speed;
+	tp->t_init_out = tp->t_init_in;
+	termioschars(&tp->t_termios);
+	tp->t_termios = tp->t_init_in;
+}
+
+/*
+ * Use more "normal" termios paramters for consoles.
+ */
+void
+ttyconsolemode(struct tty *tp, int speed)
+{
+
 	if (speed == 0)
 		speed = TTYDEF_SPEED;
+	ttyinitmode(tp, 1, speed);
+	tp->t_init_in.c_cflag |= CLOCAL;
+	termioschars(&tp->t_termios);
+	tp->t_lock_out.c_cflag = tp->t_lock_in.c_cflag = CLOCAL;
 	tp->t_lock_out.c_ispeed = tp->t_lock_out.c_ospeed =
-	tp->t_lock_in.c_ispeed = tp->t_lock_in.c_ospeed =
-	tp->t_init_in.c_ispeed = tp->t_init_in.c_ospeed = speed;
+	tp->t_lock_in.c_ispeed = tp->t_lock_in.c_ospeed = speed;
 	tp->t_init_out = tp->t_init_in;
+	tp->t_termios = tp->t_init_in;
 }
 
 /*
Index: dev/syscons/syscons.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/syscons/syscons.c,v
retrieving revision 1.430
diff -u -r1.430 syscons.c
--- dev/syscons/syscons.c	14 Oct 2004 08:58:28 -0000	1.430
+++ dev/syscons/syscons.c	18 Oct 2004 06:52:09 -0000
_at__at_ -145,6 +145,7 _at__at_
 static	int		debugger;
 
 /* prototypes */
+static struct tty *sc_alloc_tty(struct cdev *dev);
 static int scvidprobe(int unit, int flags, int cons);
 static int sckbdprobe(int unit, int flags, int cons);
 static void scmeminit(void *arg);
_at__at_ -288,10 +289,23 _at__at_
     return names[i].name[(adp->va_flags & V_ADP_COLOR) ? 0 : 1];
 }
 
+static struct tty *
+sc_alloc_tty(struct cdev *dev)
+{
+	struct tty *tp;
+
+	tp = dev->si_tty = ttyalloc();
+	ttyinitmode(tp, 1, 0);
+	tp->t_oproc = scstart;
+	tp->t_param = scparam;
+	tp->t_stop = nottystop;
+	tp->t_dev = dev;
+	return (tp);
+}
+
 int
 sc_attach_unit(int unit, int flags)
 {
-    struct tty *tp;
     sc_softc_t *sc;
     scr_stat *scp;
 #ifdef SC_PIXEL_MODE
_at__at_ -383,14 +397,9 _at__at_
 
     for (vc = 0; vc < sc->vtys; vc++) {
 	if (sc->dev[vc] == NULL) {
-		dev = make_dev(&sc_cdevsw, vc + unit * MAXCONS,
+		sc->dev[vc] = make_dev(&sc_cdevsw, vc + unit * MAXCONS,
 		    UID_ROOT, GID_WHEEL, 0600, "ttyv%r", vc + unit * MAXCONS);
-		sc->dev[vc] = dev;
-	    	tp = sc->dev[vc]->si_tty = ttyalloc();
-	        tp->t_oproc = scstart;
-	        tp->t_param = scparam;
-	        tp->t_stop = nottystop;
-	        tp->t_dev = sc->dev[vc];
+	    	sc_alloc_tty(sc->dev[vc]);
 		if (vc == 0 && sc->dev == main_devs)
 			SC_STAT(sc->dev[0]) = &main_console;
 	}
_at__at_ -403,12 +412,8 _at__at_
 
     dev = make_dev(&sc_cdevsw, SC_CONSOLECTL,
 		   UID_ROOT, GID_WHEEL, 0600, "consolectl");
-    tp = dev->si_tty = sc_console_tty = ttyalloc();
-    ttyconsolemode(tp, 0);
-    tp->t_oproc = scstart;
-    tp->t_param = scparam;
-    tp->t_stop = nottystop;
-    tp->t_dev = dev;
+    sc_console_tty = sc_alloc_tty(dev);
+    ttyconsolemode(sc_console_tty, 0);
     SC_STAT(dev) = sc_console;
 
     return 0;
_at__at_ -2581,7 +2586,6 _at__at_
 static void
 scinit(int unit, int flags)
 {
-    struct tty *tp;
 
     /*
      * When syscons is being initialized as the kernel console, malloc()
_at__at_ -2692,11 +2696,7 _at__at_
 	    sc->dev = malloc(sizeof(struct cdev *)*sc->vtys, M_DEVBUF, M_WAITOK|M_ZERO);
 	    sc->dev[0] = make_dev(&sc_cdevsw, unit * MAXCONS,
 	        UID_ROOT, GID_WHEEL, 0600, "ttyv%r", unit * MAXCONS);
-	    tp = sc->dev[0]->si_tty = ttyalloc();
-	    tp->t_oproc = scstart;
-	    tp->t_param = scparam;
-	    tp->t_stop = nottystop;
-	    tp->t_dev = sc->dev[0];
+	    sc_alloc_tty(sc->dev[0]);
 	    scp = alloc_scp(sc, sc->first_vty);
 	    SC_STAT(sc->dev[0]) = scp;
 	}
Index: dev/syscons/sysmouse.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/syscons/sysmouse.c,v
retrieving revision 1.25
diff -u -r1.25 sysmouse.c
--- dev/syscons/sysmouse.c	14 Oct 2004 08:58:28 -0000	1.25
+++ dev/syscons/sysmouse.c	18 Oct 2004 06:58:37 -0000
_at__at_ -80,12 +80,7 _at__at_
 
 	tp = dev->si_tty;
 	if (!(tp->t_state & TS_ISOPEN)) {
-		ttychars(tp);
-		tp->t_iflag = TTYDEF_IFLAG;
-		tp->t_oflag = TTYDEF_OFLAG;
-		tp->t_cflag = TTYDEF_CFLAG;
-		tp->t_lflag = TTYDEF_LFLAG;
-		tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
+		ttyinitmode(tp, 0, 0);
 		smparam(tp, &tp->t_termios);
 		ttyld_modem(tp, 1);
 	} else if (tp->t_state & TS_XCLUDE && suser(td)) {
-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk_at_FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.
Received on Mon Oct 18 2004 - 05:30:18 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:18 UTC