[PC-BSD Commits] r21494 - pcbsd/branches/9.1/src-sh/libsh

svn at pcbsd.org svn at pcbsd.org
Thu Feb 14 10:56:14 PST 2013


Author: kris
Date: 2013-02-14 18:56:13 +0000 (Thu, 14 Feb 2013)
New Revision: 21494

Modified:
   pcbsd/branches/9.1/src-sh/libsh/functions.sh
Log:

MFC some fixes to libsh for 9.1



Modified: pcbsd/branches/9.1/src-sh/libsh/functions.sh
===================================================================
--- pcbsd/branches/9.1/src-sh/libsh/functions.sh	2013-02-14 18:54:43 UTC (rev 21493)
+++ pcbsd/branches/9.1/src-sh/libsh/functions.sh	2013-02-14 18:56:13 UTC (rev 21494)
@@ -163,14 +163,37 @@
   return 1
 }
 
+# Gets the mount-point of a particular zpool / dataset
+# Arg1 = zpool to check
+getZFSMount() {
+  local zpool="$1"
+  local mnt=`mount | grep "^${zpool} on" | grep "(zfs," | awk '{print $3}'`
+  if [ -n "$mnt" ] ; then
+     echo "$mnt"
+     return 0
+  fi
+  return 1
+}
+
+# Get the ZFS dataset of a particular directory
+getZFSDataset() {
+  local mount="$1"
+  local zData=`mount | grep " on $mount " | grep "(zfs," | awk '{print $1}'`
+  if [ -n "$zData" ] ; then
+     echo "$zData"
+     return 0
+  fi
+  return 1
+}
+
 # Get the ZFS tank name for a directory
 # Arg1 = Directory to check
 getZFSTank() {
   local _chkDir="$1"
   while :
   do
-     line=`mount | grep -w -e $_chkDir -e "(zfs,"`
-     mount | grep -qw -e $_chkDir -e "(zfs,"
+     line=`mount | grep -we "$_chkDir" | grep -e "(zfs,"`
+     mount | grep -we "$_chkDir" | grep -q -e "(zfs,"
      if [ $? -eq 0 ] ; then
         echo $line | cut -d '/' -f -1 | awk '{print $1}'
         return 0



More information about the Commits mailing list