diff options
author | Manuel Mendez <mmendez534@gmail.com> | 2017-04-25 10:04:25 -0400 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2017-06-14 14:51:16 +0200 |
commit | f50d400cee33bddfad1fea8094bcfee5878eeb5f (patch) | |
tree | 43346cf9052fcd4c79aed63c05a4d68d4b19d007 | |
parent | 3284ace53c5389c2aeadc9280dd32545cf0b3b0f (diff) | |
download | mkinitfs-f50d400cee33bddfad1fea8094bcfee5878eeb5f.tar.bz2 mkinitfs-f50d400cee33bddfad1fea8094bcfee5878eeb5f.tar.xz |
init: properly parse kernel serial console options
According to https://www.kernel.org/doc/Documentation/admin-guide/serial-console.rst
the serial port options is specified as:
"... BBBBPNF, where BBBB is the speed, P is parity (n/o/e), N is number of bits,
and F is flow control ('r' for RTS)." Parity and Number of bits are ignored
since getty does not have any options for them.
I tested the paramater substitution using the following script/snippet:
```sh
/ # cat /etc/alpine-release; cat kernel2getty.sh; sh kernel2getty.sh
3.5.2
consoles="ttyS0 ttyS0,115200 ttyS0,115200n8 ttyS0,115200n8r ttyS0,115200r"
for console in $consoles; do
line=-L
term=vt100
tty=${console%,*}
speed=${console#*,}
flow=${speed##*[^r]}
speed=${speed%%[^0-9]*}
echo "console=$console"
echo " speed=$speed"
echo " flow=$flow"
echo " getty=getty ${flow:+-h }$line ${speed:-15200} $tty $term"
echo "----------"
done
console=ttyS0
speed=
flow=
getty=getty -L 15200 ttyS0 vt100
----------
console=ttyS0,115200
speed=115200
flow=
getty=getty -L 115200 ttyS0 vt100
----------
console=ttyS0,115200n8
speed=115200
flow=
getty=getty -L 115200 ttyS0 vt100
----------
console=ttyS0,115200n8r
speed=115200
flow=r
getty=getty -h -L 115200 ttyS0 vt100
----------
console=ttyS0,115200r
speed=115200
flow=r
getty=getty -h -L 115200 ttyS0 vt100
----------
```
closes #7037
-rwxr-xr-x | initramfs-init.in | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/initramfs-init.in b/initramfs-init.in index 8a1c867..1293ef4 100755 --- a/initramfs-init.in +++ b/initramfs-init.in @@ -113,9 +113,11 @@ setup_inittab_console(){ local term= case "$tty" in ttyS*|ttyMFD*|ttyUSB*|ttyAMA*) - [ "$speed" = "$1" ] && speed=115200 term=vt100 line=-L + flow=${speed##*[^r]} + speed=${speed%%[^0-9]*} + speed=${speed:-115200} ;; *) [ "$speed" = "$1" ] && speed=38400 |