Index | Thread | Search

From:
George Koehler <kernigh@gmail.com>
Subject:
powerpc64 boot: echo 1st key
To:
tech@openbsd.org
Date:
Wed, 20 Aug 2025 20:53:16 -0400

Download raw body.

Thread
It annoys me that powerpc64 boot doesn't echo the 1st key; I type
"bsd.rd" and see "boot> sd.rd".  This is because rdboot turns off ECHO
while waiting 5 seconds for the 1st key.  (After 5 seconds, it times
out and boots the default bsd.)

If I turn on ECHO, the 1st key echoes twice: "boot> bbsd.rd".

This diff works for me: getchar, putchar for echo, ungetc(3) before
the next fgets(3).  There is a race where the serial port can try to
type a 2nd key before rdboot turns on ECHO.  (I always typed by hand
and never pasted a string.)  Even so, I guess that echoing 1 key is
better than 0, then is this ok?
--gkoehler

Index: arch/powerpc64/stand//rdboot/cmd.c
===================================================================
RCS file: /cvs/src/sys/arch/powerpc64/stand/rdboot/cmd.c,v
diff -u -p -r1.3 cmd.c
--- arch/powerpc64/stand//rdboot/cmd.c	8 Aug 2024 13:59:11 -0000	1.3
+++ arch/powerpc64/stand//rdboot/cmd.c	21 Aug 2025 00:31:26 -0000
@@ -252,7 +252,7 @@ readline(char *buf, size_t n, int to)
 	struct timeval tv;
 	fd_set fdset;
 	char *p;
-	int timed_out = 0;
+	int c, timed_out = 0;
 #ifdef DEBUG
 	extern int debug;
 #endif
@@ -271,6 +271,10 @@ readline(char *buf, size_t n, int to)
 		tv.tv_usec = 0;
 		if (select(STDIN_FILENO + 1, &fdset, NULL, NULL, &tv) == 0)
 			timed_out = 1;
+		else if ((c = getchar()) != EOF) {
+			putchar(c);		/* Echo. */
+			ungetc(c, stdin);
+		}
 
 		/* Restore canonical mode. */
 		tcsetattr(STDIN_FILENO, TCSANOW, &saved_tio);