console(8): add console command and manpage

the console command runs a command or the system shell under
a new instance of kbdfs, optionally providing a serial console
when $console environment variable is set.
This commit is contained in:
cinap_lenrek 2019-12-09 17:44:28 +01:00
parent 1bfde84148
commit 57dbe35fb6
2 changed files with 44 additions and 5 deletions

16
rc/bin/console Executable file
View file

@ -0,0 +1,16 @@
#!/bin/rc
if(~ $#* 0)
*=(rc -i)
a=$console(1)
if(! ~ $#a 0){
if(! ~ $a /* '#'*)
a=/dev/eia^$a
if(test -e /dev/kbd){
@{rfork ns; aux/kbdfs; exec $* </dev/cons >/dev/cons >[2=1]} | tee $a
exit
}
}
aux/kbdfs $a
exec $* </dev/cons >/dev/cons >[2=1]

View file

@ -1,6 +1,6 @@
.TH KBDFS 8 .TH KBDFS 8
.SH NAME .SH NAME
kbdfs \- keyboard and console filesystem kbdfs, console \- keyboard and console filesystem
.SH SYNOPSIS .SH SYNOPSIS
.B aux/kbdfs .B aux/kbdfs
[ [
@ -12,7 +12,7 @@ kbdfs \- keyboard and console filesystem
.B -m .B -m
.I mntpnt .I mntpnt
] [ ] [
.I filename .I consfile
] ]
.nf .nf
@ -24,6 +24,12 @@ kbdfs \- keyboard and console filesystem
.B /dev/kbin .B /dev/kbin
.B /dev/kbmap .B /dev/kbmap
.fi .fi
.PP
.B console
[
.I cmd
.I args...
]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
Started on Started on
@ -81,6 +87,17 @@ mounts itself on
otherwise on otherwise on
.B /dev .B /dev
(the default). (the default).
.PP
The
.B console
command executes
.I cmd
(defaults to the system shell)
under its own
.I kbdfs
instance providing a serial console if
.B $console
environment variable is set.
.SS Console .SS Console
.PP .PP
Reading the Reading the
@ -151,14 +168,17 @@ to
causes the characters to be printed on the console screen. causes the characters to be printed on the console screen.
.PP .PP
When a When a
.I filename .I consfile
is passed to is passed to
.IR kbdfs (8) .IR kbdfs (8)
as its last argument, it reads and processes the as its last argument, it reads and processes the
characters from that file and forwards them to the characters from that file and forwards them to the
.BR cons .BR cons
file with the same text processing applied as on keyboard input. file with the same text processing applied as on keyboard input.
This is used on serial consoles. This is used to provide a serial console when
.B $console
environment variable is set. (see
.IR plan9.ini (8)).
.SS Keyboard .SS Keyboard
A read on the A read on the
.BR kbd .BR kbd
@ -254,11 +274,14 @@ to represent a control character.
.IR cons (3), .IR cons (3),
.IR keyboard (6), .IR keyboard (6),
.IR utf (6), .IR utf (6),
.IR kbd (3) .IR kbd (3),
.IR plan9.ini (8)
.SH FILES .SH FILES
.B /sys/lib/kbmap/* .B /sys/lib/kbmap/*
.SH SOURCE .SH SOURCE
.B /sys/src/cmd/aux/kbdfs .B /sys/src/cmd/aux/kbdfs
.br
.B /rc/bin/console
.SH HISTORY .SH HISTORY
.I Kbdfs .I Kbdfs
first appeared in 9front (May, 2011). first appeared in 9front (May, 2011).