All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kenneth D'souza <kdsouza@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: bfields@redhat.com, kdsouza@redhat.com, agaikwad@redhat.com
Subject: [PATCH] nfsd4: Make "info" file json compatible.
Date: Fri,  1 May 2020 11:52:30 +0530	[thread overview]
Message-ID: <20200501062230.19693-1-kdsouza@redhat.com> (raw)

Currently the output returned by client_info_show() is not
pure json, fix it so user space can pass the file properly.

Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
Signed-off-by: Achilles Gaikwad <agaikwad@redhat.com>
---
 fs/nfsd/nfs4state.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index c107caa56525..f2a14f95ffa6 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2341,19 +2341,24 @@ static int client_info_show(struct seq_file *m, void *v)
 	if (!clp)
 		return -ENXIO;
 	memcpy(&clid, &clp->cl_clientid, sizeof(clid));
-	seq_printf(m, "clientid: 0x%llx\n", clid);
-	seq_printf(m, "address: \"%pISpc\"\n", (struct sockaddr *)&clp->cl_addr);
-	seq_printf(m, "name: ");
+	seq_printf(m, "{\n");
+	seq_printf(m, "\t\"clientid\": \"0x%llx\",\n", clid);
+	seq_printf(m, "\t\"address\": \"%pISpc\",\n", (struct sockaddr *)&clp->cl_addr);
+	seq_printf(m, "\t\"name\": ");
 	seq_quote_mem(m, clp->cl_name.data, clp->cl_name.len);
-	seq_printf(m, "\nminor version: %d\n", clp->cl_minorversion);
+	seq_printf(m, ", ");
+	seq_printf(m, "\n\t\"minor version\": %d,\n", clp->cl_minorversion);
 	if (clp->cl_nii_domain.data) {
-		seq_printf(m, "Implementation domain: ");
+		seq_printf(m, "\t\"Implementation domain\": ");
 		seq_quote_mem(m, clp->cl_nii_domain.data,
 					clp->cl_nii_domain.len);
-		seq_printf(m, "\nImplementation name: ");
+		seq_printf(m, ", ");
+		seq_printf(m, "\n\t\"Implementation name\": ");
 		seq_quote_mem(m, clp->cl_nii_name.data, clp->cl_nii_name.len);
-		seq_printf(m, "\nImplementation time: [%lld, %ld]\n",
+		seq_printf(m, ", ");
+		seq_printf(m, "\n\t\"Implementation time\": \"[%lld, %ld]\"\n",
 			clp->cl_nii_time.tv_sec, clp->cl_nii_time.tv_nsec);
+		seq_printf(m, "}\n");
 	}
 	drop_client(clp);
 
-- 
2.21.1


             reply	other threads:[~2020-05-01  6:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-01  6:22 Kenneth D'souza [this message]
2020-05-07  1:32 ` [PATCH] nfsd4: Make "info" file json compatible J. Bruce Fields
2020-05-07  2:30   ` Kenneth Dsouza

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200501062230.19693-1-kdsouza@redhat.com \
    --to=kdsouza@redhat.com \
    --cc=agaikwad@redhat.com \
    --cc=bfields@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.