Demi Marie Obenour writes: > 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 This is really two independent patches in one as well. > --- > 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 } > + Would prefer to do this in host/rootfs, in the interest of not creating more implicit requirements on initramfs in that system. initramfs is deterministic enough that it's vanishingly unlikely we'll find that it requires these only sometimes. > 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 } I don't understand this. There are no other processes running, so how could the order possibly matter? There's nothing to race against. > > 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