From 62092574233a823f107f6afa9bf4c0e1861e4da2 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Wed, 31 Jan 2024 12:39:08 +0100 Subject: [PATCH] json: dump the output to the user selected filedescriptor Allow the user to select the output filedescriptor instead always dumping it to stdout. This allows to write the output to a file. Signed-off-by: Daniel Wagner --- src/nvme/json.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nvme/json.c b/src/nvme/json.c index e9d37bcc..b49498a4 100644 --- a/src/nvme/json.c +++ b/src/nvme/json.c @@ -576,9 +576,9 @@ int json_dump_tree(nvme_root_t r) } json_object_object_add(json_root, "hosts", host_array); - ret = json_object_to_fd(1, json_root, JSON_C_TO_STRING_PRETTY); + ret = json_object_to_fd(fileno(r->fp), json_root, JSON_C_TO_STRING_PRETTY); if (ret < 0) { - nvme_msg(r, LOG_ERR, "Failed to write to stdout, %s\n", + nvme_msg(r, LOG_ERR, "Failed to write, %s\n", json_util_get_last_err()); ret = -1; errno = EIO; -- 2.50.1