Demi Marie Obenour <demiobenour@gmail.com> writes:
On 7/13/26 05:39, Alyssa Ross wrote:
Demi Marie Obenour <demiobenour@gmail.com> writes:
cgroup-setup is written in Rust and uses the Rust standard library.
FWIW it might be good to say "cgroup-setup, a tool which will be introduced in a later patch" or something. Otherwise I have to guess what this is referring to.
It also relies on cgroupfs being mounted at /sys/fs/cgroup. Furthermore, it runs very, *very* early on, since it sets up the cgroups in which s6-svscan and s6-supervise processes run. This allows setting up sub-cgroups without having to worry about name collisions.
While it would be possible to only mount the bare minimum necessary, it's simpler to just mount everything before starting any services. These mounts are all pseudo-filesystems or tmpfs instances, and none have any dependencies.
Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com> --- host/rootfs/image/etc/init | 11 ++++++++++- host/rootfs/image/etc/s6-linux-init/scripts/rc.init | 9 +-------- 2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/host/rootfs/image/etc/init b/host/rootfs/image/etc/init index db8a6d9c747e3d212c21b6c983c8f7e299822abe..8ec7859ab00e24007a93d4000c8f34e353de50ae 100755 --- a/host/rootfs/image/etc/init +++ b/host/rootfs/image/etc/init @@ -1,6 +1,15 @@ #!/bin/execlineb -Ws0 # SPDX-License-Identifier: EUPL-1.2+ -# SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is> +# SPDX-FileCopyrightText: 2020-2022, 2024 Alyssa Ross <hi@alyssa.is>
/bin/setpriv --no-new-privs -- + +if { /bin/ln -s /proc/self/fd /dev } +if { /bin/ln -s /proc/self/fd/0 /dev/stdin } +if { /bin/ln -s /proc/self/fd/1 /dev/stdout } +if { /bin/ln -s /proc/self/fd/2 /dev/stderr }
I guess the idea is that the Rust standard library might want these?
I don't know if it actually does, though I would not be surprised if it is not tested without them. What *is* necessary is for a cgroup filesystem to be mounted at /sys/fs/cgroup. This allows setting up cgroup controllers and moving PID 1 to a sub-cgroup.
Yeah, that's what I thought. It doesn't do any harm to create them early anyway, so this is fine.
+ +if { /bin/mount --make-shared / } +if { /bin/mount -a --mkdir } + /bin/s6-linux-init -c /etc/s6-linux-init -s /run/param -- $@ diff --git a/host/rootfs/image/etc/s6-linux-init/scripts/rc.init b/host/rootfs/image/etc/s6-linux-init/scripts/rc.init index f638e373589884acb959c868462fdf532380a851..fba305c4e9cbb9f7535f11bb4c06d8da8a34837b 100755 --- a/host/rootfs/image/etc/s6-linux-init/scripts/rc.init +++ b/host/rootfs/image/etc/s6-linux-init/scripts/rc.init @@ -4,13 +4,6 @@
if { s6-rc-init -c /etc/s6-rc /run/service }
-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 { mount --make-shared / } -if { mount --make-shared /run } -if { mount -a --mkdir } +if { /bin/mount --make-shared /run }
Presumably this does not actually suddenly need an absolute path.
You are correct.
Alright then, with that fixed: Reviewed-by: Alyssa Ross <hi@alyssa.is>