#define FUSE_USE_VERSION 30
#include <fuse.h>
+#include <fuse_lowlevel.h>
+#include "include/ceph_fuse.h"
#include <sys/types.h>
#include <sys/stat.h>
struct fs_info {
struct fuse_args args;
struct fuse *f;
+#if FUSE_VERSION < FUSE_MAKE_VERSION(3, 0)
struct fuse_chan *ch;
+#endif
char *mountpoint;
};
}
-static int os_getattr(const char *path, struct stat *stbuf)
+static int os_getattr(const char *path, struct stat *stbuf
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
+ , struct fuse_file_info *fi
+#endif
+ )
{
fuse_context *fc = fuse_get_context();
FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
void *buf,
fuse_fill_dir_t filler,
off_t offset,
- struct fuse_file_info *fi)
+ struct fuse_file_info *fi
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
+ , enum fuse_readdir_flags
+#endif
+ )
{
fuse_context *fc = fuse_get_context();
FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
switch (t) {
case FN_ROOT:
{
- filler(buf, "type", NULL, 0);
+ filler_compat(filler, buf, "type", NULL, 0);
vector<coll_t> cls;
fs->store->list_collections(cls);
for (auto c : cls) {
- int r = filler(buf, stringify(c).c_str(), NULL, 0);
+ int r = filler_compat(filler, buf, stringify(c).c_str(), NULL, 0);
if (r > 0)
break;
}
if (!ch) {
return -ENOENT;
}
- filler(buf, "bitwise_hash_start", NULL, 0);
+ filler_compat(filler, buf, "bitwise_hash_start", NULL, 0);
if (fs->store->collection_bits(ch) >= 0) {
- filler(buf, "bitwise_hash_end", NULL, 0);
- filler(buf, "bitwise_hash_bits", NULL, 0);
+ filler_compat(filler, buf, "bitwise_hash_end", NULL, 0);
+ filler_compat(filler, buf, "bitwise_hash_bits", NULL, 0);
}
- filler(buf, "all", NULL, 0);
- filler(buf, "by_bitwise_hash", NULL, 0);
+ filler_compat(filler, buf, "all", NULL, 0);
+ filler_compat(filler, buf, "by_bitwise_hash", NULL, 0);
spg_t pgid;
if (cid.is_pg(&pgid) &&
fs->store->exists(ch, pgid.make_pgmeta_oid())) {
- filler(buf, "pgmeta", NULL, 0);
+ filler_compat(filler, buf, "pgmeta", NULL, 0);
}
}
break;
case FN_OBJECT:
{
- filler(buf, "bitwise_hash", NULL, 0);
- filler(buf, "data", NULL, 0);
- filler(buf, "omap", NULL, 0);
- filler(buf, "attr", NULL, 0);
- filler(buf, "omap_header", NULL, 0);
+ filler_compat(filler, buf, "bitwise_hash", NULL, 0);
+ filler_compat(filler, buf, "data", NULL, 0);
+ filler_compat(filler, buf, "omap", NULL, 0);
+ filler_compat(filler, buf, "attr", NULL, 0);
+ filler_compat(filler, buf, "omap_header", NULL, 0);
}
break;
uint64_t cur_off = ((uint64_t)bitwise_hash << hash_shift) |
(uint64_t)hashoff;
string s = stringify(p);
- r = filler(buf, s.c_str(), NULL, cur_off);
+ r = filler_compat(filler, buf, s.c_str(), NULL, cur_off);
if (r)
break;
}
continue;
}
++offset;
- int r = filler(buf, k.c_str(), NULL, offset);
+ int r = filler_compat(filler, buf, k.c_str(), NULL, offset);
if (r)
break;
}
continue;
}
++offset;
- int r = filler(buf, a.first.c_str(), NULL, offset);
+ int r = filler_compat(filler, buf, a.first.c_str(), NULL, offset);
if (r)
break;
}
return 0;
}
-static int os_chmod(const char *path, mode_t mode)
+static int os_chmod(const char *path, mode_t mode
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
+ , struct fuse_file_info *fi
+#endif
+ )
{
fuse_context *fc = fuse_get_context();
FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
return 0;
}
-static int os_truncate(const char *path, off_t size)
+static int os_truncate(const char *path, off_t size
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
+ , struct fuse_file_info *fi
+#endif
+ )
{
fuse_context *fc = fuse_get_context();
FuseStore *fs = static_cast<FuseStore*>(fc->private_data);
static struct fuse_operations fs_oper = {
getattr: os_getattr,
readlink: 0,
+#if FUSE_VERSION < FUSE_MAKE_VERSION(3, 0)
getdir: 0,
+#endif
mknod: 0,
mkdir: os_mkdir,
unlink: os_unlink,
chmod: os_chmod,
chown: 0,
truncate: os_truncate,
+#if FUSE_VERSION < FUSE_MAKE_VERSION(3, 0)
utime: 0,
+#endif
open: os_open,
read: os_read,
write: os_write,
"-d", // debug
};
int c = 3;
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
+ int rc;
+ struct fuse_cmdline_opts opts = {};
+#endif
auto fuse_debug = store->cct->_conf.get_val<bool>("fuse_debug");
if (fuse_debug)
++c;
fuse_args a = FUSE_ARGS_INIT(c, (char**)v);
info->args = a;
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
+ if (fuse_parse_cmdline(&info->args, &opts) == -1) {
+#else
if (fuse_parse_cmdline(&info->args, &info->mountpoint, NULL, NULL) == -1) {
+#endif
derr << __func__ << " failed to parse args" << dendl;
return -EINVAL;
}
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
+ info->mountpoint = opts.mountpoint;
+ info->f = fuse_new(&info->args, &fs_oper, sizeof(fs_oper), (void*)this);
+ if (!info->f) {
+ derr << __func__ << " fuse_new failed" << dendl;
+ return -EIO;
+ }
+
+ rc = fuse_mount(info->f, info->mountpoint);
+ if (rc != 0) {
+ derr << __func__ << " fuse_mount failed" << dendl;
+ return -EIO;
+ }
+#else
info->ch = fuse_mount(info->mountpoint, &info->args);
if (!info->ch) {
derr << __func__ << " fuse_mount failed" << dendl;
derr << __func__ << " fuse_new failed" << dendl;
return -EIO;
}
+#endif
fuse_thread.create("fusestore");
dout(10) << __func__ << " done" << dendl;
int FuseStore::stop()
{
dout(10) << __func__ << " enter" << dendl;
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
+ fuse_unmount(info->f);
+#else
fuse_unmount(info->mountpoint, info->ch);
+#endif
fuse_thread.join();
fuse_destroy(info->f);
dout(10) << __func__ << " exit" << dendl;