From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id D26B41370C; Wed, 17 Sep 2025 11:29:39 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 7705E13677; Wed, 17 Sep 2025 11:29:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_MISSING,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) by atuin.qyliss.net (Postfix) with ESMTPS id AF14913675 for ; Wed, 17 Sep 2025 11:29:36 +0000 (UTC) Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id E8347140013D; Wed, 17 Sep 2025 07:29:35 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Wed, 17 Sep 2025 07:29:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1758108575; x=1758194975; bh=q7+EH3LlVN jpwWQYIiRmy9+WlDeN0qRNFiyNI/Evokc=; b=AGW71Z27hthNGxaAm0o5kbbmwm iEUZXh+AeNYvHLNYPiD0b4fKTIlZExxa/VoRQICXy+iy2Vuryn3QJ2wceqqR1P7g 2+n2lBV9SnQRi95xL2+6129jhExpxGzmi6omO87IEG7jexchpIof1qesDOHDco1d UEQ239dT4OfMw7LI6CYbvWoKpP6SYeXNYvSkiyap+mYsVUIIbfMQb+anBrU26Nah cKtT356MdqtLLt63MYtHQXYq27vCfejTxAkpss9aLlLrhfSGsx6QRHuXnzv+UxtW vmxqWo0gxFggmwaoHeICkook4ZKScB6kYS0aHPJdEj6YsRfTHLOlc+iZpbMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1758108575; x=1758194975; bh=q7+EH3LlVNjpwWQYIiRmy9+WlDeN0qRNFiy NI/Evokc=; b=OQpFkbmDyFRe4jKbMRSlewNTPaTe4dLac4J1K14gaSjvR/tgm21 EcNZvfT7s8E9ugxtHLuMNZ+n4NIy73ypjlY6Ow3/z99rfDcx8kpiLlPuHosXBxiI 8fVdSioQq9HGr69gO8TzvzNqxqjSZJu0qUR2J8WjGChzzJ8rqR7PmqBPt4hyH72D LGzdFGcusfjEyQYHZ/+lM/eGEspyHcXh/VU8LnNBLc6Nxp/nkoIkkmZkxt3h/EA4 kg9fMRX/ny2gIMdB3fig99FSNSdQRu9y6ZovxOVWUYm1CwjyQR23JP3bZjGQF3nx oYPQiq7ET0PUIvvVpjCBAKOTaXSKj3eFVQw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegfeeffecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvffujghffffkgggtsehgtderredttddtnecuhfhrohhmpeetlhihshhsrgcutfho shhsuceohhhisegrlhihshhsrgdrihhsqeenucggtffrrghtthgvrhhnpeduffeiueeltd ehveehfeeiteevveffhfdvudethfeivdfgheeitdeffeelvefgudenucffohhmrghinhep shhpvggtthhruhhmqdhoshdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehhihesrghlhihsshgrrdhishdpnhgspghrtghpthhtohep vddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepuggvmhhiohgsvghnohhurhesgh hmrghilhdrtghomhdprhgtphhtthhopeguvghvvghlsehsphgvtghtrhhumhdqohhsrdho rhhg X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Sep 2025 07:29:35 -0400 (EDT) Received: by mbp.qyliss.net (Postfix, from userid 1000) id 8F8461F50E52; Wed, 17 Sep 2025 13:29:24 +0200 (CEST) From: Alyssa Ross To: Demi Marie Obenour , Spectrum OS Development Subject: Re: [PATCH 2/3] Add /dev/fd and /dev/std* In-Reply-To: <20250914-util-linux-switch-root-v1-2-9cf9349cbca3@gmail.com> References: <20250914-util-linux-switch-root-v1-0-9cf9349cbca3@gmail.com> <20250914-util-linux-switch-root-v1-2-9cf9349cbca3@gmail.com> Date: Wed, 17 Sep 2025 13:29:23 +0200 Message-ID: <87y0qdxqp8.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: BOOC4BGVOIUTGQGDBUUY43HGRR77DY2V X-Message-ID-Hash: BOOC4BGVOIUTGQGDBUUY43HGRR77DY2V X-MailFrom: hi@alyssa.is X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Demi Marie Obenour writes: > This is nearly same as 14483e1a690c (img/app: add /dev/fd and /dev/std*), > but for the host and for vm/sys/net. The only difference is that the > symlinks are created in init, rather than in rc.init. This ensures that > nothing in the main system can run before they the links are created. s6-linux-init is certainly designed to be run before these links exist, so I don't think we need them in init. I'd rather keep setup in a single place as much as possibl,e and that's rc.init. > While only Spectrum-provided code should run in these VMs, third-party > dependencies are likely to only be tested in an environment where these > links are present. Since the BSDs also have these links, some code > might even use them on purpose. > > Not having these links could cause severe bugs. For instance, if > /dev/stdout or /dev/stderr is missing, writing to them will create a > regular file instead. This could cause other code to misbehave. > Furthermore, /dev is a devtmpfs, so this could consume a lot of memory. > > In the host, the links are added in the main system, rather than in the > initramfs. This is per Alyssa's suggestion in [1]. > > [1]: https://spectrum-os.org/lists/archives/spectrum-devel/87h5xdjo9p.fsf= @alyssa.is/ > > Signed-off-by: Demi Marie Obenour > --- > host/rootfs/etc/init | 8 ++++++++ > vm/sys/net/etc/init | 8 ++++++++ > 2 files changed, 16 insertions(+) > > diff --git a/host/rootfs/etc/init b/host/rootfs/etc/init > index 4085fa55545e7309004967e443e47fc2b82b0663..b6e6122ddb987a5463c0924cd= 56e1a26cf5bfd98 100755 > --- a/host/rootfs/etc/init > +++ b/host/rootfs/etc/init > @@ -1,5 +1,13 @@ > #!/bin/execlineb -s0 > # SPDX-License-Identifier: EUPL-1.2+ > # SPDX-FileCopyrightText: 2022 Alyssa Ross > +# Symlink creation (if it's copyrightable): > +# SPDX-License-Identifier: CC0-1.0 > +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour > + > +/usr/bin/if { /usr/bin/ln -s /proc/self/fd /dev } > +/usr/bin/if { /usr/bin/ln -s /proc/self/fd/0 /dev/stdin } > +/usr/bin/if { /usr/bin/ln -s /proc/self/fd/1 /dev/stdout } > +/usr/bin/if { /usr/bin/ln -s /proc/self/fd/2 /dev/stderr } >=20=20 > /bin/s6-linux-init -c /etc/s6-linux-init -s /run/param -- $@ > diff --git a/vm/sys/net/etc/init b/vm/sys/net/etc/init > index 6424e221e0fb929e107271bd52b61706b9f1855e..de409e9296a24d42cef506054= 96efc520790559e 100755 > --- a/vm/sys/net/etc/init > +++ b/vm/sys/net/etc/init > @@ -1,5 +1,13 @@ > #!/bin/execlineb -s0 > # SPDX-License-Identifier: EUPL-1.2+ > # SPDX-FileCopyrightText: 2022 Alyssa Ross > +# Symlink creation (if it's copyrightable): > +# SPDX-License-Identifier: CC0-1.0 > +# SPDX-FileCopyrightText: 2025 Demi Marie Obenour > + > +/usr/bin/if { /usr/bin/ln -s /proc/self/fd /dev } > +/usr/bin/if { /usr/bin/ln -s /proc/self/fd/0 /dev/stdin } > +/usr/bin/if { /usr/bin/ln -s /proc/self/fd/1 /dev/stdout } > +/usr/bin/if { /usr/bin/ln -s /proc/self/fd/2 /dev/stderr } >=20=20 > /bin/s6-linux-init -Bc /etc/s6-linux-init -- $@ > > --=20 > 2.51.0 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQRV/neXydHjZma5XLJbRZGEIw/wogUCaMqbkwAKCRBbRZGEIw/w ouEcAP9+rUB//hEab86dXLDRlfzAscTe3EWfX0mkTu0PTrNmDwEA5lMUe4bDRAVm 7Kiiqr+A2WvZGfyA9GfHSQ18isiFaQo= =knD3 -----END PGP SIGNATURE----- --=-=-=--