Skip to content
  • Manuel Mendez's avatar
    init: properly parse kernel serial console options · f50d400c
    Manuel Mendez authored and Natanael Copa's avatar Natanael Copa committed
    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
    f50d400c