From patchwork Thu Aug 22 18:37:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3329 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id EDB3740F40 for ; Thu, 22 Aug 2024 20:37:48 +0200 (CEST) Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4281ca9f4dbsf8784445e9.0 for ; Thu, 22 Aug 2024 11:37:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1724351868; cv=pass; d=google.com; s=arc-20160816; b=RVQN6CeTxuO4JfBvZ39XRgyv9iJBHFWYHAh87MbeBKpksV/T7X2O6sy/VMtk1OYwKc KTNCTSZC8seHRg6bITEfTDPNmOU2kFIOvpe9WmxUAdgq5+xqAjOPAMe9i61sEQL+wibf u9flnRR2TdNKliq1nfHS0mOLYtEkfu9xr9SsP3xYSPF3BZ9bkOT6Wz6YObsuuVSMTuW+ pf+F/+qiv2DA/Riinpjdj8RdWzYAp4BtCZ34RBHEafCPMoi3fr57CZ2US2JW+Anp/W61 xLebQR7gYf2C11TtyccHXp6J5I57oY9xuDfYnsf0YcGOdQ1qkHodpRATp1Z3fWeZ1S9G ZR7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=9Tzlt+BdPYcy4EVQmD79iN3E6kejaQPiWA2ibvl6JCs=; fh=uaP0oTPex2asVER3FfLdHMBFbcdhweMnNFX3EYV6f7U=; b=ZPyNnCX9wrjLfrjFrQNl4PHgUW+S8ayFFEUTgm1PGMw9hw8Ckdat2jSyKvsTNEObeQ puK6vwG1XtiZTXzY+hLKeXvARet2oFYKMhQwLrJ4pL6cRuwn5JlPZ31bbJ7fQIGMjFDO Gz/UatulqP0M2MFFg4TO0HmeKbplRner8ioaucmKBajKyN3/TzsgpXObAsvmhOCd/2nQ ooDilOhrlMUgKXkkboH2SXlZGjKnxs05eBQlx551Xrqz7THFeP+13YVT2D3d2lFV1I9y LNdbDnlRWsXvPe6MDlUjxcCHEIYICyRp3srq4JbRhw35TZO1USiIZcBDoqtGoi66cZvQ u5VQ==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XvGGyTLz; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1724351868; x=1724956668; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=9Tzlt+BdPYcy4EVQmD79iN3E6kejaQPiWA2ibvl6JCs=; b=osgXqAGDMEFavp/bRf5TgiGtf3c5yTD/mDbpdj6m2eke/Pd+lr8TLe/rn0fTnAljGy isIsklDDvmoxkwcG7aoWBWd8HDA5jivGYM3FDiu4BPUuLXDgT5gWpJiHjR3o4tiC3fw3 Ft4t3ZQC8/KsG532jgUEYyr7Tgg1f9OVQIiTM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724351868; x=1724956668; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9Tzlt+BdPYcy4EVQmD79iN3E6kejaQPiWA2ibvl6JCs=; b=NMUogYHEdKpQTRvkKBd8BFqaS3KcQHCWok4yIJVnXXoG3YpdudXjcyUCe6xPmZEY85 yTFMykTFI6MYLuTs2QjvU0lbm8C/DPbo5mfcYY2dxwff0+mJum9eY+oJZ31kODtkMlJy t93lJ/G7/Ht8jmdotLXfFVmD4SIk/i74QElHkHIiemLLUADDTj5/63lyOt8xqIOLhgMK Vz42JKgLFiA2ytksYqOWnGFQ4Ke3c33yBN0LaUj9e5w37JtNpUEsBUGc8gvbMvYKUYAX ujrUECfeHcwdHIJLq2xyO6QedeixSJgyCXnZ8cBruhIJ2gDBIlstOTYnUG44Lxiue7Nw XV8g== X-Forwarded-Encrypted: i=2; AJvYcCVEEAEGNegvbrIWxktthWHLLFTRbo1KJsE5FC3p3nYWTiJI0rdO/w6aUJark2z0ZifhhaT2mxdaKzhl+1/D@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yx8FqU0wqI4PziZAgJ1TubqxdW8I1Vb9g7AQhyxy68JiL0yss4H 6J5b/aJVeYI8XO7ScMfSJzCfhhJDKSjssh35kAD+5LLXx7829gsS+aH4UrFkRzc6xA== X-Google-Smtp-Source: AGHT+IHVv0QUfKTDXhGyuauln9JGyadBJCvuGZX4JOXpRK8/2gSRyJNf7q8OBsZzc7MVcMo/LHf7tw== X-Received: by 2002:a5d:438d:0:b0:368:460a:961d with SMTP id ffacd0b85a97d-372fd5bb9dbmr3952396f8f.3.1724351868492; Thu, 22 Aug 2024 11:37:48 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:adf:fe4e:0:b0:368:4489:3f40 with SMTP id ffacd0b85a97d-37305dd255els316491f8f.2.-pod-prod-07-eu; Thu, 22 Aug 2024 11:37:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWo0SX7CRiLBgmzhm8gNl+02mLNayWbxqDikwbtL8z9mJYAc3Iya0qlZEbrP9xhUY8aM72ZEhUwYpwoUQNx@amarulasolutions.com X-Received: by 2002:adf:fc87:0:b0:364:348:9170 with SMTP id ffacd0b85a97d-372fd92b2bcmr4185552f8f.54.1724351866719; Thu, 22 Aug 2024 11:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724351866; cv=none; d=google.com; s=arc-20160816; b=InjHXCgQSoJVQ2tYvVkuTyMHOo8DHhPA2LEIuh7MHrZ2RsC4hey/lJAbe57n5674CO TXDvjyg9GjSCEf4bT1XyG9LZvOLIKLQRZqgEDmepFmvdbpR0tuI0/IIc+CNi+KnEmL++ tCxAxBc4bzw5SnZI7m0+vw/ZzMUMNVfqGJGRZWsQ7kFQXJnFD/aSK2tGY3fPM9fAt4rV fOQ1MQhMQmMs8TQ+C1iwwP3mIbX7NcYb4X6xSyrpK61S1lZa9SKDExVKKY3Qr16JDX6Z PYp/fVqorWnrk4oxmtFyXd78QRY+4WajeDSFvRNWLls2bMCpb5gyzRr6ooAv6GCtALGj Y3Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=rKzCjo3qdZIf2pi418S63Vz2bGbb0Xdz5SnU/PMgetQ=; fh=fGUT6C+qo4rASkpziVnqryM5OSgskCdWowl9TGMdeuE=; b=PqrHaNwbsBRtd91cl6wIYcUitGV0uUYNlSmDCohCRMltWt5EKH0s6T+c4d/WJDC5wJ /bjPkOo+AhogmVn7B7tmSBifISX6qeQNE7FrfyTHexFstoQaJvUuUQi7E/XqwU7lp5Zy 8aawUxkOCBhzqSLL07YN00rTWqfxrcobxo8wjJD6n8bfmhIAzFBSaumaXDgt/fioe4Fe bFlEY99en51Rt1Jz7xSMboEa5NYurM09mcUgZMXu/RZ/g75lBAn6nsVx/eKPZMVotl8L ZFLDSJz1YFB1KvDpK7uMdDnUMBOfegtNeaGtF2ruWJX4o2yuCfDeCtsh8MkdN0CdNhpp aimA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XvGGyTLz; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id ffacd0b85a97d-3730826b0desor416049f8f.8.2024.08.22.11.37.46 for (Google Transport Security); Thu, 22 Aug 2024 11:37:46 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Forwarded-Encrypted: i=1; AJvYcCXJ8y11cgwJPplmZl37GfxteCxYsPLZYyZL0w1j4KVqki5SDXtln88Qbp9z9dT/vbY9XbNaoFjJ/TuRiSIW@amarulasolutions.com X-Received: by 2002:adf:a3d0:0:b0:371:8a74:4170 with SMTP id ffacd0b85a97d-372fd6d5744mr4225924f8f.24.1724351866197; Thu, 22 Aug 2024 11:37:46 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.. ([2.196.40.166]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3730811001fsm2276397f8f.20.2024.08.22.11.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 11:37:45 -0700 (PDT) From: Dario Binacchi To: buildroot@buildroot.org Cc: Dario Binacchi , Damien Le Moal , Thomas Petazzoni , "Yann E . MORIN" , linux-amarula@amarulasolutions.com Subject: [PATCH v3 1/3] package/tinyinit: new package Date: Thu, 22 Aug 2024 20:37:40 +0200 Message-ID: <20240822183742.3550055-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240822183742.3550055-1-dario.binacchi@amarulasolutions.com> References: <20240822183742.3550055-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=XvGGyTLz; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This package contains a Linux init script suitable for resource-limited systems which can be used as an alternative to the one provided by Busybox. Signed-off-by: Dario Binacchi --- Changes v2 -> v3: - Add the init script - Drop the entry in the init selection in system/Config.in. Changes v1 -> v2: - Rename tinit to tinyinit. - Put the script inside the tinyinit package without the need to use a github repo. - Update the commit message. DEVELOPERS | 1 + package/Config.in | 1 + package/tinyinit/Config.in | 10 ++++++++++ package/tinyinit/init | 32 ++++++++++++++++++++++++++++++++ package/tinyinit/tinyinit.mk | 12 ++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 package/tinyinit/Config.in create mode 100644 package/tinyinit/init create mode 100644 package/tinyinit/tinyinit.mk diff --git a/DEVELOPERS b/DEVELOPERS index d7d0af35431b..45cc1cc48996 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -791,6 +791,7 @@ F: configs/imx8mn_bsh_smm_s2_defconfig F: configs/imx8mn_bsh_smm_s2_pro_defconfig F: configs/stm32f769_disco_sd_defconfig F: package/sscep/ +F: package/tinyinit/ F: package/uuu/ N: Dario Binacchi diff --git a/package/Config.in b/package/Config.in index 317f859684fe..ddf378b13e01 100644 --- a/package/Config.in +++ b/package/Config.in @@ -2869,6 +2869,7 @@ menu "System tools" source "package/tar/Config.in" source "package/tealdeer/Config.in" source "package/thermald/Config.in" + source "package/tinyinit/Config.in" source "package/tpm-tools/Config.in" source "package/tpm2-abrmd/Config.in" source "package/tpm2-tools/Config.in" diff --git a/package/tinyinit/Config.in b/package/tinyinit/Config.in new file mode 100644 index 000000000000..2ceb8e191e23 --- /dev/null +++ b/package/tinyinit/Config.in @@ -0,0 +1,10 @@ +config BR2_PACKAGE_TINYINIT + bool "tinyinit" + depends on BR2_INIT_NONE + help + A Linux tiny initialization script suitable for resource + limited systems, which can be used as an alternative to the + one provided by Busybox. + +comment "tinyinit needs BR2_INIT_NONE, i. e. no init system installed" + depends on !BR2_INIT_NONE diff --git a/package/tinyinit/init b/package/tinyinit/init new file mode 100644 index 000000000000..fbcb481010c2 --- /dev/null +++ b/package/tinyinit/init @@ -0,0 +1,32 @@ +#!/bin/sh + +# This script replaces the default busybox init process to avoid having that +# process staying alive and sleeping in the background, (uselessly) consuming +# precious memory. + +# Mount procfs and sysfs +/bin/mount -t proc proc /proc +/bin/mount -t sysfs sysfs /sys + +# When the kernel is directly booted, devtmpfs is not automatically mounted. +# Manually mount it if needed. +devmnt=$(mount | grep -c devtmpfs) +if [ "${devmnt}" -eq 0 ]; then + /bin/mount -t devtmpfs devtmpfs /dev +fi + +# Use the /dev/console device node from devtmpfs if possible to not +# confuse glibc's ttyname_r(). +# This may fail (E.G. booted with console=), and errors from exec will +# terminate the shell, so use a subshell for the test +if (exec 0/dev/null; then + exec 0/dev/console + exec 2>/dev/console +fi + +# Clear memory to reduce page fragmentation +echo 3 > /proc/sys/vm/drop_caches + +# Finally, let's start an interactive shell +exec /bin/sh diff --git a/package/tinyinit/tinyinit.mk b/package/tinyinit/tinyinit.mk new file mode 100644 index 000000000000..c7bb144dee68 --- /dev/null +++ b/package/tinyinit/tinyinit.mk @@ -0,0 +1,12 @@ +################################################################################ +# +# tinyinit +# +################################################################################ + +define TINYINIT_INSTALL_TARGET_CMDS + $(INSTALL) -m 0755 -D $(TINYINIT_PKGDIR)/init $(TARGET_DIR)/sbin/init + (cd $(TARGET_DIR); ln -sf /sbin/init init) +endef + +$(eval $(generic-package))