lfs-execline-scripts

Repository for execline scripts used in my linux-from-scratch builds
Log | Files | Refs

commit 4c75bb198a1e37c6bdad34684c9817b830b6d134
parent 26f46f246d479b6e69558f686ea2e845d147fc20
Author: mrgrouse <bdmfegys@duck.com>
Date:   Sun, 27 Jul 2025 21:33:54 -0400

sinit: move mounting of psuedo-filesystems to separate script without forx loop. move broken forx loop to separate file for later evaluation

Diffstat:
Msinit/rc.init | 35+----------------------------------
Asinit/rc.mounts | 35+++++++++++++++++++++++++++++++++++
Asinit/rc.mounts.broken | 34++++++++++++++++++++++++++++++++++
3 files changed, 70 insertions(+), 34 deletions(-)

diff --git a/sinit/rc.init b/sinit/rc.init @@ -5,40 +5,7 @@ define PATH "/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin" background { printf "Starting Suckless' init!\n\nMounting from /etc/fstab...\n" } foreground { mount -a } -# --- beginning of mounter --- # -# the following is inspired by getopt in c, meant to make adding different mountpoints to this easier -forx x { /proc /sys /sys/firmware/efi/efivars /dev /dev/pts /dev/shm /run /tmp } -{ # begin loop -foreground { # foreground wrapper - case -N -- $x - { # open case - /proc { export mntargs "proc proc ${x} -o nosuid,noexec,nodev" } - /sys { export mntargs "sysfs sysfs ${x} -o nosuid,noexec,nodev" } - /sys/firmware/efi/efivars { export mntargs "efivarfs -o ro efivarfs ${x}" } - /dev { export mntargs "devtmpfs devtmpfs ${x} -o mode=0755,nosuid" } - /dev/pts { export mntargs "devpts devpts ${x} -o mode=0620,gid=5,nosuid,noexec" } - /dev/shm { export mntargs "tmpfs tmpfs ${x} -o mode=1777,nosuid,nodev" } - /run { export mntargs "tmpfs tmpfs ${x} -o mode=0755,nosuid,nodev" } - /tmp { export mntargs "tmpfs tmpfs ${x}" } - } # close case - - # default case if one of the things above does not match. TODO: dropping into shell may not work depending on the shell, maybe we should just trigger reboot - { - foreground - { printf "Broken forx mounter loop at %s. Fix %s.\nDropping into shell." ${x} ${0} } - exec /bin/sh - } - -} # close foreground wrapper (around case statement) - -# if said dir is a mountpoint -importas -S mntargs -if { ! mountpoint -q ${x} } - { mount -t ${mntargs} } - -} # close forx - -# --- end of mounter --- # +foreground { /bin/rc.mounts } background { printf "Mounting swap devices...\n" } foreground { swapon -a } diff --git a/sinit/rc.mounts b/sinit/rc.mounts @@ -0,0 +1,35 @@ +#!/bin/execlineb -S0 +# basic skeleton +#background { printf "Mounting filesystem...\n" } +#foreground { if {mountpoint -q } mount -t -o } + +background { printf "Mounting proc filesystem...\n" } +foreground { if { mountpoint -q /proc } mount -t proc proc /proc -o nosuid,noexec,nodev } + +background { printf "Mounting sysfs filesystem...\n" } +foreground { if { mountpoint -q /sys } mount -t sysfs sysfs /sys -o nosuid,noexec,nodev } + +foreground { + if { eltest -d /sys/firmware/efi } + background { printf "Mounting efivarfs filesystem...\n" } + foreground { + if { mountpoint -q /sys/firmware/efivars } + mount -t efivarfs -o ro efivarfs /sys/firmware/efi/efivars + } +} + +background { printf "Mounting /dev filesystem...\n" } +foreground { if { mountpoint -q /dev } mount -t devtmpfs devtmpfs /dev -o mode=0755,nosuid } + +background { printf "Mounting /dev/pts filesystem...\n" } +foreground { if {eltest -d /dev } mkdir /dev/pts } +foreground { if { mountpoint -q /dev/pts } mount -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec } + +background { printf "Mounting /dev/shm filesystem...\n" } +foreground { if { mountpoint -q /dev/shm } mount -t tmpfs tmpfs /dev/pts -o mode=1777,nosuid,nodev } + +background { printf "Mounting /run filesystem...\n" } +foreground { if { mountpoint -q /run } mount -t tmpfs tmpfs /run -o mode=0755,nosuid,nodev } + +background { printf "Mounting /run filesystem...\n" } +foreground { if {mountpoint -q /tmp } mount -t tmpfs tmpfs /tmp } diff --git a/sinit/rc.mounts.broken b/sinit/rc.mounts.broken @@ -0,0 +1,34 @@ +## --- beginning of mounter --- # +## the following is inspired by getopt in c, meant to make adding different mountpoints to this easier +#forx x { /proc /sys /sys/firmware/efi/efivars /dev /dev/pts /dev/shm /run /tmp } +#{ # begin loop +#foreground { # foreground wrapper +# case -N -- $x +# { # open case +# /proc { export mntargs "proc proc ${x} -o nosuid,noexec,nodev" } +# /sys { export mntargs "sysfs sysfs ${x} -o nosuid,noexec,nodev" } +# /sys/firmware/efi/efivars { export mntargs "efivarfs -o ro efivarfs ${x}" } +# /dev { export mntargs "devtmpfs devtmpfs ${x} -o mode=0755,nosuid" } +# /dev/pts { export mntargs "devpts devpts ${x} -o mode=0620,gid=5,nosuid,noexec" } +# /dev/shm { export mntargs "tmpfs tmpfs ${x} -o mode=1777,nosuid,nodev" } +# /run { export mntargs "tmpfs tmpfs ${x} -o mode=0755,nosuid,nodev" } +# /tmp { export mntargs "tmpfs tmpfs ${x}" } +# } # close case +# +# # default case if one of the things above does not match. TODO: dropping into shell may not work depending on the shell, maybe we should just trigger reboot +# { +# foreground +# { printf "Broken forx mounter loop at %s. Fix %s.\nDropping into shell." ${x} ${0} } +# exec /bin/sh +# } +# +#} # close foreground wrapper (around case statement) +# +## if said dir is a mountpoint +#importas -S mntargs +#if { ! mountpoint -q ${x} } +# { mount -t ${mntargs} } +# +#} # close forx +# +## --- end of mounter --- #