From c3eadd27e1eb82e52ee9b801d57131d72ed41e01 Mon Sep 17 00:00:00 2001 From: Cem Keylan Date: Mon, 1 Jun 2020 12:52:00 +0300 Subject: init: make mnt function similar to KISS --- rc.boot | 12 ++++++------ rc.lib | 14 ++++++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/rc.boot b/rc.boot index 348f4fd..9bba561 100755 --- a/rc.boot +++ b/rc.boot @@ -10,10 +10,10 @@ printf '\033[1;36m-> \033[39mWelcome to \033[35mCarbs %s\033[39m!\033[m\n' "$(uname -s)" out "Mounting pseudo filesystems..."; { - mnt /proc -o nosuid,noexec,nodev -t proc proc - mnt /sys -o nosuid,noexec,nodev -t sysfs sys - mnt /run -o mode=0755,nosuid,nodev -t tmpfs run - mnt /dev -o mode=0755,nosuid -t devtmpfs dev + mnt nosuid,noexec,nodev proc proc /proc + mnt nosuid,noexec,nodev sysfs sys /sys + mnt mode=0755,nosuid,nodev tmpfs run /run + mnt mode=0755,nosuid devtmpfs dev /dev mkdir -pm 0755 \ /run/lvm \ @@ -25,8 +25,8 @@ out "Mounting pseudo filesystems..."; { command -v runsvdir >/dev/null 2>&1 && mkdir -pm 0755 /run/runit - mnt /dev/pts -o mode=0620,gid=5,nosuid,noexec -nt devpts devpts - mnt /dev/shm -o mode=1777,nosuid,nodev -nt tmpfs shm + mnt mode=0620,gid=5,nosuid,noexec devpts devpts /dev/pts + mnt mode=1777,nosuid,nodev tmpfs shm /dev/shm } out "Parsing kernel commandline..."; { diff --git a/rc.lib b/rc.lib index 03ef793..1df98ff 100644 --- a/rc.lib +++ b/rc.lib @@ -75,13 +75,19 @@ device_helper() { esac } -mnt() { - [ -f /proc/mounts ] && while read -r _ mnt _; do +mounted() { + [ -e "$1" ] && + [ -f /proc/mounts ] && + while read -r _ mnt _; do case "$mnt" in "$1") return 0; esac done < /proc/mounts - mnt="$1"; shift - mount "$@" "$mnt" 2>&1 | log + return 1 +} + +mnt() { + mounted "$4" && set -- "remount,$1" "$2" "$3" "$4" + mount -o "$1" -t "$2" "$3" "$4" } parse_cmdline() { -- cgit v1.2.3