mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
nvlist: Add nvlist_snprintf() and zfs_dbgmsg_nvlist()
Add nvlist_snprintf() to print a nvlist to a buffer. This is basically the snprintf() version of dump_nvlist(). Along with that, add a zfs_dbgmsg_nvlist() to print out an nvlist to dbgmsg. This will aid in debugging. Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Tony Hutter <hutter2@llnl.gov> Closes #17215
This commit is contained in:
@@ -267,6 +267,8 @@ _SYS_NVPAIR_H int nvlist_lookup_double(const nvlist_t *, const char *,
|
||||
double *);
|
||||
#endif
|
||||
|
||||
_SYS_NVPAIR_H int nvlist_snprintf(char *, size_t, nvlist_t *, int);
|
||||
|
||||
_SYS_NVPAIR_H int nvlist_lookup_nvpair(nvlist_t *, const char *, nvpair_t **);
|
||||
_SYS_NVPAIR_H int nvlist_lookup_nvpair_embedded_index(nvlist_t *, const char *,
|
||||
nvpair_t **, int *, const char **);
|
||||
|
||||
@@ -39,6 +39,8 @@ extern "C" {
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#include <sys/nvpair.h>
|
||||
|
||||
extern int zfs_flags;
|
||||
extern int zfs_recover;
|
||||
extern int zfs_free_leak_on_eio;
|
||||
@@ -104,6 +106,24 @@ extern void zfs_panic_recover(const char *fmt, ...);
|
||||
extern void zfs_dbgmsg_init(void);
|
||||
extern void zfs_dbgmsg_fini(void);
|
||||
|
||||
/*
|
||||
* When printing an nvlist, print one beginning line with the file/func/line
|
||||
* number and the text "nvlist <var name>:" followed by all the nvlist lines
|
||||
* without the file/fun/line number. This makes the nvlist lines easy to read.
|
||||
*/
|
||||
#define zfs_dbgmsg_nvlist(nv) \
|
||||
if (zfs_dbgmsg_enable) { \
|
||||
zfs_dbgmsg("nvlist "#nv":"); \
|
||||
__zfs_dbgmsg_nvlist(nv); \
|
||||
}
|
||||
|
||||
#define zfs_dbgmsg(...) \
|
||||
if (zfs_dbgmsg_enable) \
|
||||
__dprintf(B_FALSE, __FILE__, __func__, __LINE__, __VA_ARGS__)
|
||||
|
||||
|
||||
extern void __zfs_dbgmsg_nvlist(nvlist_t *nv);
|
||||
|
||||
#ifndef _KERNEL
|
||||
extern int dprintf_find_string(const char *string);
|
||||
extern void zfs_dbgmsg_print(int fd, const char *tag);
|
||||
|
||||
Reference in New Issue
Block a user