All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfsd4: Make "info" file json compatible.
@ 2020-05-01  6:22 Kenneth D'souza
  2020-05-07  1:32 ` J. Bruce Fields
  0 siblings, 1 reply; 3+ messages in thread
From: Kenneth D'souza @ 2020-05-01  6:22 UTC (permalink / raw)
  To: linux-nfs; +Cc: bfields, kdsouza, agaikwad

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] nfsd4: Make "info" file json compatible.
  2020-05-01  6:22 [PATCH] nfsd4: Make "info" file json compatible Kenneth D'souza
@ 2020-05-07  1:32 ` J. Bruce Fields
  2020-05-07  2:30   ` Kenneth Dsouza
  0 siblings, 1 reply; 3+ messages in thread
From: J. Bruce Fields @ 2020-05-07  1:32 UTC (permalink / raw)
  To: Kenneth D'souza; +Cc: linux-nfs, bfields, agaikwad

On Fri, May 01, 2020 at 11:52:30AM +0530, Kenneth D'souza wrote:
> Currently the output returned by client_info_show() is not
> pure json, fix it so user space can pass the file properly.

Gah, I said JSON, but the promise was that these files would be YAML,
which I believe is a superset of JSON.

I'd prefer not to make major backwards-incompatible changes.

--b.

> 
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nfsd4: Make "info" file json compatible.
  2020-05-07  1:32 ` J. Bruce Fields
@ 2020-05-07  2:30   ` Kenneth Dsouza
  0 siblings, 0 replies; 3+ messages in thread
From: Kenneth Dsouza @ 2020-05-07  2:30 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: linux-nfs, Bruce Fields, Achilles Gaikwad

Thanks for the feedback Bruce.

On Thu, May 7, 2020 at 7:02 AM J. Bruce Fields <bfields@fieldses.org> wrote:
>
> On Fri, May 01, 2020 at 11:52:30AM +0530, Kenneth D'souza wrote:
> > Currently the output returned by client_info_show() is not
> > pure json, fix it so user space can pass the file properly.
>
> Gah, I said JSON, but the promise was that these files would be YAML,
> which I believe is a superset of JSON.
>
> I'd prefer not to make major backwards-incompatible changes.
>
> --b.
>
> >
> > 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
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-07  2:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-01  6:22 [PATCH] nfsd4: Make "info" file json compatible Kenneth D'souza
2020-05-07  1:32 ` J. Bruce Fields
2020-05-07  2:30   ` Kenneth Dsouza

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.