diff mbox

[3/3] exportfs.c: Escape path for '-s' option

Message ID 1387397189-9591-3-git-send-email-tasleson@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tony Asleson Dec. 18, 2013, 8:06 p.m. UTC
When outputing the paths and the user has specified the option
-s, escape the path.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
---
 utils/exportfs/exportfs.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 019961b..9ea86cb 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -666,6 +666,9 @@  dumpopt(char c, char *fmt, ...)
 static void
 dump(int verbose, int export_format)
 {
+	char buf[1024];
+	char *bp;
+	int len;
 	nfs_export	*exp;
 	struct exportent *ep;
 	int		htype;
@@ -683,7 +686,15 @@  dump(int verbose, int export_format)
 			if (strlen(ep->e_path) > 14 && !export_format)
 				printf("%-14s\n\t\t%s", ep->e_path, hname);
 			else
-				printf(((export_format)? "%s %s" : "%-14s\t%s"), ep->e_path, hname);
+				if (export_format) {
+					bp = buf;
+					len = sizeof(buf) - 1;
+					qword_add(&bp, &len, ep->e_path);
+					*bp = '\0';
+					printf("%s %s", buf, hname);
+				} else {
+					printf("%-14s\t%s", ep->e_path, hname);
+				}
 
 			if (!verbose && !export_format) {
 				printf("\n");