text stringlengths 0 14.1k |
|---|
zpool_prop_to_name(ZPOOL_PROP_CACHEFILE), ""none"") != 0) { |
nvlist_free(props); |
return (zfs_error_fmt(hdl, EZFS_NOMEM, |
dgettext(TEXT_DOMAIN, ""cannot import '%s'""), |
newname)); |
} |
} |
ret = zpool_import_props(hdl, config, newname, props, B_FALSE); |
if (props) |
nvlist_free(props); |
return (ret); |
} |
/* |
* Import the given pool using the known configuration and a list of |
* properties to be set. The configuration should have come from |
* zpool_find_import(). The 'newname' parameters control whether the pool |
* is imported with a different name. |
*/ |
int |
zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, |
nvlist_t *props, boolean_t importfaulted) |
{ |
zfs_cmd_t zc = { 0 }; |
zpool_rewind_policy_t policy; |
nvlist_t *nvi = NULL; |
char *thename; |
char *origname; |
uint64_t returned_size; |
int ret; |
char errbuf[1024]; |
verify(nvlist_lookup_string(config, ZPOOL_CONFIG_POOL_NAME, |
&origname) == 0); |
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, |
""cannot import pool '%s'""), origname); |
if (newname != NULL) { |
if (!zpool_name_valid(hdl, B_FALSE, newname)) |
return (zfs_error_fmt(hdl, EZFS_INVALIDNAME, |
dgettext(TEXT_DOMAIN, ""cannot import '%s'""), |
newname)); |
thename = (char *)newname; |
} else { |
thename = origname; |
} |
if (props) { |
uint64_t version; |
verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, |
&version) == 0); |
if ((props = zpool_valid_proplist(hdl, origname, |
props, version, B_TRUE, errbuf)) == NULL) { |
return (-1); |
} else if (zcmd_write_src_nvlist(hdl, &zc, props) != 0) { |
nvlist_free(props); |
return (-1); |
} |
} |
(void) strlcpy(zc.zc_name, thename, sizeof (zc.zc_name)); |
verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_GUID, |
&zc.zc_guid) == 0); |
if (zcmd_write_conf_nvlist(hdl, &zc, config) != 0) { |
nvlist_free(props); |
return (-1); |
} |
returned_size = zc.zc_nvlist_conf_size + 512; |
if (zcmd_alloc_dst_nvlist(hdl, &zc, returned_size) != 0) { |
nvlist_free(props); |
return (-1); |
} |
zc.zc_cookie = (uint64_t)importfaulted; |
ret = 0; |
if (zfs_ioctl(hdl, ZFS_IOC_POOL_IMPORT, &zc) != 0) { |
char desc[1024]; |
(void) zcmd_read_dst_nvlist(hdl, &zc, &nvi); |
zpool_get_rewind_policy(config, &policy); |
/* |
* Dry-run failed, but we print out what success |
* looks like if we found a best txg |
*/ |
if ((policy.zrp_request & ZPOOL_TRY_REWIND) && nvi) { |
zpool_rewind_exclaim(hdl, newname ? origname : thename, |
B_TRUE, nvi); |
nvlist_free(nvi); |
return (-1); |
} |
if (newname == NULL) |
(void) snprintf(desc, sizeof (desc), |
dgettext(TEXT_DOMAIN, ""cannot import '%s'""), |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.