Skip to contentSkip to conversation

nfsd4: Make "info" file json compatible.

PATCH In review Kenneth D'souza 2 participants 3 messages May 1, 2020 – May 7, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsd4: Make "info" file json compatible.

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

---
 fs/nfsd/nfs4state.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
fs/nfsd/nfs4state.c +12 -7
index c107caa56525..f2a14f95ffa6 100644
@@ -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);
 
Signature · 1 line
2.21.1
#1 lore raw
Quoted 2 lines · Kenneth D'souza

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.

Quoted 45 lines
---
 fs/nfsd/nfs4state.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
fs/nfsd/nfs4state.c +12 -7
index c107caa56525..f2a14f95ffa6 100644
@@ -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);
 
Signature · 1 line
2.21.1
#2 lore raw

Thanks for the feedback Bruce.

Quoted 58 lines · J. Bruce Fields
Quoted 2 lines · Kenneth D'souza

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.

Quoted 45 lines
---
 fs/nfsd/nfs4state.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
fs/nfsd/nfs4state.c +12 -8
index c107caa56525..f2a14f95ffa6 100644
@@ -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