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 19DCE4F8A; Thu, 04 Sep 2025 23:48:12 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id D970C4E40; Thu, 04 Sep 2025 23:47:57 +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.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_PASS,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by atuin.qyliss.net (Postfix) with ESMTPS id DCA6D4D9F for ; Thu, 04 Sep 2025 23:47:55 +0000 (UTC) Received: by mail-yb1-xb2f.google.com with SMTP id 3f1490d57ef6-e931c858dbbso1644552276.0 for ; Thu, 04 Sep 2025 16:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757029674; x=1757634474; darn=spectrum-os.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=4G0kJupp8XeKztRiO+1hPDItcFF7jZuHRY+d+0Jtki0=; b=Ku2tWD4zf02HciV4pEwgHoPvcJdjIm1z/SgCSWjq2N/UF+Gt+6nC9kAoUPKwJD/mtK pg86mbld/S1kdQscBtyoqg3u6N/hcTP0ks7/QTSujwkn1n6Mg9ZldePup+rHayHASlrQ 0jyEK3un5AfbmXCs1ugcTcaNTfXI4DAbcZiLnwXolh2u3TSbKJ/vb2KQCiZMjCwrfJIu 56CRWuKGYC4ek8zPp7SrgQwfkgeVdDz2ZnqXTsbownTu26Fjm3XF9EgwwFKmexzn5JEu FVfn4Qz4pDtm2A2cxSs0Xw3gPlCEG3Bw3N2q1ZkZmRxpWcsKqICZwsJdmyiC/o2Yfgzh lwVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757029674; x=1757634474; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4G0kJupp8XeKztRiO+1hPDItcFF7jZuHRY+d+0Jtki0=; b=evcL/e/ncdUWrADo4iAS8IbMp4jPlWdJtWqRG39pO4efZ0/chmIL+FhOC3ybmrQvxJ MZY0asXBwHGDziZpGMAfNg5uLTOcNIdsKzjvb3U6fM9uvuaemYTzdY23mxgzm0rP3odx q6cYCgldWnOmStp1PykIUvnkLqNcxPamFO7O/J9o0sNjAXk39daET9Iy6ipPso55wZQw QRUZ1jnhIEAuNHIS/UGgjXvjchpFzo2aiv4u1iZu9NqlILRYCFEk0OqU/7bXlGnbZbAU IAJt9k7JgdxFYDjYuUAFCo1epyqfNdfuFXAM5O/LnsmsGffCoYEaNBeEQudnVCFzRaCX qU2g== X-Gm-Message-State: AOJu0Yy2RMV2ObvBO2ijIj/zS3/+KMq3cG8BxOmIPN6hj0xxVeonRBv9 xxi2GG0Ib5vq13nrUTXMSZkJ2GQemUyTZkL/5fN+28C6aRPT9qfAwYVS5f7OTzBH X-Gm-Gg: ASbGnct7BqTXKKF/T9DWfXw1gZcHOwTX+nfZFx13yc+iNv9/0fkZ+bECbeyrWrU83ZD XN57YNdzra1eMvxrlLu42P3F1SiMkJARTlmDOw2xWXlPzo8v0o4VJZ1UtZZG0phg3jel766xj7U qG7CxRIcCBW3ZPi94XCHMLgjeVd4MYyfJ5KyBKv4qbbRnfipGi4GkH5W4Ss+BWpNYAfYPesQHtd v8g18K6ddgVfgReiVK0+JGWptWHX7eu/yA5VqgwH0TL+Zj/VBa0dsZViKQLAiXB69C0SDhG6xEU AjORCO1N32pvPDCu/8tMrIW/0GMHjSEM8fgqJMa6zGn/3C/yb+m18998XLLFx2lnyoyKHBv9QST NIT8EYkqAohM3sTbRQ0dBKqrTvlu+IV/DuxIJqDaJ1Euw8EpgTc5PPeBLX3P686MMv94BGY9jMv ytl2vj+Yzns5BFxnKOgMAq4cLm6M87qgzJ5a9M3ycwxte45uS1IARmfA== X-Google-Smtp-Source: AGHT+IHQ1Gdv0AD0x2w+MyONYyhFgURjtdGshm7SBLYb3FjEAP+FbwkpCNGHDxsw7Wjj07J9U9Fq/A== X-Received: by 2002:a05:6902:2511:b0:e96:fa53:eb08 with SMTP id 3f1490d57ef6-e98a58440bfmr19394728276.40.1757029674498; Thu, 04 Sep 2025 16:47:54 -0700 (PDT) Received: from localhost.localdomain (h96-60-249-169.cncrtn.broadband.dynamic.tds.net. [96.60.249.169]) by smtp.gmail.com with UTF8SMTPSA id 3f1490d57ef6-e9bbe05d717sm2688473276.22.2025.09.04.16.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Sep 2025 16:47:54 -0700 (PDT) From: Demi Marie Obenour Date: Thu, 04 Sep 2025 17:26:33 -0400 Subject: [PATCH 11/20] Add /dev/fd and /dev/std* MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250904-systemd-v1-11-2a63b790a913@gmail.com> References: <20250904-systemd-v1-0-2a63b790a913@gmail.com> In-Reply-To: <20250904-systemd-v1-0-2a63b790a913@gmail.com> To: Spectrum OS Development X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757021182; l=2623; i=demiobenour@gmail.com; s=20250729; h=from:subject:message-id; bh=WAejXaFrdOhtxio1hSi0TtEW8p4gq8UIdbwZIB8JP98=; b=tHs77kjWH5eqbQB7PpGBHjGvfHiyvVfZKejP6gv2r4WPbx638o48s3jXsGFtWB5PpGPq7bpMt MNPIN9grOfoBA4b8oYcyCBI9cy9Qp90XFM7LGtsM1rL6wkUAvy1aRV1 X-Developer-Key: i=demiobenour@gmail.com; a=ed25519; pk=X57Q4/YQDj9t4SBeKaDwvXYKB6quZJVx/DE2Ly2out0= Message-ID-Hash: 6B6O2MZYARRJK2D3CKG2DYS6WSWDH5W7 X-Message-ID-Hash: 6B6O2MZYARRJK2D3CKG2DYS6WSWDH5W7 X-MailFrom: demiobenour@gmail.com 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 CC: Demi Marie Obenour , Alyssa Ross 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: This is the same as 14483e1a690c (img/app: add /dev/fd and /dev/std*), but for the host and for vm/sys/net. While only Spectrum-provided code should run in these VMs, third-party dependencies of Spectrum might assume these links exist, and them being missing could cause severe bugs. For instance, code writing to /dev/stdout could create a file in /dev rather than actually writing to stdout. In the host, the links are added in the initramfs. Since /dev is created by the kernel and moved (via mount --move) from the initramfs to the main system, adding the links in the main system is not necessary and in fact would fail. Also reorder the moving of /sys, /proc, and /dev from the initramfs to the root filesystem to minimize the time that /dev and /proc are not mounted. /proc is considered more important than /dev. Signed-off-by: Demi Marie Obenour --- host/initramfs/etc/init | 7 ++++++- vm/sys/net/etc/s6-linux-init/scripts/rc.init | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/host/initramfs/etc/init b/host/initramfs/etc/init index 719488741b6d31564c2c17c0e41f15d16b1c0a08..b72108ab96630e2a846063551772b0b29ca27bdf 100755 --- a/host/initramfs/etc/init +++ b/host/initramfs/etc/init @@ -6,6 +6,11 @@ export PATH /bin if { mount -a } +if { ln -s /proc/self/fd /dev } +if { ln -s /proc/self/fd/0 /dev/stdin } +if { ln -s /proc/self/fd/1 /dev/stdout } +if { ln -s /proc/self/fd/2 /dev/stderr } + piperw 3 4 if { fdmove 1 4 /etc/getuuids } fdclose 4 @@ -45,9 +50,9 @@ background { rm /dev/rootfs /dev/verity } if { mount /dev/mapper/root-verity /mnt/root } wait { $mdevd_pid } -if { mount --move /proc /mnt/root/proc } if { mount --move /sys /mnt/root/sys } if { mount --move /dev /mnt/root/dev } +if { mount --move /proc /mnt/root/proc } switch_root /mnt/root /etc/init diff --git a/vm/sys/net/etc/s6-linux-init/scripts/rc.init b/vm/sys/net/etc/s6-linux-init/scripts/rc.init index 1016d0c62bc6103bc9e865a389f5d482ef6c2b76..eaf037ec123afcaeafced93096c4f35c2388f385 100755 --- a/vm/sys/net/etc/s6-linux-init/scripts/rc.init +++ b/vm/sys/net/etc/s6-linux-init/scripts/rc.init @@ -2,6 +2,11 @@ # SPDX-License-Identifier: EUPL-1.2+ # SPDX-FileCopyrightText: 2020-2022 Alyssa Ross +if { ln -s /proc/self/fd /dev } +if { ln -s /proc/self/fd/0 /dev/stdin } +if { ln -s /proc/self/fd/1 /dev/stdout } +if { ln -s /proc/self/fd/2 /dev/stderr } + if { s6-rc-init -c /etc/s6-rc /run/service } if { mkdir -p /dev/pts /dev/shm } -- 2.51.0