From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 37ED713835A for ; Sun, 14 Mar 2021 20:06:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 74377E083B; Sun, 14 Mar 2021 20:05:59 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 559FBE083B for ; Sun, 14 Mar 2021 20:05:59 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C9BEB335D3F for ; Sun, 14 Mar 2021 20:05:57 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 4A8CF5A5 for ; Sun, 14 Mar 2021 20:05:56 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1615750425.b2f55a479ffbb07dc0abc36660f6cc12bc63eda6.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/initrd.defaults defaults/initrd.scripts defaults/linuxrc X-VCS-Directories: defaults/ X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: b2f55a479ffbb07dc0abc36660f6cc12bc63eda6 X-VCS-Branch: master Date: Sun, 14 Mar 2021 20:05:56 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: bf98bfa4-ee4e-4de3-8f0c-7dc6b557d01e X-Archives-Hash: 635d254d92622584ebac8de14bd70b9f commit: b2f55a479ffbb07dc0abc36660f6cc12bc63eda6 Author: Thomas Deutschmann gentoo org> AuthorDate: Sat Mar 13 18:35:19 2021 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Sun Mar 14 19:33:45 2021 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=b2f55a47 linuxrc: Determine active console Signed-off-by: Thomas Deutschmann gentoo.org> defaults/initrd.defaults | 1 - defaults/initrd.scripts | 15 +++++++++++++++ defaults/linuxrc | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults index 7ee78e9..c9e956a 100644 --- a/defaults/initrd.defaults +++ b/defaults/initrd.defaults @@ -56,7 +56,6 @@ ROOT_LINKS='bin sbin lib lib32 lib64 boot usr opt emul' ROOT_TREES='etc root home var' REAL_ROOT='' -CONSOLE='/dev/console' NEW_ROOT='/newroot' no_umounts='/newroot|/mnt/aufs-dev|/mnt/aufs-rw-branch|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino' ROOTDELAY=5 diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index c133282..505ca02 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -2722,6 +2722,21 @@ setup_unionfs() { fi } +get_active_console() { + local active_console=console + + while [ -f /sys/class/tty/${active_console}/active ] + do + active_console=$(cat /sys/class/tty/${active_console}/active) + + # last console will be the active one, + # see https://www.kernel.org/doc/html/latest/admin-guide/serial-console.html + active_console=${active_console##* } + done + + echo ${active_console} +} + get_mounts_list() { awk ' /^[[:blank:]]*#/ { next } diff --git a/defaults/linuxrc b/defaults/linuxrc index f20d606..37a8dfa 100644 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -21,6 +21,7 @@ [ ! -e /dev/zero ] && mknod /dev/zero c 1 5 # Take control +CONSOLE="/dev/$(get_active_console)" exec 0<>${CONSOLE} 1<>${CONSOLE} 2<>${CONSOLE} if [ "$$" != '1' ]