diff options
author | Umer Saleem <[email protected]> | 2024-04-05 21:02:30 +0500 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2024-08-06 12:45:45 -0700 |
commit | aa15b60e58599c8851358f6c7f85097f79fcfe55 (patch) | |
tree | 8f84e80bcec088a48b42c87a192f88524f59ac8e /include/libzfs.h | |
parent | 6c7d41a64373a2df615ec804b9c5d635d5019064 (diff) |
JSON output support for zfs version and zfs get
This commit adds support for JSON output for zfs version and zfs get
commands. '-j' flag can be used to get output in JSON format.
Information is collected in nvlist objects which is later printed in
JSON format. Existing options that work for zfs get and zfs version
also work with '-j' flag.
man pages for zfs get and zfs version are updated accordingly.
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Ameer Hamza <[email protected]>
Signed-off-by: Umer Saleem <[email protected]>
Closes #16217
Diffstat (limited to 'include/libzfs.h')
-rw-r--r-- | include/libzfs.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/libzfs.h b/include/libzfs.h index 979b919ce..42054d74b 100644 --- a/include/libzfs.h +++ b/include/libzfs.h @@ -631,6 +631,8 @@ _LIBZFS_H int zprop_get_list(libzfs_handle_t *, char *, zprop_list_t **, zfs_type_t); _LIBZFS_H void zprop_free_list(zprop_list_t *); +_LIBZFS_H void zcmd_print_json(nvlist_t *); + #define ZFS_GET_NCOLS 5 typedef enum { @@ -658,9 +660,12 @@ typedef struct zprop_get_cbdata { boolean_t cb_scripted; boolean_t cb_literal; boolean_t cb_first; + boolean_t cb_json; zprop_list_t *cb_proplist; zfs_type_t cb_type; vdev_cbdata_t cb_vdevs; + nvlist_t *cb_jsobj; + boolean_t cb_json_as_int; } zprop_get_cbdata_t; #define ZFS_SET_NOMOUNT 1 @@ -674,6 +679,9 @@ _LIBZFS_H void zprop_print_one_property(const char *, zprop_get_cbdata_t *, const char *, const char *, zprop_source_t, const char *, const char *); +_LIBZFS_H int zprop_nvlist_one_property(const char *, const char *, + zprop_source_t, const char *, const char *, nvlist_t *, boolean_t); + /* * Iterator functions. */ @@ -979,6 +987,7 @@ _LIBZFS_H boolean_t libzfs_envvar_is_set(const char *); _LIBZFS_H const char *zfs_version_userland(void); _LIBZFS_H char *zfs_version_kernel(void); _LIBZFS_H int zfs_version_print(void); +_LIBZFS_H nvlist_t *zfs_version_nvlist(void); /* * Given a device or file, determine if it is part of a pool. |