mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-23 02:44:41 +03:00
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 <behlendorf1@llnl.gov> Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Signed-off-by: Umer Saleem <usaleem@ixsystems.com> Closes #13969
This commit is contained in:
committed by
Brian Behlendorf
parent
d62bafee9f
commit
d9ac17a57f
+23
-4
@@ -59,6 +59,15 @@ typedef const struct pool_config_ops {
|
||||
_LIBZUTIL_H pool_config_ops_t libzfs_config_ops;
|
||||
_LIBZUTIL_H pool_config_ops_t libzpool_config_ops;
|
||||
|
||||
typedef enum lpc_error {
|
||||
LPC_SUCCESS = 0, /* no error -- success */
|
||||
LPC_BADCACHE = 2000, /* out of memory */
|
||||
LPC_BADPATH, /* must be an absolute path */
|
||||
LPC_NOMEM, /* out of memory */
|
||||
LPC_EACCESS, /* some devices require root privileges */
|
||||
LPC_UNKNOWN
|
||||
} lpc_error_t;
|
||||
|
||||
typedef struct importargs {
|
||||
char **path; /* a list of paths to search */
|
||||
int paths; /* number of paths to search */
|
||||
@@ -70,10 +79,20 @@ typedef struct importargs {
|
||||
nvlist_t *policy; /* load policy (max txg, rewind, etc.) */
|
||||
} importargs_t;
|
||||
|
||||
_LIBZUTIL_H nvlist_t *zpool_search_import(void *, importargs_t *,
|
||||
pool_config_ops_t *);
|
||||
_LIBZUTIL_H int zpool_find_config(void *, const char *, nvlist_t **,
|
||||
importargs_t *, pool_config_ops_t *);
|
||||
typedef struct libpc_handle {
|
||||
int lpc_error;
|
||||
boolean_t lpc_printerr;
|
||||
boolean_t lpc_open_access_error;
|
||||
boolean_t lpc_desc_active;
|
||||
char lpc_desc[1024];
|
||||
pool_config_ops_t *lpc_ops;
|
||||
void *lpc_lib_handle;
|
||||
} libpc_handle_t;
|
||||
|
||||
_LIBZUTIL_H const char *libpc_error_description(libpc_handle_t *);
|
||||
_LIBZUTIL_H nvlist_t *zpool_search_import(libpc_handle_t *, importargs_t *);
|
||||
_LIBZUTIL_H int zpool_find_config(libpc_handle_t *, const char *, nvlist_t **,
|
||||
importargs_t *);
|
||||
|
||||
_LIBZUTIL_H const char * const * zpool_default_search_paths(size_t *count);
|
||||
_LIBZUTIL_H int zpool_read_label(int, nvlist_t **, int *);
|
||||
|
||||
Reference in New Issue
Block a user