summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordougm <none@none>2008-01-09 08:33:04 -0800
committerdougm <none@none>2008-01-09 08:33:04 -0800
commit8e314a4400960b022e9b9135577c1c0ceebd1e36 (patch)
tree051dc14742387c9e36bc015e881b05bc241a1b3c
parent4210e8839ed460021fb6bded1f56af3acfe29a99 (diff)
downloadillumos-gate-8e314a4400960b022e9b9135577c1c0ceebd1e36.tar.gz
6639919 Remove shares failed at the first time with error message "Could not remove share: unknown -1"
-rw-r--r--usr/src/lib/libshare/nfs/libshare_nfs.c95
-rw-r--r--usr/src/lib/libshare/smb/libshare_smb.c20
2 files changed, 68 insertions, 47 deletions
diff --git a/usr/src/lib/libshare/nfs/libshare_nfs.c b/usr/src/lib/libshare/nfs/libshare_nfs.c
index 2be9c9c569..8d1aa7b48a 100644
--- a/usr/src/lib/libshare/nfs/libshare_nfs.c
+++ b/usr/src/lib/libshare/nfs/libshare_nfs.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -1897,10 +1897,12 @@ out:
}
/*
- * nfs_disable_share(share)
+ * nfs_disable_share(share, path)
*
- * Unshare the specified share. How much error checking should be
- * done? We only do basic errors for now.
+ * Unshare the specified share. Note that "path" is the same path as
+ * what is in the "share" object. It is passed in to avoid an
+ * additional lookup. A missing "path" value makes this a no-op
+ * function.
*/
static int
nfs_disable_share(sa_share_t share, char *path)
@@ -1908,54 +1910,59 @@ nfs_disable_share(sa_share_t share, char *path)
int err;
int ret = SA_OK;
int iszfs;
+ sa_group_t parent;
+ if (path == NULL)
+ return (ret);
- if (path != NULL) {
- iszfs = sa_path_is_zfs(path);
-
- if (iszfs) {
- struct exportfs_args ea;
- share_t sh = { 0 };
-
- ea.dname = path;
- ea.uex = NULL;
- sh.sh_path = path;
- sh.sh_fstype = "nfs";
-
- err = sa_share_zfs(share, path, &sh,
- &ea, ZFS_UNSHARE_NFS);
- } else
- err = exportfs(path, NULL);
- if (err < 0) {
- /*
- * TBD: only an error in some
- * cases - need better analysis
- */
-
- switch (errno) {
- case EPERM:
- case EACCES:
- ret = SA_NO_PERMISSION;
- if (getzoneid() != GLOBAL_ZONEID) {
- ret = SA_NOT_SUPPORTED;
- }
- break;
- case EINVAL:
- case ENOENT:
- ret = SA_NO_SUCH_PATH;
+ /*
+ * If the share is in a ZFS group we need to handle it
+ * differently. Just being on a ZFS file system isn't
+ * enough since we may be in a legacy share case.
+ */
+ parent = sa_get_parent_group(share);
+ iszfs = sa_group_is_zfs(parent);
+ if (iszfs) {
+ struct exportfs_args ea;
+ share_t sh = { 0 };
+ ea.dname = path;
+ ea.uex = NULL;
+ sh.sh_path = path;
+ sh.sh_fstype = "nfs";
+
+ err = sa_share_zfs(share, path, &sh,
+ &ea, ZFS_UNSHARE_NFS);
+ } else {
+ err = exportfs(path, NULL);
+ }
+ if (err < 0) {
+ /*
+ * TBD: only an error in some
+ * cases - need better analysis
+ */
+ switch (errno) {
+ case EPERM:
+ case EACCES:
+ ret = SA_NO_PERMISSION;
+ if (getzoneid() != GLOBAL_ZONEID) {
+ ret = SA_NOT_SUPPORTED;
+ }
+ break;
+ case EINVAL:
+ case ENOENT:
+ ret = SA_NO_SUCH_PATH;
break;
default:
ret = SA_SYSTEM_ERR;
break;
- }
- }
- if (ret == SA_OK || ret == SA_NO_SUCH_PATH) {
- if (!iszfs)
- (void) sa_delete_sharetab(path, "nfs");
- /* just in case it was logged */
- (void) nfslogtab_deactivate(path);
}
}
+ if (ret == SA_OK || ret == SA_NO_SUCH_PATH) {
+ if (!iszfs)
+ (void) sa_delete_sharetab(path, "nfs");
+ /* just in case it was logged */
+ (void) nfslogtab_deactivate(path);
+ }
return (ret);
}
diff --git a/usr/src/lib/libshare/smb/libshare_smb.c b/usr/src/lib/libshare/smb/libshare_smb.c
index 0a3ed7535b..82a1a31806 100644
--- a/usr/src/lib/libshare/smb/libshare_smb.c
+++ b/usr/src/lib/libshare/smb/libshare_smb.c
@@ -607,19 +607,33 @@ smb_resource_changed(sa_resource_t resource)
}
/*
- * smb_disable_share(sa_share_t share)
+ * smb_disable_share(sa_share_t share, char *path)
*
- * Unshare the specified share.
+ * Unshare the specified share. Note that "path" is the same
+ * path as what is in the "share" object. It is passed in to avoid an
+ * additional lookup. A missing "path" value makes this a no-op
+ * function.
*/
static int
smb_disable_share(sa_share_t share, char *path)
{
char *rname;
sa_resource_t resource;
+ sa_group_t parent;
boolean_t iszfs;
int err = SA_OK;
- iszfs = sa_path_is_zfs(path);
+ if (path == NULL)
+ return (err);
+
+ /*
+ * If the share is in a ZFS group we need to handle it
+ * differently. Just being on a ZFS file system isn't
+ * enough since we may be in a legacy share case.
+ */
+ parent = sa_get_parent_group(share);
+ iszfs = sa_group_is_zfs(parent);
+
if (!smb_isonline())
goto done;