Skip to content

Commit 047b82a

Browse files
committed
core: 用于引导参数时不需要判断 tty 是否存在和可写
1 parent 0db534c commit 047b82a

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

ttys.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,24 @@ prefix=$1
77
# 注意 debian initrd 没有 xargs
88

99
# 最后一个 tty 是主 tty,显示的信息最全
10-
is_first=true
1110
if [ "$(uname -m)" = "aarch64" ]; then
1211
ttys="ttyS0 ttyAMA0 tty0"
1312
else
1413
ttys="ttyS0 tty0"
1514
fi
1615

16+
# 安装环境下 tty 不一定齐全
17+
# hytron 有ttyS0 但无法写入
18+
# 用于 cmdline 引导参数时不需要判断 tty 是否存在和可写
19+
if [ "$prefix" = "console=" ]; then
20+
is_for_cmdline=true
21+
else
22+
is_for_cmdline=false
23+
fi
24+
25+
is_first=true
1726
for tty in $ttys; do
18-
# hytron 有ttyS0 但无法写入
19-
if stty -g -F "/dev/$tty" >/dev/null 2>&1; then
27+
if $is_for_cmdline || stty -g -F "/dev/$tty" >/dev/null 2>&1; then
2028
if $is_first; then
2129
is_first=false
2230
else
@@ -25,7 +33,7 @@ for tty in $ttys; do
2533

2634
printf "%s" "$prefix$tty"
2735

28-
if [ "$prefix" = "console=" ] &&
36+
if $is_for_cmdline &&
2937
{ [ "$tty" = ttyS0 ] || [ "$tty" = ttyAMA0 ]; }; then
3038
printf ",115200n8"
3139
fi

0 commit comments

Comments
 (0)