mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
ZTS: Refactor is_shared, fix impl on FreeBSD
FreeBSD doesn't have a `share` command. It does have showmount. Split the separate platform impls out of is_shared_impl. Dispatch to the correct platform impl function from is_shared. Eliminate the use of is_shared_impl from tests. is_shared works. Reviewed-by: John Kennedy <john.kennedy@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #10037
This commit is contained in:
@@ -127,6 +127,7 @@ export SYSTEM_FILES_FREEBSD='chflags
|
||||
rmextattr
|
||||
setextattr
|
||||
sha256
|
||||
showmount
|
||||
swapctl
|
||||
sysctl
|
||||
uncompress'
|
||||
|
||||
@@ -1324,20 +1324,18 @@ function datasetnonexists
|
||||
return 0
|
||||
}
|
||||
|
||||
function is_shared_impl
|
||||
function is_shared_freebsd
|
||||
{
|
||||
typeset fs=$1
|
||||
|
||||
showmount -E | grep -qx $fs
|
||||
}
|
||||
|
||||
function is_shared_illumos
|
||||
{
|
||||
typeset fs=$1
|
||||
typeset mtpt
|
||||
|
||||
if is_linux; then
|
||||
for mtpt in `share | awk '{print $1}'` ; do
|
||||
if [[ $mtpt == $fs ]] ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
fi
|
||||
|
||||
for mtpt in `share | awk '{print $2}'` ; do
|
||||
if [[ $mtpt == $fs ]] ; then
|
||||
return 0
|
||||
@@ -1352,6 +1350,19 @@ function is_shared_impl
|
||||
return 1
|
||||
}
|
||||
|
||||
function is_shared_linux
|
||||
{
|
||||
typeset fs=$1
|
||||
typeset mtpt
|
||||
|
||||
for mtpt in `share | awk '{print $1}'` ; do
|
||||
if [[ $mtpt == $fs ]] ; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
#
|
||||
# Given a mountpoint, or a dataset name, determine if it is shared via NFS.
|
||||
#
|
||||
@@ -1376,7 +1387,11 @@ function is_shared
|
||||
fi
|
||||
fi
|
||||
|
||||
is_shared_impl "$fs"
|
||||
case $(uname) in
|
||||
FreeBSD) is_shared_freebsd "$fs" ;;
|
||||
Linux) is_shared_linux "$fs" ;;
|
||||
*) is_shared_illumos "$fs" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user