FreeBSD/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
/*
 * Unshare a filesystem by mountpoint.
 */
Unshare a filesystem by mountpoint.
Unshare a filesystem by mountpoint .
static int
unshare_one(libzfs_handle_t *hdl, const char *name, const char *mountpoint,
    zfs_share_proto_t proto)
{
#ifdef illumos
	sa_share_t share;
	int err;
	char *mntpt;
	mntpt = zfs_strdup(hdl, mountpoint);
	if ((err = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) {
		free(mntpt);	
		return (zfs_error_fmt(hdl, EZFS_SHARENFSFAILED,
		    dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"),
		    name, _sa_errorstr(err)));
	}
	share = zfs_sa_find_share(hdl->libzfs_sharehdl, mntpt);
	free(mntpt);	
	if (share != NULL) {
		err = zfs_sa_disable_share(share, proto_table[proto].p_name);
		if (err != SA_OK) {
			return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,
			    dgettext(TEXT_DOMAIN, "cannot unshare '%s': %s"),
			    name, _sa_errorstr(err)));
		}
	} else {
		return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,
		    dgettext(TEXT_DOMAIN, "cannot unshare '%s': not found"),
		    name));
	}
#else
	char buf[MAXPATHLEN];
	FILE *fp;
	int err;
	if (proto != PROTO_NFS) {
		fprintf(stderr, "No SMB support in FreeBSD yet.\n");
		return (EOPNOTSUPP);
	}
	err = fsunshare(ZFS_EXPORTS_PATH, mountpoint);
	if (err != 0) {
		zfs_error_aux(hdl, "%s", strerror(err));
		return (zfs_error_fmt(hdl, EZFS_UNSHARENFSFAILED,
		    dgettext(TEXT_DOMAIN,
		    "cannot unshare '%s'"), name));
	}
#endif
	return (0);
}
static int unshare_one ( libzfs_handle_t * hdl , const char * name , const char * mountpoint , zfs_share_proto_t proto ) { #ifdef illumos sa_share_t share ; int err ; char * mntpt ; mntpt = zfs_strdup ( hdl , mountpoint ) ; if ( ( err = zfs_init_libshare ( hdl , SA_INIT_SHARE_API ) ) != SA_OK ) { free ( mntpt ) ; return ( zfs_error_fmt ( hdl , EZFS_SHARENFSFAILED , dgettext ( TEXT_DOMAIN , " " ) , name , _sa_errorstr ( err ) ) ) ; } share = zfs_sa_find_share ( hdl -> libzfs_sharehdl , mntpt ) ; free ( mntpt ) ; if ( share != NULL ) { err = zfs_sa_disable_share ( share , proto_table [ proto ] . p_name ) ; if ( err != SA_OK ) { return ( zfs_error_fmt ( hdl , EZFS_UNSHARENFSFAILED , dgettext ( TEXT_DOMAIN , " " ) , name , _sa_errorstr ( err ) ) ) ; } } else { return ( zfs_error_fmt ( hdl , EZFS_UNSHARENFSFAILED , dgettext ( TEXT_DOMAIN , " " ) , name ) ) ; } #else char buf [ MAXPATHLEN ] ; FILE * fp ; int err ; if ( proto != PROTO_NFS ) { fprintf ( stderr , " \n " ) ; return ( EOPNOTSUPP ) ; } err = fsunshare ( ZFS_EXPORTS_PATH , mountpoint ) ; if ( err != 0 ) { zfs_error_aux ( hdl , " " , strerror ( err ) ) ; return ( zfs_error_fmt ( hdl , EZFS_UNSHARENFSFAILED , dgettext ( TEXT_DOMAIN , " " ) , name ) ) ; } #endif return ( 0 ) ; }
Unshare a filesystem by mountpoint.
Unshare a filesystem by mountpoint .
/*
	 * Mountpoint could get trashed if libshare calls getmntany
	 * which it does during API initialization, so strdup the
	 * value.
	 */ /* make sure libshare initialized */ /* don't need the copy anymore */ /* don't need the copy anymore */