[arch-projects] [INITSCRIPTS][PATCH 1/2] arch-binfmt: move api filesytem mounting from rc.sysinit
this will avoid filesytem to be mounted at every startup if not binfmt is used Signed-off-by: Sébastien Luttringer <seblu@seblu.net> --- 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 -- Sebastien "Seblu" Luttringer
Signed-off-by: Sébastien Luttringer <seblu@seblu.net> --- Makefile | 3 ++- binfmt.d.5.txt | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 binfmt.d.5.txt diff --git a/Makefile b/Makefile index 46ce5b0..b232e9f 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,8 @@ MAN_PAGES := \ rc.conf.5 \ locale.conf.5 \ vconsole.conf.5 \ - hostname.5 + hostname.5 \ + binfmt.d.5 all: doc diff --git a/binfmt.d.5.txt b/binfmt.d.5.txt new file mode 100644 index 0000000..2925256 --- /dev/null +++ b/binfmt.d.5.txt @@ -0,0 +1,57 @@ +///// +vim:set ts=4 sw=4 syntax=asciidoc noet: +///// +binfmt.d(5) +=========== + +NAME +---- +binfmt.d - Configure additional binary formats at boot + +SYNOPSIS +-------- +/usr/lib/binfmt.d/*.conf + +/etc/binfmt.d/*.conf + +/run/binfmt.d/*.conf + +DESCRIPTION +----------- +*initscripts* uses files from the above directories to configure additional +binary formats to register during boot in the kernel. + +CONFIGURATION FORMAT +-------------------- +Each file contains a list of binfmt_misc kernel binary format rules. +Consult *binfmt_misc.txt*[1] for more information on registration of +additional binary formats and how to write rules. + +Empty lines and lines beginning with ; and # are ignored. Note that this +means you may not use ; and # as delimiter in binary format rules. + +Each configuration file is named in the style of <program>.conf. Files in +/etc/ overwrite files with the same name in /usr/lib/. Files in /run +overwrite files with the same name in /etc/ and /usr/lib/. Packages +should install their configuration files in /usr/lib/, files in /etc/ are +reserved for the local administration, which possibly decides to +overwrite the configurations installed from packages. All files are +sorted by filename in alphabetical order, regardless in which of the +directories they reside, to ensure that a specific configuration file +takes precedence over another file with an alphabetically later name. + +EXAMPLE +------- +*Example 1. /etc/binfmt.d/wine.conf example:* + + # Start WINE on Windows executables + :DOSWin:M::MZ::/usr/bin/wine: + +NOTES +----- +*1. binfmt_misc.txt:* + http://www.kernel.org/doc/Documentation/binfmt_misc.txt + +AUTHORS +------- +Original by Lennart Poettering, adapted to Arch Linux by Sébastien Luttringer. -- Sebastien "Seblu" Luttringer
participants (1)
-
Sébastien Luttringer