From e10b98ba9374c145df0719bb2e9c7fe0d4b614ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Tue, 13 Mar 2012 23:43:45 +0100 Subject: arch-binfmt: move api filesytem mounting from rc.sysinit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this will avoid filesytem to be mounted at every startup if not binfmt is used Signed-off-by: Sébastien Luttringer --- arch-binfmt | 31 ++++++++++++++++++++----------- rc.sysinit | 4 +--- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/arch-binfmt b/arch-binfmt index 6931843..91468ef 100755 --- a/arch-binfmt +++ b/arch-binfmt @@ -7,20 +7,29 @@ shopt -s nullglob -declare -a binfmt_d=( - /usr/lib/binfmt.d/*.conf - /etc/binfmt.d/*.conf - /run/binfmt.d/*.conf -) -declare -A fragments +declare -a binfmt_d +# files given has argv supersede config files +if (( $# > 0 )); then + for arg; do [[ -r "$arg" ]] && binfmt_d+=("$arg"); done +else + binfmt_d=( + /usr/lib/binfmt.d/*.conf + /etc/binfmt.d/*.conf + /run/binfmt.d/*.conf + ) +fi + +# check there is file to load +(( ${#binfmt_d[@]} > 0 )) || exit 1 -# check binfmt_misc filesystem is mounted +# mount binfmt_misc if api filesystem is missing mountpoint -q /proc/sys/fs/binfmt_misc || - { echo "/proc/sys/fs/binfmt_misc is not mounted"; exit 1;} + mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc -# files declared later in the sysctl_d array will override earlier -# Example: `/etc/sysctl.d/foo.conf' supersedes `/usr/lib/sysctl.d/foo.conf'. -for path in "${@:-${binfmt_d[@]}}"; do +# files declared later in the binfmt_d array will override earlier +# Example: `/etc/binfmt.d/foo.conf' supersedes `/usr/lib/binfmt.d/foo.conf'. +declare -A fragments +for path in "${binfmt_d[@]}"; do [[ -f $path ]] && fragments[${path##*/}]=$path done diff --git a/rc.sysinit b/rc.sysinit index 9880995..ff0b6d2 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -12,10 +12,8 @@ printhl "${C_H2}http://www.archlinux.org" printsep # mount the api filesystems -# /proc, /proc/sys/fs/binfmt_misc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm +# /proc, /sys, /run, /dev, /run/lock, /dev/pts, /dev/shm mountpoint -q /proc || mount -t proc proc /proc -o nosuid,noexec,nodev -mountpoint -q /proc/sys/fs/binfmt_misc || - mount -t binfmt_misc binfmt /proc/sys/fs/binfmt_misc mountpoint -q /sys || mount -t sysfs sys /sys -o nosuid,noexec,nodev mountpoint -q /run || mount -t tmpfs run /run -o mode=0755,nosuid,nodev mountpoint -q /dev || mount -t devtmpfs dev /dev -o mode=0755,nosuid -- cgit v1.2.3