text stringlengths 0 14.1k |
|---|
thename); |
else |
(void) snprintf(desc, sizeof (desc), |
dgettext(TEXT_DOMAIN, ""cannot import '%s' as '%s'""), |
origname, thename); |
switch (errno) { |
case ENOTSUP: |
/* |
* Unsupported version. |
*/ |
(void) zfs_error(hdl, EZFS_BADVERSION, desc); |
break; |
case EINVAL: |
(void) zfs_error(hdl, EZFS_INVALCONFIG, desc); |
break; |
case EROFS: |
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, |
""one or more devices is read only"")); |
(void) zfs_error(hdl, EZFS_BADDEV, desc); |
break; |
default: |
(void) zcmd_read_dst_nvlist(hdl, &zc, &nvi); |
(void) zpool_standard_error(hdl, errno, desc); |
zpool_explain_recover(hdl, |
newname ? origname : thename, -errno, nvi); |
nvlist_free(nvi); |
break; |
} |
ret = -1; |
} else { |
zpool_handle_t *zhp; |
/* |
* This should never fail, but play it safe anyway. |
*/ |
if (zpool_open_silent(hdl, thename, &zhp) != 0) |
ret = -1; |
else if (zhp != NULL) |
zpool_close(zhp); |
(void) zcmd_read_dst_nvlist(hdl, &zc, &nvi); |
zpool_get_rewind_policy(config, &policy); |
if (policy.zrp_request & |
(ZPOOL_DO_REWIND | ZPOOL_TRY_REWIND)) { |
zpool_rewind_exclaim(hdl, newname ? origname : thename, |
((policy.zrp_request & ZPOOL_TRY_REWIND) != 0), |
nvi); |
} |
nvlist_free(nvi); |
return (0); |
} |
zcmd_free_nvlists(&zc); |
nvlist_free(props); |
return (ret); |
} |
/* |
* Scan the pool. |
*/ |
int |
zpool_scan(zpool_handle_t *zhp, pool_scan_func_t func) |
{ |
zfs_cmd_t zc = { 0 }; |
char msg[1024]; |
libzfs_handle_t *hdl = zhp->zpool_hdl; |
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); |
zc.zc_cookie = func; |
if (zfs_ioctl(zhp->zpool_hdl, ZFS_IOC_POOL_SCAN, &zc) == 0 || |
(errno == ENOENT && func != POOL_SCAN_NONE)) |
return (0); |
if (func == POOL_SCAN_SCRUB) { |
(void) snprintf(msg, sizeof (msg), |
dgettext(TEXT_DOMAIN, ""cannot scrub %s""), zc.zc_name); |
} else if (func == POOL_SCAN_NONE) { |
(void) snprintf(msg, sizeof (msg), |
dgettext(TEXT_DOMAIN, ""cannot cancel scrubbing %s""), |
zc.zc_name); |
} else { |
assert(!""unexpected result""); |
} |
if (errno == EBUSY) { |
nvlist_t *nvroot; |
pool_scan_stat_t *ps = NULL; |
uint_t psc; |
verify(nvlist_lookup_nvlist(zhp->zpool_config, |
ZPOOL_CONFIG_VDEV_TREE, &nvroot) == 0); |
(void) nvlist_lookup_uint64_array(nvroot, |
ZPOOL_CONFIG_SCAN_STATS, (uint64_t **)&ps, &psc); |
if (ps && ps->pss_func == POOL_SCAN_SCRUB) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.