ref: f50d400cee33bddfad1fea8094bcfee5878eeb5f
parent: 3284ace53c5389c2aeadc9280dd32545cf0b3b0f
author: Manuel Mendez <mmendez534@gmail.com>
date: Tue Apr 25 05:04:25 CDT 2017
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
--- a/initramfs-init.in
+++ b/initramfs-init.in
@@ -113,9 +113,11 @@
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