Module Name:    src
Committed By:   haad
Date:           Mon Oct  5 22:39:27 UTC 2009

Modified Files:
        src/etc/rc.d: mountall

Log Message:
Add support for mounting zfs filesystems to mountall script. ZFS configuration
is stored in /etc/zpool.cache and it is automatically loaded to kernel from
filesystem. Filesystems are then configured accordingly to their properties
loaded from cache file.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/etc/rc.d/mountall

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/etc/rc.d/mountall
diff -u src/etc/rc.d/mountall:1.6 src/etc/rc.d/mountall:1.7
--- src/etc/rc.d/mountall:1.6	Mon Dec  1 14:47:14 2008
+++ src/etc/rc.d/mountall	Mon Oct  5 22:39:27 2009
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: mountall,v 1.6 2008/12/01 14:47:14 tsutsui Exp $
+# $NetBSD: mountall,v 1.7 2009/10/05 22:39:27 haad Exp $
 #
 
 # REQUIRE: mountcritremote named ypbind
@@ -9,8 +9,40 @@
 $_rc_subr_loaded . /etc/rc.subr
 
 name="mountall"
-start_cmd="echo 'Mounting all filesystems...'; mount -a"
-stop_cmd="echo 'Unmounting all filesystems...'; umount -a"
+start_cmd="mountall_start"
+stop_cmd="mountall_stop"
+
+mountall_start()
+{
+	echo 'Mounting all filesystems...'
+	if [ -f /etc/zfs/zpool.cache ]; then
+		# Get ZFS module loaded (and thereby, zvols created).
+		zfs list > /dev/null 2>&1
+		# Mount file systems noted in fstab.
+		mount -a
+		# Mount ZFS file systems.
+		zfs mount -a
+	else
+		# Mount file systems noted in fstab.
+		mount -a
+	fi
+}
+
+mountall_stop()
+{
+	echo 'Unmounting all filesystems...'
+	if [ -f /etc/zfs/zpool.cache ]; then
+		# Unmount ZFS file systems.
+		zfs unmount -a
+		# Unmount file systems noted in fstab.
+		umount -a
+		# Unload ZFS module, so disk devices are closed.
+		modunload zfs
+	else
+		# Otherwise, just deal with fstab.
+		umount -a
+	fi
+}
 
 load_rc_config $name
 run_rc_command "$1"

Reply via email to