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 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)
free_cpuview();
cgroup_exit(cgroup_ops);
}
+
+void *lxcfs_fuse_init(struct fuse_conn_info *conn, struct fuse_config *cfg)
+{
+ struct fuse_context *fc = fuse_get_context();
+ can_use_sys_cpu = true;
+ has_versioned_opts = true;
+ return fc->private_data;
+}
#define _FILE_OFFSET_BITS 64
#include <fuse.h>
+#include <linux/types.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
bool swap_off;
bool use_pidfd;
bool use_cfs;
+ /*
+ * Ideally we'd version by size but because of backwards compatability
+ * and the use of bool instead of explicited __u32 and __u64 we can't.
+ */
+ __u32 version;
};
typedef enum lxcfs_opt_t {
extern bool supports_pidfd(void);
extern bool liblxcfs_functional(void);
extern bool liblxcfs_can_use_swap(void);
+extern bool liblxcfs_can_use_sys_cpu(void);
+extern bool liblxcfs_has_versioned_opts(void);
static inline bool lxcfs_has_opt(struct lxcfs_opts *opts, lxcfs_opt_t opt)
{
return pid;
}
+__visible extern void *lxcfs_fuse_init(struct fuse_conn_info *conn,
+ struct fuse_config *cfg);
+
#endif /* __LXCFS_BINDINGS_H */
return -ENOENT;
}
+static void *lxcfs_init(struct fuse_conn_info *conn, struct fuse_config *cfg)
+{
+ char *error;
+ void *(*__lxcfs_fuse_init)(struct fuse_conn_info * conn, struct fuse_config * cfg);
+
+ dlerror();
+ __lxcfs_fuse_init = (void *(*)(struct fuse_conn_info * conn, struct fuse_config * cfg))dlsym(dlopen_handle, "lxcfs_fuse_init");
+ error = dlerror();
+ if (error)
+ return log_error(NULL, "%s - Failed to find lxcfs_fuse_init()", error);
+
+ return __lxcfs_fuse_init(conn, cfg);
+}
+
const struct fuse_operations lxcfs_ops = {
.access = lxcfs_access,
.chmod = lxcfs_chmod,
.flush = lxcfs_flush,
.fsync = lxcfs_fsync,
.getattr = lxcfs_getattr,
+ .init = lxcfs_init,
.mkdir = lxcfs_mkdir,
.open = lxcfs_open,
.opendir = lxcfs_opendir,
.getdir = NULL,
#endif
.getxattr = NULL,
- .init = NULL,
.link = NULL,
.listxattr = NULL,
.mknod = NULL,
opts->swap_off = false;
opts->use_pidfd = false;
opts->use_cfs = false;
+ opts->version = 1;
while ((c = getopt_long(argc, argv, "dulfhvso:p:", long_options, &idx)) != -1) {
switch (c) {