]> git.proxmox.com Git - mirror_lxcfs.git/blobdiff - lxcfs.c
lxcfs: add --disable-cfs
[mirror_lxcfs.git] / lxcfs.c
diff --git a/lxcfs.c b/lxcfs.c
index b378de0b5101c80ddb3e6b69d8791df85de09b92..1f4d902861db5740b59db045b882eff3aa81ec24 100644 (file)
--- a/lxcfs.c
+++ b/lxcfs.c
@@ -957,16 +957,23 @@ const struct fuse_operations lxcfs_ops = {
 
 static void usage()
 {
-       fprintf(stderr, "Usage:\n");
+       fprintf(stderr, "Usage: lxcfs <directory>\n");
        fprintf(stderr, "\n");
-       fprintf(stderr, "lxcfs [-f|-d] -u -l -n [-p pidfile] mountpoint\n");
-       fprintf(stderr, "  -f running foreground by default; -d enable debug output \n");
-       fprintf(stderr, "  -l use loadavg \n");
-       fprintf(stderr, "  -u no swap \n");
-       fprintf(stderr, "  Default pidfile is %s/lxcfs.pid\n", RUNTIME_PATH);
-       fprintf(stderr, "lxcfs -h\n");
-       fprintf(stderr, "lxcfs -v\n");
-       exit(1);
+       fprintf(stderr, "lxcfs set up fuse- and cgroup-based virtualizing filesystem\n");
+       fprintf(stderr, "\n");
+       fprintf(stderr, "Options :\n");
+       fprintf(stderr, "-d, --debug            Run lxcfs with debugging enabled\n");
+       fprintf(stderr, "--disable-cfs          Disable cpu virtualization via cpu shares\n");
+       fprintf(stderr, "-f, --foreground       Run lxcfs in the foreground\n");
+       fprintf(stderr, "-n, --help             Print help\n");
+       fprintf(stderr, "-l, --enable-loadavg   Enable loadavg virtualization\n");
+       fprintf(stderr, "-o                     Options to pass directly through fuse\n");
+       fprintf(stderr, "-p, --pidfile=FILE     Path to use for storing lxcfs pid\n");
+       fprintf(stderr, "                       Default pidfile is %s/lxcfs.pid\n", RUNTIME_PATH);
+       fprintf(stderr, "-u, --disable-swap     Disable swap virtualization\n");
+       fprintf(stderr, "-v, --version          Print lxcfs version\n");
+       fprintf(stderr, "--enable-pidfd         Use pidfd for process tracking\n");
+       exit(EXIT_FAILURE);
 }
 
 static inline bool is_help(char *w)
@@ -1065,7 +1072,7 @@ int main(int argc, char *argv[])
        int ret = EXIT_FAILURE;
        char *pidfile = NULL, *saveptr = NULL, *token = NULL, *v = NULL;
        char pidfile_buf[STRLITERALLEN(RUNTIME_PATH) + STRLITERALLEN("/lxcfs.pid") + 1] = {};
-       bool debug = false, nonempty = false;
+       bool debug = false, foreground = false, nonempty = false;
        bool load_use = false;
        /*
         * what we pass to fuse_main is:
@@ -1082,18 +1089,40 @@ int main(int argc, char *argv[])
        }
        opts->swap_off = false;
        opts->use_pidfd = false;
+       opts->use_cfs = true;
 
        /* accomodate older init scripts */
        swallow_arg(&argc, argv, "-s");
-       swallow_arg(&argc, argv, "-f");
+
+       /* -f / --foreground */
+       foreground = swallow_arg(&argc, argv, "-f");
+       if (swallow_arg(&argc, argv, "--foreground"))
+               foreground = true;
+
+       /* -d / --debug */
        debug = swallow_arg(&argc, argv, "-d");
-       if (swallow_arg(&argc, argv, "-l"))
+       if (swallow_arg(&argc, argv, "--debug"))
+               debug = true;
+
+       if (foreground && debug)
+               log_exit("Both --debug and --forgreound specified");
+
+       /* -l / --enable-loadavg */
+       load_use = swallow_arg(&argc, argv, "-l");
+       if (swallow_arg(&argc, argv, "--enable-loadavg"))
                load_use = true;
-       if (swallow_arg(&argc, argv, "-u"))
+
+       /* -u / --disable-swap */
+       opts->swap_off = swallow_arg(&argc, argv, "-u");
+       if (swallow_arg(&argc, argv, "--disable-swap"))
                opts->swap_off = true;
 
-       if (swallow_arg(&argc, argv, "--pidfd"))
-               opts->use_pidfd = true;
+       /* --enable-pidfd */
+       opts->use_pidfd = swallow_arg(&argc, argv, "--enable-pidfd");
+
+       /* --disable-cfs */
+       if (swallow_arg(&argc, argv, "--disable-cfs"))
+               opts->use_cfs = false;
 
        if (swallow_option(&argc, argv, "-o", &v)) {
                /* Parse multiple values */
@@ -1111,8 +1140,12 @@ int main(int argc, char *argv[])
                free(v);
                v = NULL;
        }
+
+       /* -p / --pidfile */
        if (swallow_option(&argc, argv, "-p", &v))
                pidfile = v;
+       if (!pidfile && swallow_option(&argc, argv, "--pidfile", &v))
+               pidfile = v;
 
        if (argc == 2  && is_version(argv[1])) {
                fprintf(stderr, "%s\n", VERSION);
@@ -1135,9 +1168,9 @@ int main(int argc, char *argv[])
                newargv[cnt++] = "-f";
        newargv[cnt++] = "-o";
        if (nonempty)
-               newargv[cnt++] = "allow_other,direct_io,entry_timeout=0.5,attr_timeout=0.5,nonempty";
+               newargv[cnt++] = "default_permissions,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++] = "default_permissions,allow_other,direct_io,entry_timeout=0.5,attr_timeout=0.5";
        newargv[cnt++] = argv[1];
        newargv[cnt++] = NULL;