mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-04-17 08:54:52 +03:00
Make zpool_find_config() report errors
All of zpool_find_config() callers now set lpc_printerr. Actually printing the errors when pool can not be found should make zdb a half percent less confusing. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> Closes #17642
This commit is contained in:
parent
2c877e8453
commit
a9410ccbd9
@ -1903,8 +1903,14 @@ zpool_find_config(libpc_handle_t *hdl, const char *target, nvlist_t **configp,
|
|||||||
*sepp = '\0';
|
*sepp = '\0';
|
||||||
|
|
||||||
pools = zpool_search_import(hdl, args);
|
pools = zpool_search_import(hdl, args);
|
||||||
|
if (pools == NULL) {
|
||||||
|
zutil_error_aux(hdl, dgettext(TEXT_DOMAIN, "no pools found"));
|
||||||
|
(void) zutil_error_fmt(hdl, LPC_UNKNOWN, dgettext(TEXT_DOMAIN,
|
||||||
|
"failed to find config for pool '%s'"), targetdup);
|
||||||
|
free(targetdup);
|
||||||
|
return (ENOENT);
|
||||||
|
}
|
||||||
|
|
||||||
if (pools != NULL) {
|
|
||||||
nvpair_t *elem = NULL;
|
nvpair_t *elem = NULL;
|
||||||
while ((elem = nvlist_next_nvpair(pools, elem)) != NULL) {
|
while ((elem = nvlist_next_nvpair(pools, elem)) != NULL) {
|
||||||
VERIFY0(nvpair_value_nvlist(elem, &config));
|
VERIFY0(nvpair_value_nvlist(elem, &config));
|
||||||
@ -1919,14 +1925,21 @@ zpool_find_config(libpc_handle_t *hdl, const char *target, nvlist_t **configp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fnvlist_free(pools);
|
fnvlist_free(pools);
|
||||||
}
|
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
|
zutil_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
||||||
|
"no matching pools"));
|
||||||
|
(void) zutil_error_fmt(hdl, LPC_UNKNOWN, dgettext(TEXT_DOMAIN,
|
||||||
|
"failed to find config for pool '%s'"), targetdup);
|
||||||
free(targetdup);
|
free(targetdup);
|
||||||
return (ENOENT);
|
return (ENOENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
|
zutil_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
||||||
|
"more than one matching pool"));
|
||||||
|
(void) zutil_error_fmt(hdl, LPC_UNKNOWN, dgettext(TEXT_DOMAIN,
|
||||||
|
"failed to find config for pool '%s'"), targetdup);
|
||||||
free(targetdup);
|
free(targetdup);
|
||||||
fnvlist_free(match);
|
fnvlist_free(match);
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user