AC_CHECK_LIB(pthread, main)
-PKG_CHECK_MODULES(FUSE, fuse)
+PKG_CHECK_MODULES(FUSE, fuse, [], [
+ PKG_CHECK_MODULES(FUSE, fuse3, [AC_DEFINE([HAVE_FUSE3], [1], [Use fuse3])])
+])
AC_PATH_PROG(HELP2MAN, help2man, false // No help2man //)
AM_CONDITIONAL([HAVE_HELP2MAN], [test "x$HELP2MAN" != "xfalse // No help2man //" ])
#define _GNU_SOURCE
#endif
+#include "config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#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"
#define _GNU_SOURCE
#endif
+#include "config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#include <sys/vfs.h>
#include "bindings.h"
-#include "config.h"
#include "cgroups/cgroup.h"
#include "cgroups/cgroup_utils.h"
+#include "fuse_compat.h"
#include "memory_utils.h"
#include "utils.h"
if (!fc || !cgroup_ops || pure_unified_layout(cgroup_ops))
return -EIO;
- if (filler(buf, ".", NULL, 0) != 0 || filler(buf, "..", NULL, 0) != 0)
+ if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 || DIR_FILLER(filler, buf, "..", NULL, 0) != 0)
return -EIO;
if (d->type != LXC_TYPE_CGDIR) {
if (is_unified_hierarchy(*h))
continue;
- if ((*h)->__controllers && filler(buf, (*h)->__controllers, NULL, 0))
+ if ((*h)->__controllers && DIR_FILLER(filler, buf, (*h)->__controllers, NULL, 0))
return -EIO;
}
initpid = fc->pid;
if (!caller_is_in_ancestor(initpid, d->controller, d->cgroup, &nextcg)) {
if (nextcg) {
- ret = filler(buf, nextcg, NULL, 0);
+ ret = DIR_FILLER(filler, buf, nextcg, NULL, 0);
free(nextcg);
if (ret != 0) {
ret = -EIO;
}
for (i = 0; list && list[i]; i++) {
- if (filler(buf, list[i]->name, NULL, 0) != 0) {
+ if (DIR_FILLER(filler, buf, list[i]->name, NULL, 0) != 0) {
ret = -EIO;
goto out;
}
}
if (clist) {
for (i = 0; clist[i]; i++) {
- if (filler(buf, clist[i], NULL, 0) != 0) {
+ if (DIR_FILLER(filler, buf, clist[i], NULL, 0) != 0) {
ret = -EIO;
goto out;
}
#define _GNU_SOURCE
#endif
+#include "../config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
#include <unistd.h>
-#include "../config.h"
#include "../macro.h"
#include "../memory_utils.h"
#include "../utils.h"
#define _GNU_SOURCE
#endif
+#include "../config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#include <sys/vfs.h>
#include <unistd.h>
-#include "../config.h"
#include "../macro.h"
#include "../memory_utils.h"
#include "cgroup.h"
#define _GNU_SOURCE
#endif
+#include "../config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
#include <unistd.h>
-#include "../config.h"
#include "../macro.h"
#include "../memory_utils.h"
#include "cgroup2_devices.h"
#define _GNU_SOURCE
#endif
+#include "../config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#include <sys/vfs.h>
#include <unistd.h>
-#include "../config.h"
#include "../macro.h"
#include "../memory_utils.h"
#include "cgroup.h"
#define _GNU_SOURCE
#endif
+#include "config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#include "bindings.h"
#include "cgroups/cgroup.h"
#include "cgroups/cgroup_utils.h"
-#include "config.h"
#include "memory_utils.h"
#include "proc_loadavg.h"
#include "utils.h"
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1+ */
+
+#ifndef __LXC_FUSE_COMPAT_H
+#define __LXC_FUSE_COMPAT_H
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#ifdef HAVE_FUSE3
+#define DIR_FILLER(F,B,N,S,O) F(B,N,S,O,FUSE_FILL_DIR_PLUS)
+#else
+#define DIR_FILLER(F,B,N,S,O) F(B,N,S,O)
+#endif
+#endif /* __LXC_FUSE_COMPAT_H */
#define _GNU_SOURCE
#endif
+#include "config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#include <linux/limits.h>
#include "bindings.h"
-#include "config.h"
+#include "fuse_compat.h"
#include "macro.h"
#include "memory_utils.h"
return __sys_releasedir(path, fi);
}
+#ifdef HAVE_FUSE3
+static int lxcfs_getattr(const char *path, struct stat *sb, struct fuse_file_info *fi)
+#else
static int lxcfs_getattr(const char *path, struct stat *sb)
+#endif
{
int ret;
struct timespec now;
return -ENOENT;
}
+#ifdef HAVE_FUSE3
+static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
+ off_t offset, struct fuse_file_info *fi, enum fuse_readdir_flags flags)
+#else
static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
+#endif
{
int ret;
if (strcmp(path, "/") == 0) {
- if (filler(buf, ".", NULL, 0) != 0 ||
- filler(buf, "..", NULL, 0) != 0 ||
- filler(buf, "proc", NULL, 0) != 0 ||
- filler(buf, "sys", NULL, 0) != 0 ||
- filler(buf, "cgroup", NULL, 0) != 0)
+ if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "..", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "proc", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "sys", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "cgroup", NULL, 0) != 0)
return -ENOMEM;
return 0;
return -EPERM;
}
+#ifdef HAVE_FUSE3
+int lxcfs_chown(const char *path, uid_t uid, gid_t gid, struct fuse_file_info *fi)
+#else
int lxcfs_chown(const char *path, uid_t uid, gid_t gid)
+#endif
{
int ret;
* really make sense for cgroups. So just return 0 always but do
* nothing.
*/
+#ifdef HAVE_FUSE3
+int lxcfs_truncate(const char *path, off_t newsize, struct fuse_file_info *fi)
+#else
int lxcfs_truncate(const char *path, off_t newsize)
+#endif
{
if (strncmp(path, "/cgroup", 7) == 0)
return 0;
return -EPERM;
}
+#ifdef HAVE_FUSE3
+int lxcfs_chmod(const char *path, mode_t mode, struct fuse_file_info *fi)
+#else
int lxcfs_chmod(const char *path, mode_t mode)
+#endif
{
int ret;
.create = NULL,
.destroy = NULL,
+#ifndef HAVE_FUSE3
.fgetattr = NULL,
+#endif
.fsyncdir = NULL,
+#ifndef HAVE_FUSE3
.ftruncate = NULL,
.getdir = NULL,
+#endif
.getxattr = NULL,
.init = NULL,
.link = NULL,
.statfs = NULL,
.symlink = NULL,
.unlink = NULL,
+#ifndef HAVE_FUSE3
.utime = NULL,
+#endif
};
static void usage()
#define _GNU_SOURCE
#endif
+#include "config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#include <sys/vfs.h>
#include "bindings.h"
-#include "config.h"
#include "cgroup_fuse.h"
#include "cpuset_parse.h"
#include "cgroups/cgroup.h"
#define _GNU_SOURCE
#endif
+#include "config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#include <sys/vfs.h>
#include "bindings.h"
-#include "config.h"
#include "cgroup_fuse.h"
#include "cgroups/cgroup.h"
#include "cgroups/cgroup_utils.h"
#include "cpuset_parse.h"
+#include "fuse_compat.h"
#include "memory_utils.h"
#include "proc_loadavg.h"
#include "proc_cpuview.h"
fuse_fill_dir_t filler, off_t offset,
struct fuse_file_info *fi)
{
- if (filler(buf, ".", NULL, 0) != 0 ||
- filler(buf, "..", NULL, 0) != 0 ||
- filler(buf, "cpuinfo", NULL, 0) != 0 ||
- filler(buf, "meminfo", NULL, 0) != 0 ||
- filler(buf, "stat", NULL, 0) != 0 ||
- filler(buf, "uptime", NULL, 0) != 0 ||
- filler(buf, "diskstats", NULL, 0) != 0 ||
- filler(buf, "swaps", NULL, 0) != 0 ||
- filler(buf, "loadavg", NULL, 0) != 0)
+ if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "..", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "cpuinfo", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "meminfo", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "stat", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "uptime", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "diskstats", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "swaps", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "loadavg", NULL, 0) != 0)
return -EINVAL;
return 0;
#define _GNU_SOURCE
#endif
+#include "config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#include <sys/vfs.h>
#include "bindings.h"
-#include "config.h"
#include "cgroup_fuse.h"
#include "cgroups/cgroup.h"
#include "cgroups/cgroup_utils.h"
#define _GNU_SOURCE
#endif
+#include "config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#include "bindings.h"
#include "memory_utils.h"
#include "cgroups/cgroup.h"
-#include "config.h"
+#include "fuse_compat.h"
#include "sysfs_fuse.h"
#include "utils.h"
struct fuse_file_info *fi)
{
if (strcmp(path, "/sys") == 0) {
- if (filler(buf, ".", NULL, 0) != 0 ||
- filler(buf, "..", NULL, 0) != 0 ||
- filler(buf, "devices", NULL, 0) != 0)
+ if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "..", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "devices", NULL, 0) != 0)
return -ENOENT;
return 0;
}
if (strcmp(path, "/sys/devices") == 0) {
- if (filler(buf, ".", NULL, 0) != 0 ||
- filler(buf, "..", NULL, 0) != 0 ||
- filler(buf, "system", NULL, 0) != 0)
+ if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "..", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "system", NULL, 0) != 0)
return -ENOENT;
return 0;
}
if (strcmp(path, "/sys/devices/system") == 0) {
- if (filler(buf, ".", NULL, 0) != 0 ||
- filler(buf, "..", NULL, 0) != 0 ||
- filler(buf, "cpu", NULL, 0) != 0)
+ if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "..", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "cpu", NULL, 0) != 0)
return -ENOENT;
return 0;
}
if (strcmp(path, "/sys/devices/system/cpu") == 0) {
- if (filler(buf, ".", NULL, 0) != 0 ||
- filler(buf, "..", NULL, 0) != 0 ||
- filler(buf, "online", NULL, 0) != 0)
+ if (DIR_FILLER(filler, buf, ".", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "..", NULL, 0) != 0 ||
+ DIR_FILLER(filler, buf, "online", NULL, 0) != 0)
return -ENOENT;
return 0;
#define _GNU_SOURCE
#endif
+#include "config.h"
+
+#ifdef HAVE_FUSE3
+#ifndef FUSE_USE_VERSION
+#define FUSE_USE_VERSION 30
+#endif
+#else
#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif
+#endif
#define _FILE_OFFSET_BITS 64
#include <unistd.h>
#include "bindings.h"
-#include "config.h"
#include "macro.h"
#include "memory_utils.h"
#include "utils.h"