]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
Add support to nonempty option
authorGeaaru <geaaru@gmail.com>
Tue, 24 Apr 2018 22:01:03 +0000 (00:01 +0200)
committerGeaaru <geaaru@gmail.com>
Wed, 2 May 2018 14:59:59 +0000 (16:59 +0200)
Signed-off-by: Geaaru <geaaru@gmail.com>
lxcfs.c

diff --git a/lxcfs.c b/lxcfs.c
index 62cfd3509751b248df3ae432ad1719cdf2c4aab3..8370c35e2bdcb148e03c64d862facf188f22408c 100644 (file)
--- a/lxcfs.c
+++ b/lxcfs.c
@@ -845,9 +845,9 @@ int main(int argc, char *argv[])
 {
        int ret = EXIT_FAILURE;
        int pidfd = -1;
-       char *pidfile = NULL, *v = NULL;
+       char *pidfile = NULL, *saveptr = NULL, *token = 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,9 +860,17 @@ 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) {
-                       fprintf(stderr, "Warning: unexpected fuse option %s\n", v);
-                       exit(EXIT_FAILURE);
+               /* Parse multiple values */
+               for (; (token = strtok_r(v, ",", &saveptr)); v = NULL) {
+                       if (strcmp(token, "allow_other") == 0) {
+                               /* Noop. this is the default. Always enabled. */
+                       } else if (strcmp(token, "nonempty") == 0) {
+                               nonempty = true;
+                       } else {
+                               free(v);
+                               fprintf(stderr, "Warning: unexpected fuse option %s\n", v);
+                               exit(EXIT_FAILURE);
+                       }
                }
                free(v);
                v = NULL;
@@ -884,13 +892,15 @@ int main(int argc, char *argv[])
        }
 
        newargv[cnt++] = argv[0];
-        if (debug) {
-                newargv[cnt++] = "-d";
-        } else {
-                newargv[cnt++] = "-f";
-        }
+       if (debug)
+               newargv[cnt++] = "-d";
+       else
+               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;