diff options
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c index e09417aa2dfb..b9db421dcbcf 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c @@ -20,8 +20,8 @@ */ /* + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2011, 2014 by Delphix. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. */ @@ -256,7 +256,8 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len, break; case ZPOOL_PROP_HEALTH: - (void) strlcpy(buf, "FAULTED", len); + (void) strlcpy(buf, + zpool_pool_state_to_name(POOL_STATE_UNAVAIL), len); break; case ZPOOL_PROP_GUID: @@ -408,7 +409,7 @@ bootfs_name_valid(const char *pool, char *bootfs) static boolean_t pool_uses_efi(nvlist_t *config) { -#ifdef sun +#ifdef illumos nvlist_t **child; uint_t c, children; @@ -420,7 +421,7 @@ pool_uses_efi(nvlist_t *config) if (pool_uses_efi(child[c])) return (B_TRUE); } -#endif /* sun */ +#endif /* illumos */ return (B_FALSE); } @@ -574,7 +575,7 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname, verify(nvlist_lookup_nvlist(zpool_get_config(zhp, NULL), ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); -#ifdef sun +#ifdef illumos /* * bootfs property cannot be set on a disk which has * been EFI labeled. @@ -587,7 +588,7 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname, zpool_close(zhp); goto error; } -#endif /* sun */ +#endif /* illumos */ zpool_close(zhp); break; @@ -1714,7 +1715,7 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, thename = origname; } - if (props) { + if (props != NULL) { uint64_t version; prop_flags_t flags = { .create = B_FALSE, .import = B_TRUE }; @@ -1722,12 +1723,13 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, &version) == 0); if ((props = zpool_valid_proplist(hdl, origname, - props, version, flags, errbuf)) == NULL) { + props, version, flags, errbuf)) == NULL) return (-1); - } else if (zcmd_write_src_nvlist(hdl, &zc, props) != 0) { + if (zcmd_write_src_nvlist(hdl, &zc, props) != 0) { nvlist_free(props); return (-1); } + nvlist_free(props); } (void) strlcpy(zc.zc_name, thename, sizeof (zc.zc_name)); @@ -1736,11 +1738,11 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, &zc.zc_guid) == 0); if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0) { - nvlist_free(props); + zcmd_free_nvlists(&zc); return (-1); } if (zcmd_alloc_dst_nvlist(hdl, &zc, zc.zc_nvlist_conf_size * 2) != 0) { - nvlist_free(props); + zcmd_free_nvlists(&zc); return (-1); } @@ -1756,6 +1758,9 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, error = errno; (void) zcmd_read_dst_nvlist(hdl, &zc, &nv); + + zcmd_free_nvlists(&zc); + zpool_get_rewind_policy(config, &policy); if (error) { @@ -1861,9 +1866,6 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, return (0); } - zcmd_free_nvlists(&zc); - nvlist_free(props); - return (ret); } @@ -1915,6 +1917,7 @@ zpool_scan(zpool_handle_t *zhp, pool_scan_func_t func) } } +#ifdef illumos /* * This provides a very minimal check whether a given string is likely a * c#t#d# style string. Users of this are expected to do their own @@ -1946,6 +1949,7 @@ ctd_check_path(char *str) { } return (CTD_CHECK(str)); } +#endif /* * Find a vdev that matches the search criteria specified. We use the @@ -2001,6 +2005,7 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search, boolean_t *avail_spare, * * Otherwise, all other searches are simple string compares. */ +#ifdef illumos if (strcmp(srchkey, ZPOOL_CONFIG_PATH) == 0 && ctd_check_path(val)) { uint64_t wholedisk = 0; @@ -2040,6 +2045,9 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search, boolean_t *avail_spare, break; } } else if (strcmp(srchkey, ZPOOL_CONFIG_TYPE) == 0 && val) { +#else + if (strcmp(srchkey, ZPOOL_CONFIG_TYPE) == 0 && val) { +#endif char *type, *idx, *end, *p; uint64_t id, vdev_id; @@ -2377,7 +2385,7 @@ zpool_get_physpath(zpool_handle_t *zhp, char *physpath, size_t phypath_size) static int zpool_relabel_disk(libzfs_handle_t *hdl, const char *name) { -#ifdef sun +#ifdef illumos char path[MAXPATHLEN]; char errbuf[1024]; int fd, error; @@ -2407,7 +2415,7 @@ zpool_relabel_disk(libzfs_handle_t *hdl, const char *name) "relabel '%s': unable to read disk capacity"), name); return (zfs_error(hdl, EZFS_NOCAP, errbuf)); } -#endif /* sun */ +#endif /* illumos */ return (0); } @@ -3325,8 +3333,10 @@ devid_to_path(char *devid_str) if (ret != 0) return (NULL); - if ((path = strdup(list[0].devname)) == NULL) - return (NULL); + /* + * In a case the strdup() fails, we will just return NULL below. + */ + path = strdup(list[0].devname); devid_free_nmlist(list); @@ -3463,7 +3473,7 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, devid_str_free(newdevid); } -#ifdef sun +#ifdef illumos if (strncmp(path, "/dev/dsk/", 9) == 0) path += 9; @@ -3488,10 +3498,10 @@ zpool_vdev_name(libzfs_handle_t *hdl, zpool_handle_t *zhp, nvlist_t *nv, } return (tmp); } -#else /* !sun */ +#else /* !illumos */ if (strncmp(path, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0) path += sizeof(_PATH_DEV) - 1; -#endif /* !sun */ +#endif /* illumos */ } else { verify(nvlist_lookup_string(nv, ZPOOL_CONFIG_TYPE, &path) == 0); @@ -3881,7 +3891,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj, free(mntpnt); } -#ifdef sun +#ifdef illumos /* * Read the EFI label from the config, if a label does not exist then * pass back the error to the caller. If the caller has passed a non-NULL @@ -3946,7 +3956,7 @@ find_start_block(nvlist_t *config) } return (MAXOFFSET_T); } -#endif /* sun */ +#endif /* illumos */ /* * Label an individual disk. The name provided is the short name, @@ -3955,7 +3965,7 @@ find_start_block(nvlist_t *config) int zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name) { -#ifdef sun +#ifdef illumos char path[MAXPATHLEN]; struct dk_gpt *vtoc; int fd; @@ -4060,7 +4070,7 @@ zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name) (void) close(fd); efi_free(vtoc); -#endif /* sun */ +#endif /* illumos */ return (0); } |