diff --git a/bin/rc b/bin/rc index bed4312..d40c622 100755 --- a/bin/rc +++ b/bin/rc @@ -1,5 +1,11 @@ #!/bin/bash +# Default virtual mounts for linux systems +cfg_mounts+=( 'proc:proc:/proc:' ) +cfg_mounts+=( 'run:tmpfs:/run:' ) +cfg_mounts+=( 'sys:sysfs:/sys:' ) +cfg_mounts+=( 'dev:devtmpfs:/dev:' ) + # Functions rc.rescue() { exec "${cfg_rc_rescue_shell:-"$SHELL"}"; } @@ -13,23 +19,14 @@ rc.motd() { return 0 } -rc.mount() { - local fs - local fs_type - local mountpoint - local mount_options - - fs="$1" - fs_type="$2" - mountpoint="$3" - mount_options="${4:-defaults}" - - mount "$1" -n -t "$2" -o "$mount_options" "$3" -} - rc.mount_misc() { - mountpoint -q /proc || { rc.mount proc proc /proc; } - mountpoint -q /dev || { rc.mount dev devtmpfs /dev; } + for m in "${cfg_mounts[@]}"; do + IFS=':' read fs fs_type mountpoint mount_options <<< "$m" + + [[ "$mount_options" ]] || { mount_options='defaults' } + + mount "$fs" -n -t "$fs_type" -o "$mount_options" "$mountpoint" + done } rc.parse_cmdline() {