public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/sci:master commit in: sys-devel/spl/, sys-fs/zfs/files/
@ 2011-04-30 22:15 Alexey Shvetsov
  0 siblings, 0 replies; only message in thread
From: Alexey Shvetsov @ 2011-04-30 22:15 UTC (permalink / raw
  To: gentoo-commits

commit:     766c554bcb19b062936d30a6404c082d50c6fa81
Author:     Alexey Shvetsov <alexxy <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 30 22:14:43 2011 +0000
Commit:     Alexey Shvetsov <alexxy <AT> gentoo <DOT> org>
CommitDate: Sat Apr 30 22:14:43 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/sci.git;a=commit;h=766c554b

updates to zfs

---
 sys-devel/spl/spl-0.6.0_rc3.ebuild |    2 +
 sys-fs/zfs/files/zfs.initd         |  134 ++++++++++++++++++++++++++++++++++++
 2 files changed, 136 insertions(+), 0 deletions(-)

diff --git a/sys-devel/spl/spl-0.6.0_rc3.ebuild b/sys-devel/spl/spl-0.6.0_rc3.ebuild
index a59d99e..e680822 100644
--- a/sys-devel/spl/spl-0.6.0_rc3.ebuild
+++ b/sys-devel/spl/spl-0.6.0_rc3.ebuild
@@ -41,4 +41,6 @@ src_configure() {
 
 src_install() {
 	emake DESTDIR="${D}" install || die 'emake install failed'
+	dosym /usr/include/spl/spl_config.h /usr/include/spl/module/spl_config.h \
+		|| die
 }

diff --git a/sys-fs/zfs/files/zfs.initd b/sys-fs/zfs/files/zfs.initd
new file mode 100644
index 0000000..d8ec4ea
--- /dev/null
+++ b/sys-fs/zfs/files/zfs.initd
@@ -0,0 +1,134 @@
+#!/sbin/runscript
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/zfs/files/zfs,v 0.9 2011/04/30 10:13:43 devsk Exp $
+
+depend() {
+	before net
+	after udev
+}
+
+CACHEFILE=/etc/zfs/zpool.cache
+ZPOOL=/sbin/zpool
+ZFS=/sbin/zfs
+ZFS_MODULE=zfs
+LOCKFILE=/var/lock/zfs/zfs_lockfile
+
+checksystem()
+{
+	/sbin/modinfo $ZFS_MODULE &>/dev/null
+	if [[ $? -ne 0 ]]
+	then
+		eerror "$ZFS_MODULE not found. Is the ZFS package installed?"
+		return 1
+	fi
+	if [[ ! -x $ZPOOL ]]
+	then
+		eerror "$ZPOOL binary not found."
+		return 1
+	fi
+	if [[ ! -x $ZFS ]]
+	then
+		eerror "$ZFS binary not found."
+		return 1
+	fi
+	return 0
+}
+
+start()
+{
+	if [[ -f $LOCKFILE ]]
+	then
+		einfo "ZFS already running, please stop it first. Delete $LOCKFILE if its not so."
+		eend 3
+		return 3
+	fi
+	ebegin "Starting ZFS"
+	checksystem || return 1
+	if ! grep -q $ZFS_MODULE /proc/modules
+	then
+		/sbin/modprobe $ZFS_MODULE &>/dev/null
+		rv=$?
+		if [[ $rv -ne 0 ]]
+		then
+			eerror "Failed to load the $ZFS_MODULE module, check 'dmesg|tail'."
+			eend $rv
+			return $rv
+		fi
+	fi
+
+	# Import all pools described by the cache file, and then mount
+	# all filesystem based on their properties.
+	if [[ -f $CACHEFILE ]]
+	then
+		einfo "Importing ZFS pools"
+
+		# as per fedora script, import can fail if all pools are already imported
+		# The check for $rv makes no sense...but someday, it will work right.
+		$ZPOOL import -c $CACHEFILE -aN 2>/dev/null || true
+		rv=$?
+		if [[ $rv -ne 0 ]]
+		then
+			eerror "Failed to import not-yet imported pools."
+			eend $rv
+			return $rv
+		fi
+	fi
+
+	einfo "Mounting ZFS filesystems"
+	$ZFS mount -a
+	rv=$?
+	if [[ $rv -ne 0 ]]
+	then
+		eerror "Failed to mount ZFS filesystems."
+		eend $rv
+		return $rv
+	fi
+
+	# hack to read mounted file systems because otherwise
+	# zfs returns EPERM when a non-root user reads a mounted filesystem before root did
+	savepwd="$PWD"
+	mount | grep " type zfs " | sed 's/.*on //' | sed 's/ type zfs.*$//' | \
+	while read line
+	do
+		cd "$line" &> /dev/null
+		ls &> /dev/null
+	done
+	cd "$savepwd"
+
+	touch $LOCKFILE
+	eend 0
+	return 0
+}
+
+stop()
+{
+	if [[ ! -f $LOCKFILE ]]
+	then
+		einfo "ZFS is not started, remove $LOCKFILE if its not so."
+		eend 3
+		return 3
+	fi
+	ebegin "Unmounting ZFS filesystems"
+	sync
+	$ZFS umount -a
+	if [[ $rv -ne 0 ]]
+	then
+		eerror "Failed to umount ZFS filesystems."
+	fi
+	rm -f $LOCKFILE
+	eend $rv
+}
+
+status()
+{
+	if [[ ! -f $LOCKFILE ]]
+	then
+		einfo "ZFS is not started, remove $LOCKFILE if its not so."
+		eend 3
+		return 3
+	fi
+
+	# show pool status and list
+	$ZPOOL status && echo && $ZPOOL list
+}



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-04-30 22:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-30 22:15 [gentoo-commits] proj/sci:master commit in: sys-devel/spl/, sys-fs/zfs/files/ Alexey Shvetsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox