code: drawterm

Download patch

ref: 082f1a3a980c79b96009f413b72f65b791cc2352
parent: 673e3de9a2f59dbac9a845b2f28363b2bb9f0041
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Mar 8 11:21:13 EST 2016

add -B option to disable /dev/kbd

--- a/cpu.c
+++ b/cpu.c
@@ -27,6 +27,7 @@
 
 #define system csystem
 static char	*system;
+static int	nokbd;
 static int	cflag;
 extern int	dbg;
 
@@ -155,8 +156,10 @@
 	static char script[] = 
 "mount -nc /fd/0 /mnt/term || exit\n"
 "bind -q /mnt/term/dev/cons /dev/cons\n"
-"</dev/cons >/dev/cons >[2=1] aux/kbdfs -dq -m /mnt/term/dev\n"
-"bind -q /mnt/term/dev/cons /dev/cons\n"
+"if(test -r /mnt/term/dev/kbd){\n"
+"	</dev/cons >/dev/cons >[2=1] aux/kbdfs -dq -m /mnt/term/dev\n"
+"	bind -q /mnt/term/dev/cons /dev/cons\n"
+"}\n"
 "</dev/cons >/dev/cons >[2=1] service=cpu exec rc -li\n";
 	char *na;
 	int fd;
@@ -166,8 +169,8 @@
 		return;
 
 	/* provide /dev/kbd for kbdfs */
-	if(bind("#b", "/dev", MAFTER) < 0)
-		panic("bind #b: %r");
+	if(!nokbd)
+		bind("#b", "/dev", MAFTER);
 
 	fd = p9authtls(fd);
 	if(aanfilter){
@@ -206,9 +209,6 @@
 	authserver = getenv("auth");
 	system = getenv("cpu");
 	ARGBEGIN{
-	case 'p':
-		aanfilter = 1;
-		break;
 	case 'a':
 		authserver = EARGF(usage());
 		break;
@@ -246,6 +246,12 @@
 		break;
 	case 'u':
 		user = EARGF(usage());
+		break;
+	case 'B':
+		nokbd = 1;
+		break;
+	case 'p':
+		aanfilter = 1;
 		break;
 	default:
 		usage();