summaryrefslogtreecommitdiff
path: root/usr/src/lib/libzfs/common/libzfs_import.c
diff options
context:
space:
mode:
authoreschrock <none@none>2006-09-05 11:37:36 -0700
committereschrock <none@none>2006-09-05 11:37:36 -0700
commite9dbad6f263d5570ed7ff5443ec5b958af8c24d7 (patch)
tree7bd6d85273a4462fc4699aa9ed69e33bd69e2613 /usr/src/lib/libzfs/common/libzfs_import.c
parentf724721be86f2d808bc08cd6be299acc214e3dc5 (diff)
downloadillumos-joyent-e9dbad6f263d5570ed7ff5443ec5b958af8c24d7.tar.gz
PSARC 2006/486 ZFS canmount property
PSARC 2006/497 ZFS create time properties PSARC 2006/502 ZFS get all datasets PSARC 2006/504 ZFS user properties 6269805 properties should be set via an nvlist. 6281585 user defined properties 6349494 'zfs list' output annoying for even moderately long dataset names 6366244 'canmount' option for container-like functionality 6367103 create-time properties 6416639 RFE: provide zfs get -a 6437808 ZFS module version should match on-disk version 6454551 'zfs create -b blocksize filesystem' should fail. 6457478 unrecognized character in error message with 'zpool create -R' command 6457865 missing device name in the error message of 'zpool clear' command 6458571 zfs_ioc_set_prop() doesn't validate input 6458614 zfs ACL #defines should use prefix 6458638 get_configs() accesses bogus memory 6458678 zvol functions should be moved out of zfs_ioctl.h 6458683 zfs_cmd_t could use more cleanup 6458691 common routines to manage zfs_cmd_t nvlists 6460398 zpool import cores on zfs_prop_get 6461029 zpool status -x noexisting-pool has incorrect error message. 6461223 index translations should live with property definitions 6461424 zpool_unmount_datasets() has some busted logic 6461427 zfs_realloc() would be useful 6461757 'zpool status' can report the wrong number of persistent errors 6461784 recursive zfs_snapshot() leaks memory
Diffstat (limited to 'usr/src/lib/libzfs/common/libzfs_import.c')
-rw-r--r--usr/src/lib/libzfs/common/libzfs_import.c47
1 files changed, 18 insertions, 29 deletions
diff --git a/usr/src/lib/libzfs/common/libzfs_import.c b/usr/src/lib/libzfs/common/libzfs_import.c
index 6b76b2922c..ea74079bee 100644
--- a/usr/src/lib/libzfs/common/libzfs_import.c
+++ b/usr/src/lib/libzfs/common/libzfs_import.c
@@ -382,7 +382,6 @@ get_configs(libzfs_handle_t *hdl, pool_list_t *pl)
char *name;
zfs_cmd_t zc = { 0 };
uint64_t version, guid;
- char *packed;
size_t len;
int err;
uint_t children = 0;
@@ -575,50 +574,38 @@ get_configs(libzfs_handle_t *hdl, pool_list_t *pl)
/*
* Try to do the import in order to get vdev state.
*/
- if ((err = nvlist_size(config, &len, NV_ENCODE_NATIVE)) != 0)
- goto nomem;
-
- if ((packed = zfs_alloc(hdl, len)) == NULL)
- goto nomem;
-
- if ((err = nvlist_pack(config, &packed, &len,
- NV_ENCODE_NATIVE, 0)) != 0)
- goto nomem;
+ if (zcmd_write_src_nvlist(hdl, &zc, config, &len) != 0)
+ goto error;
nvlist_free(config);
config = NULL;
- zc.zc_config_src_size = len;
- zc.zc_config_src = (uint64_t)(uintptr_t)packed;
-
- zc.zc_config_dst_size = 2 * len;
- if ((zc.zc_config_dst = (uint64_t)(uintptr_t)
- zfs_alloc(hdl, zc.zc_config_dst_size)) == NULL)
- goto nomem;
+ if (zcmd_alloc_dst_nvlist(hdl, &zc, len * 2) != 0) {
+ zcmd_free_nvlists(&zc);
+ goto error;
+ }
while ((err = ioctl(hdl->libzfs_fd, ZFS_IOC_POOL_TRYIMPORT,
&zc)) != 0 && errno == ENOMEM) {
- free((void *)(uintptr_t)zc.zc_config_dst);
- if ((zc.zc_config_dst = (uint64_t)(uintptr_t)
- zfs_alloc(hdl, zc.zc_config_dst_size)) == NULL)
- goto nomem;
+ if (zcmd_expand_dst_nvlist(hdl, &zc) != 0) {
+ zcmd_free_nvlists(&zc);
+ goto error;
+ }
}
- free(packed);
-
if (err) {
(void) zpool_standard_error(hdl, errno,
dgettext(TEXT_DOMAIN, "cannot discover pools"));
- free((void *)(uintptr_t)zc.zc_config_dst);
+ zcmd_free_nvlists(&zc);
goto error;
}
- if (nvlist_unpack((void *)(uintptr_t)zc.zc_config_dst,
- zc.zc_config_dst_size, &config, 0) != 0) {
- free((void *)(uintptr_t)zc.zc_config_dst);
- goto nomem;
+ if (zcmd_read_dst_nvlist(hdl, &zc, &config) != 0) {
+ zcmd_free_nvlists(&zc);
+ goto error;
}
- free((void *)(uintptr_t)zc.zc_config_dst);
+
+ zcmd_free_nvlists(&zc);
/*
* Go through and update the paths for spares, now that we have
@@ -640,6 +627,8 @@ get_configs(libzfs_handle_t *hdl, pool_list_t *pl)
/*
* Add this pool to the list of configs.
*/
+ verify(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME,
+ &name) == 0);
if (nvlist_add_nvlist(ret, name, config) != 0)
goto nomem;