mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Allow zfs unshare <protocol> -a
Allow `zfs unshare <protocol> -a` command to share or unshare all datasets of a given protocol, nfs or smb. Additionally, enable most of ZFS Test Suite zfs_share/zfs_unshare test cases. To work around some Illumos-specific functionalities ($SHARE/$UNSHARE) some function wrappers were added around them. Finally, fix and issue in smb_is_share_active() that would leave SMB shares exported when invoking 'zfs unshare -a' Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Turbo Fredriksson <turbo@bayour.com> Signed-off-by: loli10K <ezomori.nozomu@gmail.com> Closes #3238 Closes #5367
This commit is contained in:
+5
-3
@@ -354,17 +354,19 @@ smb_validate_shareopts(const char *shareopts)
|
||||
static boolean_t
|
||||
smb_is_share_active(sa_share_impl_t impl_share)
|
||||
{
|
||||
smb_share_t *iter = smb_shares;
|
||||
|
||||
if (!smb_available())
|
||||
return (B_FALSE);
|
||||
|
||||
/* Retrieve the list of (possible) active shares */
|
||||
smb_retrieve_shares();
|
||||
|
||||
while (smb_shares != NULL) {
|
||||
if (strcmp(impl_share->sharepath, smb_shares->path) == 0)
|
||||
while (iter != NULL) {
|
||||
if (strcmp(impl_share->sharepath, iter->path) == 0)
|
||||
return (B_TRUE);
|
||||
|
||||
smb_shares = smb_shares->next;
|
||||
iter = iter->next;
|
||||
}
|
||||
|
||||
return (B_FALSE);
|
||||
|
||||
@@ -988,6 +988,20 @@ zfs_unshareall_bypath(zfs_handle_t *zhp, const char *mountpoint)
|
||||
return (zfs_unshare_proto(zhp, mountpoint, share_all_proto));
|
||||
}
|
||||
|
||||
int
|
||||
zfs_unshareall_bytype(zfs_handle_t *zhp, const char *mountpoint,
|
||||
const char *proto)
|
||||
{
|
||||
if (proto == NULL)
|
||||
return (zfs_unshare_proto(zhp, mountpoint, share_all_proto));
|
||||
if (strcmp(proto, "nfs") == 0)
|
||||
return (zfs_unshare_proto(zhp, mountpoint, nfs_only));
|
||||
else if (strcmp(proto, "smb") == 0)
|
||||
return (zfs_unshare_proto(zhp, mountpoint, smb_only));
|
||||
else
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the mountpoint associated with the current dataset, if necessary.
|
||||
* We only remove the underlying directory if:
|
||||
|
||||
Reference in New Issue
Block a user