[lxc-devel] [lxcfs/master] Add support to nonempty option

geaaru on Github lxc-bot at linuxcontainers.org
Tue Apr 24 22:02:06 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 342 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180424/93cfba4e/attachment.bin>
-------------- next part --------------
From 13141d48ebcf22cdd3827654ebb3effa48212e72 Mon Sep 17 00:00:00 2001
From: Geaaru <geaaru at gmail.com>
Date: Wed, 25 Apr 2018 00:01:03 +0200
Subject: [PATCH] Add support to nonempty option

Signed-off-by: Geaaru <geaaru at gmail.com>
---
 lxcfs.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lxcfs.c b/lxcfs.c
index 62cfd35..313c297 100644
--- a/lxcfs.c
+++ b/lxcfs.c
@@ -847,7 +847,7 @@ int main(int argc, char *argv[])
 	int pidfd = -1;
 	char *pidfile = NULL, *v = NULL;
 	size_t pidfile_len;
-	bool debug = false;
+	bool debug = false, nonempty = false;
 	/*
 	 * what we pass to fuse_main is:
 	 * argv[0] -s [-f|-d] -o allow_other,directio argv[1] NULL
@@ -860,10 +860,11 @@ int main(int argc, char *argv[])
 	swallow_arg(&argc, argv, "-f");
 	debug = swallow_arg(&argc, argv, "-d");
 	if (swallow_option(&argc, argv, "-o", &v)) {
-		if (strcmp(v, "allow_other") != 0) {
+		if (strncmp(v, "allow_other", 11) != 0 && strncmp(v, "nonempty", 8) != 0) {
 			fprintf(stderr, "Warning: unexpected fuse option %s\n", v);
 			exit(EXIT_FAILURE);
-		}
+		} else if (strncmp(v, "nonempty", 8) == 0)
+			nonempty = true;
 		free(v);
 		v = NULL;
 	}
@@ -890,7 +891,10 @@ int main(int argc, char *argv[])
                 newargv[cnt++] = "-f";
         }
 	newargv[cnt++] = "-o";
-	newargv[cnt++] = "allow_other,direct_io,entry_timeout=0.5,attr_timeout=0.5";
+	if (nonempty)
+		newargv[cnt++] = "allow_other,direct_io,entry_timeout=0.5,attr_timeout=0.5,nonempty";
+	else
+		newargv[cnt++] = "allow_other,direct_io,entry_timeout=0.5,attr_timeout=0.5";
 	newargv[cnt++] = argv[1];
 	newargv[cnt++] = NULL;
 


More information about the lxc-devel mailing list