aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zdb
diff options
context:
space:
mode:
authorUmer Saleem <[email protected]>2022-09-26 18:40:43 +0500
committerBrian Behlendorf <[email protected]>2022-10-04 09:54:35 -0700
commitd9ac17a57f66bdbd482ab09ab238cb941821e13f (patch)
tree1261d407346f84a257ddc4932e8db72fe5b814f6 /cmd/zdb
parentd62bafee9fc38f8b9653c531e1861e83dcba4618 (diff)
Expose libzutil error info in libpc_handle_t
In libzutil, for zpool_search_import and zpool_find_config, we use libpc_handle_t internally, which does not maintain error code and it is not exposed in the interface. Due to this, the error information is not propagated to the caller. Instead, an error message is printed on stderr. This commit adds lpc_error field in libpc_handle_t and exposes it in the interface, which can be used by the users of libzutil to get the appropriate error information and handle it accordingly. Users of the API can also control if they want to print the error message on stderr. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Ryan Moeller <[email protected]> Signed-off-by: Umer Saleem <[email protected]> Closes #13969
Diffstat (limited to 'cmd/zdb')
-rw-r--r--cmd/zdb/zdb.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c
index 96db9c4b9..18a94da1f 100644
--- a/cmd/zdb/zdb.c
+++ b/cmd/zdb/zdb.c
@@ -8778,8 +8778,12 @@ main(int argc, char **argv)
args.path = searchdirs;
args.can_be_active = B_TRUE;
- error = zpool_find_config(NULL, target_pool, &cfg, &args,
- &libzpool_config_ops);
+ libpc_handle_t lpch = {
+ .lpc_lib_handle = NULL,
+ .lpc_ops = &libzpool_config_ops,
+ .lpc_printerr = B_TRUE
+ };
+ error = zpool_find_config(&lpch, target_pool, &cfg, &args);
if (error == 0) {