/* SPDX-License-Identifier: LGPL-2.1+ */
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#ifndef FUSE_USE_VERSION
-#define FUSE_USE_VERSION 26
-#endif
-
-#define _FILE_OFFSET_BITS 64
+#include "config.h"
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
-#include <fuse.h>
#include <inttypes.h>
#include <libgen.h>
#include <linux/magic.h>
#include <unistd.h>
#include <wait.h>
-#include "api_extensions.h"
#include "bindings.h"
+
+#include "api_extensions.h"
#include "cgroup_fuse.h"
#include "cgroups/cgroup.h"
#include "cgroups/cgroup_utils.h"
-#include "config.h"
#include "memory_utils.h"
#include "proc_cpuview.h"
#include "syscall_numbers.h"
#include "utils.h"
static bool can_use_pidfd;
+static bool can_use_swap;
+static bool can_use_sys_cpu;
+static bool has_versioned_opts;
static volatile sig_atomic_t reload_successful;
return reload_successful != 0;
}
+bool liblxcfs_can_use_swap(void)
+{
+ return can_use_swap;
+}
+
+bool liblxcfs_can_use_sys_cpu(void)
+{
+ return can_use_sys_cpu;
+}
+
+bool liblxcfs_has_versioned_opts(void)
+{
+ return has_versioned_opts;
+}
+
/* Define pivot_root() if missing from the C library */
#ifndef HAVE_PIVOT_ROOT
static int pivot_root(const char *new_root, const char *put_old)
return false;
}
-static int pivot_enter()
+static int pivot_enter(void)
{
__do_close int oldroot = -EBADF, newroot = -EBADF;
return 0;
}
-static int chroot_enter()
+static int chroot_enter(void)
{
if (mount(ROOTDIR, "/", NULL, MS_REC | MS_BIND, NULL)) {
lxcfs_error("Failed to recursively bind-mount %s into /.", ROOTDIR);
please_compiler:
/*
* The write() syscall is a function whose return value needs to be
- * checked. Otherwise the compiler will warn. This is how we
- * please our master. Another one could be to use
- * syscall(__NR_write, ...) directly but whatever.
+ * checked. Otherwise the compiler will warn.Another one could be to
+ * use syscall(__NR_write, ...) directly but whatever.
*/
return;
}
lxcfs_info("Kernel supports pidfds");
}
+ can_use_swap = cgroup_ops->can_use_swap(cgroup_ops);
+ if (can_use_swap)
+ lxcfs_info("Kernel supports swap accounting");
+ else
+ lxcfs_info("Kernel does not support swap accounting");
+
lxcfs_info("api_extensions:");
- for (i = 0; i < nr_api_extensions; i++)
- lxcfs_info("- %s", api_extensions[i]);
+ for (size_t nr = 0; nr < nr_api_extensions; nr++)
+ lxcfs_info("- %s", api_extensions[nr]);
root_fd = open("/", O_PATH | O_CLOEXEC);
if (root_fd < 0)
free_cpuview();
cgroup_exit(cgroup_ops);
}
+
+void *lxcfs_fuse_init(struct fuse_conn_info *conn, void *data)
+{
+ struct fuse_context *fc = fuse_get_context();
+ can_use_sys_cpu = true;
+ has_versioned_opts = true;
+ return fc->private_data;
+}