From patchwork Fri Oct 6 11:22:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 31765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC206E81DE5 for ; Fri, 6 Oct 2023 11:22:08 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.10315.1696591325489504926 for ; Fri, 06 Oct 2023 04:22:05 -0700 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 438A2C15; Fri, 6 Oct 2023 04:22:44 -0700 (PDT) Received: from oss-tx204.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AC2473F5A1; Fri, 6 Oct 2023 04:22:04 -0700 (PDT) From: ross.burton@arm.com To: openembedded-core@lists.openembedded.org Cc: nd@arm.com Subject: [PATCH 3/4] sysvinit-inittab: use ttyrun to run getty only if the terminal exists Date: Fri, 6 Oct 2023 12:22:00 +0100 Message-Id: <20231006112201.1081909-3-ross.burton@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231006112201.1081909-1-ross.burton@arm.com> References: <20231006112201.1081909-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 06 Oct 2023 11:22:08 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/188759 From: Ross Burton Wrap calls to start_getty with ttyrun, so that getty isn't started if the device doesn't exist. As we know start_getty is only called when the device exists we can remove the partial workaround for this problem in that scripts too. This neatly obsoletes SERIAL_CONSOLES_CHECK, whose sole purpose was to check what terminals are present at boot and rewrite inittab. Notably, this meant that SERIAL_CONSOLES_CHECK made using a read-only rootfs impossible. (From OE-Core rev: f4fd17d5a5e4eaa31995d3ca52c871cfbdc0df68) Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- .../sysvinit/sysvinit-inittab/start_getty | 11 ++++--- .../sysvinit/sysvinit-inittab_2.88dsf.bb | 30 ++----------------- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty b/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty index f60409eae3a..f5671ee53d2 100644 --- a/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty +++ b/meta/recipes-core/sysvinit/sysvinit-inittab/start_getty @@ -1,5 +1,9 @@ #!/bin/sh +SPEED=$1 +DEVICE=$2 +TERM=$3 + # busybox' getty does this itself, util-linux' agetty needs extra help getty="/sbin/getty" case $(readlink -f "${getty}") in @@ -13,9 +17,4 @@ case $(readlink -f "${getty}") in ;; esac -if [ -e /sys/class/tty/$2 -a -c /dev/$2 ]; then - ${setsid:-} ${getty} ${options:-} -L $1 $2 $3 -else - # Prevent respawning to fast error if /dev entry does not exist - sleep 1000 -fi +${setsid:-} ${getty} ${options:-} -L $SPEED $DEVICE $TERM diff --git a/meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb b/meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb index e70dc705c05..6bbe517df1b 100644 --- a/meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb +++ b/meta/recipes-core/sysvinit/sysvinit-inittab_2.88dsf.bb @@ -28,7 +28,7 @@ do_install() { device=$(echo $s | cut -d\; -f 2) label=$(echo $device | sed -e 's/tty//' | tail --bytes=5) - echo "$label:12345:respawn:${base_bindir}/start_getty $speed $device vt102" >> ${D}${sysconfdir}/inittab + echo "$label:12345:respawn:${sbindir}/ttyrun $device ${base_bindir}/start_getty $speed $device vt102" >> ${D}${sysconfdir}/inittab done if [ "${USE_VT}" = "1" ]; then @@ -52,33 +52,6 @@ EOF fi } -pkg_postinst:${PN} () { -# run this on host and on target -if [ "${SERIAL_CONSOLES_CHECK}" = "" ]; then - exit 0 -fi -} - -pkg_postinst_ontarget:${PN} () { -# run this on the target -if [ -e /proc/consoles ]; then - tmp="${SERIAL_CONSOLES_CHECK}" - for i in $tmp - do - j=`echo ${i} | sed -e s/^.*\;//g -e s/\:.*//g` - k=`echo ${i} | sed s/^.*\://g` - if [ -z "`grep ${j} /proc/consoles`" ]; then - if [ -z "${k}" ] || [ -z "`grep ${k} /proc/consoles`" ] || [ ! -e /dev/${j} ]; then - sed -i -e /^.*${j}\ /d -e /^.*${j}$/d /etc/inittab - fi - fi - done - kill -HUP 1 -else - exit 1 -fi -} - # USE_VT and SERIAL_CONSOLES are generally defined by the MACHINE .conf. # Set PACKAGE_ARCH appropriately. PACKAGE_ARCH = "${MACHINE_ARCH}" @@ -89,4 +62,5 @@ CONFFILES:${PN} = "${sysconfdir}/inittab" USE_VT ?= "1" SYSVINIT_ENABLED_GETTYS ?= "1" +RDEPENDS:${PN} = "ttyrun" RCONFLICTS:${PN} = "busybox-inittab"