From f50d400cee33bddfad1fea8094bcfee5878eeb5f Mon Sep 17 00:00:00 2001 From: Manuel Mendez Date: Tue, 25 Apr 2017 10:04:25 -0400 Subject: 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 --- initramfs-init.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3