summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Bächler <thomas@archlinux.org>2010-02-16 00:30:48 +0100
committerThomas Bächler <thomas@archlinux.org>2010-02-16 00:30:48 +0100
commit8a81daeb4fdc9f559ef972ac5a2cda9f313000f1 (patch)
tree144cf7663228304793e0ea9ac1b5be1d9a23292b
parentc83d5eb8c694ac266b3055c38254e751e8917e8e (diff)
downloadmkinitcpio-8a81daeb4fdc9f559ef972ac5a2cda9f313000f1.tar.gz
mkinitcpio-8a81daeb4fdc9f559ef972ac5a2cda9f313000f1.tar.xz
Introduce mount handlers
Instead of having special NFS code in /init, make it possible for a hook to register a mount handler When a hook sets the mount_handler environment variable, the normal mount code will be skipped and the handler will be called with the path to mount point as the first and only argument.
-rw-r--r--hooks/net14
-rw-r--r--init14
2 files changed, 19 insertions, 9 deletions
diff --git a/hooks/net b/hooks/net
index ff33955..d2085c7 100644
--- a/hooks/net
+++ b/hooks/net
@@ -80,6 +80,20 @@ run_hook ()
rootfstype="nfs"
echo "NFS-Mount: ${nfs_server}:${nfs_path}"
+
+ # set mount handler for NFS
+ mount_handler="nfs_mount_handler"
fi
fi
}
+
+nfs_mount_handler() {
+ if [ -z "$nfs_server" -o -z "$nfs_path" ]; then
+ err "Unable to mount root filesystem over NFS: wrong parameters."
+ echo "You are being dropped to a recovery shell"
+ echo " Type 'exit' to try and continue booting"
+ launch_interactive_shell
+ msg "Trying to continue (this will most likely fail) ..."
+ fi
+ nfsmount ${nfs_option:+-o ${nfs_option}} "${nfs_server}:${nfs_path}" "$1"
+}
diff --git a/init b/init
index f3c4e84..6a206e9 100644
--- a/init
+++ b/init
@@ -15,6 +15,9 @@ export root=""
export init=""
echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
+# set default mount handler
+mount_handler="default"
+
# if available, start udevd at this stage
if [ -x /sbin/udevd ]; then
msg ":: Starting udevd..."
@@ -103,7 +106,7 @@ if [ -f "/message" ]; then
fi
mkdir -p /new_root
-if [ -z "${nfsroot}" -a "${root}" != "/dev/nfs" ]; then
+if [ -z "${mount_handler}" -o "${mount_handler}" = "default" ]; then
if [ ${root:0:5} != "/dev/" ] || ! poll_device "${root}" ${rootdelay}; then
msg "\nRoot device '${root}' doesn't exist. Attempting to create it."
rootdev=""
@@ -170,14 +173,7 @@ if [ -z "${nfsroot}" -a "${root}" != "/dev/nfs" ]; then
fi
mount ${fstype:+-t ${fstype}} -o ${rwopt}${rootflags:+,${rootflags}} "${root}" /new_root
else
- if [ -z "$nfs_server" -o -z "$nfs_path" ]; then
- err "Unable to mount root filesystem over NFS: wrong parameters."
- echo "You are being dropped to a recovery shell"
- echo " Type 'exit' to try and continue booting"
- launch_interactive_shell
- msg "Trying to continue (this will most likely fail) ..."
- fi
- nfsmount ${nfs_option:+-o ${nfs_option}} "${nfs_server}:${nfs_path}" /new_root
+ ${mount_handler} /new_root
fi
[ -z "${init}" ] && init="/sbin/init"