diff options
author | marks <none@none> | 2007-06-26 07:44:24 -0700 |
---|---|---|
committer | marks <none@none> | 2007-06-26 07:44:24 -0700 |
commit | ecd6cf800b63704be73fb264c3f5b6e0dafc068d (patch) | |
tree | ec83d040bc56ee0a46e9533a645e832e58d8ba86 /usr/src/lib/libshare/common/libshare_zfs.c | |
parent | 8ac1b93fdff76ea81638299d410b2d474240ee2b (diff) | |
download | illumos-joyent-ecd6cf800b63704be73fb264c3f5b6e0dafc068d.tar.gz |
PSARC/2006/465 ZFS Delegated Administration
PSARC/2006/577 zpool property to disable delegation
PSARC/2006/625 Enhancements to zpool history
PSARC/2007/228 ZFS delegation amendments
PSARC/2007/295 ZFS Delegated Administration Addendum
6280676 restore "owner" property
6349470 investigate non-root restore/backup
6572465 'zpool set bootfs=...' records history as 'zfs set bootfs=...'
Diffstat (limited to 'usr/src/lib/libshare/common/libshare_zfs.c')
-rw-r--r-- | usr/src/lib/libshare/common/libshare_zfs.c | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/usr/src/lib/libshare/common/libshare_zfs.c b/usr/src/lib/libshare/common/libshare_zfs.c index b7ac6c0d74..8beb621524 100644 --- a/usr/src/lib/libshare/common/libshare_zfs.c +++ b/usr/src/lib/libshare/common/libshare_zfs.c @@ -254,7 +254,7 @@ get_zfs_dataset(sa_handle_impl_t impl_handle, char *path) /* canmount must be set */ canmount[0] = '\0'; - if (!zfs_prop_get(zlist[i], ZFS_PROP_CANMOUNT, canmount, + if (zfs_prop_get(zlist[i], ZFS_PROP_CANMOUNT, canmount, sizeof (canmount), NULL, NULL, 0, B_FALSE) != 0 || strcmp(canmount, "off") == 0) continue; @@ -914,3 +914,76 @@ sa_path_is_zfs(char *path) sa_free_fstype(fstype); return (ret); } + +int +sa_sharetab_fill_zfs(sa_share_t share, share_t *sh, char *proto) +{ + char *path; + + path = sa_get_share_attr(share, "path"); + if (path != NULL) { + (void) memset(sh, 0, sizeof (sh)); + (void) sa_fillshare(share, proto, sh); + return (0); + } else + return (1); +} + +#define SMAX(i, j) \ + if ((j) > (i)) { \ + (i) = (j); \ + } + +int +sa_share_zfs(sa_share_t share, char *path, share_t *sh, + void *exportdata, boolean_t on) +{ + libzfs_handle_t *libhandle; + sa_group_t group; + sa_handle_t sahandle; + char *dataset; + int err = EINVAL; + int i, j; + + /* + * First find the dataset name + */ + if ((group = sa_get_parent_group(share)) == NULL) { + return (SA_SYSTEM_ERR); + } + if ((sahandle = sa_find_group_handle(group)) == NULL) { + return (SA_SYSTEM_ERR); + } + + if ((dataset = get_zfs_dataset(sahandle, path)) == NULL) { + return (SA_SYSTEM_ERR); + } + + libhandle = libzfs_init(); + if (libhandle != NULL) { + + i = (sh->sh_path ? strlen(sh->sh_path) : 0); + sh->sh_size = i; + + j = (sh->sh_res ? strlen(sh->sh_res) : 0); + sh->sh_size += j; + SMAX(i, j); + + j = (sh->sh_fstype ? strlen(sh->sh_fstype) : 0); + sh->sh_size += j; + SMAX(i, j); + + j = (sh->sh_opts ? strlen(sh->sh_opts) : 0); + sh->sh_size += j; + SMAX(i, j); + + j = (sh->sh_descr ? strlen(sh->sh_descr) : 0); + sh->sh_size += j; + SMAX(i, j); + err = zfs_deleg_share_nfs(libhandle, dataset, path, + exportdata, sh, i, on); + libzfs_fini(libhandle); + } + free(dataset); + return (err); +} |