summaryrefslogtreecommitdiff
path: root/libfusepp
diff options
context:
space:
mode:
Diffstat (limited to 'libfusepp')
-rw-r--r--libfusepp/fuseapp.h89
1 files changed, 48 insertions, 41 deletions
diff --git a/libfusepp/fuseapp.h b/libfusepp/fuseapp.h
index bb18c02..d372655 100644
--- a/libfusepp/fuseapp.h
+++ b/libfusepp/fuseapp.h
@@ -56,51 +56,51 @@ class FuseAppBase {
virtual int fallocate(const char *, int, off_t, off_t, struct fuse_file_info *);
virtual int onError(const std::exception & err) throw();
-#define IFIMPL(func) typeid(&FuseAppBase::func) == typeid(&FuseApp::func) ? NULL :
+#define GetHelper(func) getHelper<&FuseAppBase::func>(typeid(&FuseAppBase::func) != typeid(&FuseApp::func))
template <typename FuseApp>
static int run(int & argc, char** & argv, FuseApp * fa)
{
auto args = runint(argc, argv, fa);
struct fuse_operations operations = {
- IFIMPL(getattr) fuseCall<const char *, struct stat *>::helper<&FuseAppBase::getattr>,
- IFIMPL(readlink) fuseCall<const char *, char *, size_t>::helper<&FuseAppBase::readlink>,
+ fuseCall<const char *, struct stat *>::GetHelper(getattr),
+ fuseCall<const char *, char *, size_t>::GetHelper(readlink),
NULL, // getdir deprecated
- IFIMPL(mknod) fuseCall<const char *, mode_t, dev_t>::helper<&FuseAppBase::mknod>,
- IFIMPL(mkdir) fuseCall<const char *, mode_t>::helper<&FuseAppBase::mkdir>,
- IFIMPL(unlink) fuseCall<const char *>::helper<&FuseAppBase::unlink>,
- IFIMPL(rmdir) fuseCall<const char *>::helper<&FuseAppBase::rmdir>,
- IFIMPL(symlink) fuseCall<const char *, const char *>::helper<&FuseAppBase::symlink>,
- IFIMPL(rename) fuseCall<const char *, const char *>::helper<&FuseAppBase::rename>,
- IFIMPL(link) fuseCall<const char *, const char *>::helper<&FuseAppBase::link>,
- IFIMPL(chmod) fuseCall<const char *, mode_t>::helper<&FuseAppBase::chmod>,
- IFIMPL(chown) fuseCall<const char *, uid_t, gid_t>::helper<&FuseAppBase::chown>,
- IFIMPL(truncate) fuseCall<const char *, off_t>::helper<&FuseAppBase::truncate>,
+ NULL, //fuseCall<const char *, mode_t, dev_t>::GetHelper(mknod),
+ fuseCall<const char *, mode_t>::GetHelper(mkdir),
+ fuseCall<const char *>::GetHelper(unlink),
+ fuseCall<const char *>::GetHelper(rmdir),
+ fuseCall<const char *, const char *>::GetHelper(symlink),
+ fuseCall<const char *, const char *>::GetHelper(rename),
+ fuseCall<const char *, const char *>::GetHelper(link),
+ fuseCall<const char *, mode_t>::GetHelper(chmod),
+ fuseCall<const char *, uid_t, gid_t>::GetHelper(chown),
+ fuseCall<const char *, off_t>::GetHelper(truncate),
NULL, // utime deprecated
- IFIMPL(open) fuseCall<const char *, struct fuse_file_info *>::helper<&FuseAppBase::open>,
- IFIMPL(read) fuseCall<const char *, char *, size_t, off_t, struct fuse_file_info *>::helper<&FuseAppBase::read>,
- IFIMPL(write) fuseCall<const char *, const char *, size_t, off_t, struct fuse_file_info *>::helper<&FuseAppBase::write>,
- IFIMPL(statfs) fuseCall<const char *, struct statvfs *>::helper<&FuseAppBase::statfs>,
- IFIMPL(flush) fuseCall<const char *, struct fuse_file_info *>::helper<&FuseAppBase::flush>,
- IFIMPL(release) fuseCall<const char *, struct fuse_file_info *>::helper<&FuseAppBase::release>,
- IFIMPL(fsync) fuseCall<const char *, int, struct fuse_file_info *>::helper<&FuseAppBase::fsync>,
- IFIMPL(setxattr) fuseCall<const char *, const char *, const char *, size_t, int>::helper<&FuseAppBase::setxattr>,
- IFIMPL(getxattr) fuseCall<const char *, const char *, char *, size_t>::helper<&FuseAppBase::getxattr>,
- IFIMPL(listxattr) fuseCall<const char *, char *, size_t>::helper<&FuseAppBase::listxattr>,
- IFIMPL(removexattr) fuseCall<const char *, const char *>::helper<&FuseAppBase::removexattr>,
- IFIMPL(opendir) fuseCall<const char *, struct fuse_file_info *>::helper<&FuseAppBase::opendir>,
- IFIMPL(readdir) fuseCall<const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *>::helper<&FuseAppBase::readdir>,
- IFIMPL(releasedir) fuseCall<const char *, struct fuse_file_info *>::helper<&FuseAppBase::releasedir>,
- IFIMPL(fsyncdir) fuseCall<const char *, int, struct fuse_file_info *>::helper<&FuseAppBase::fsyncdir>,
+ fuseCall<const char *, struct fuse_file_info *>::GetHelper(open),
+ fuseCall<const char *, char *, size_t, off_t, struct fuse_file_info *>::GetHelper(read),
+ fuseCall<const char *, const char *, size_t, off_t, struct fuse_file_info *>::GetHelper(write),
+ fuseCall<const char *, struct statvfs *>::GetHelper(statfs),
+ fuseCall<const char *, struct fuse_file_info *>::GetHelper(flush),
+ fuseCall<const char *, struct fuse_file_info *>::GetHelper(release),
+ fuseCall<const char *, int, struct fuse_file_info *>::GetHelper(fsync),
+ fuseCall<const char *, const char *, const char *, size_t, int>::GetHelper(setxattr),
+ fuseCall<const char *, const char *, char *, size_t>::GetHelper(getxattr),
+ fuseCall<const char *, char *, size_t>::GetHelper(listxattr),
+ fuseCall<const char *, const char *>::GetHelper(removexattr),
+ fuseCall<const char *, struct fuse_file_info *>::GetHelper(opendir),
+ fuseCall<const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *>::GetHelper(readdir),
+ fuseCall<const char *, struct fuse_file_info *>::GetHelper(releasedir),
+ fuseCall<const char *, int, struct fuse_file_info *>::GetHelper(fsyncdir),
fuseInit,
fuseDestroy,
- IFIMPL(access) fuseCall<const char *, int>::helper<&FuseAppBase::access>,
- IFIMPL(create) fuseCall<const char *, mode_t, struct fuse_file_info *>::helper<&FuseAppBase::create>,
- IFIMPL(fgetattr) fuseCall<const char *, off_t, struct fuse_file_info *>::helper<&FuseAppBase::ftruncate>,
- IFIMPL(fgetattr) fuseCall<const char *, struct stat *, struct fuse_file_info *>::helper<&FuseAppBase::fgetattr>,
+ fuseCall<const char *, int>::GetHelper(access),
+ fuseCall<const char *, mode_t, struct fuse_file_info *>::GetHelper(create),
+ fuseCall<const char *, off_t, struct fuse_file_info *>::GetHelper(ftruncate),
+ fuseCall<const char *, struct stat *, struct fuse_file_info *>::GetHelper(fgetattr),
#if (FUSE_MINOR_VERSION >= 6)
- IFIMPL(lock) fuseCall<const char *, struct fuse_file_info *, int, struct flock *>::helper<&FuseAppBase::lock>,
- IFIMPL(utimens) fuseCall<const char *, const struct timespec [2]>::helper<&FuseAppBase::utimens>,
- IFIMPL(bmap) fuseCall<const char *, size_t, uint64_t *>::helper<&FuseAppBase::bmap>,
+ fuseCall<const char *, struct fuse_file_info *, int, struct flock *>::GetHelper(lock),
+ fuseCall<const char *, const struct timespec [2]>::GetHelper(utimens),
+ fuseCall<const char *, size_t, uint64_t *>::GetHelper(bmap),
#if (FUSE_MINOR_VERSION >= 8)
0, // flag_nullpath_ok
#if (FUSE_MINOR_VERSION >= 9)
@@ -108,13 +108,13 @@ class FuseAppBase {
0, // flag_utime_omit_ok
#endif
0, // flag_reserved
- IFIMPL(ioctl) fuseCall<const char *, int, void *, struct fuse_file_info *, unsigned int, void *>::helper<&FuseAppBase::ioctl>,
- IFIMPL(poll) fuseCall<const char *, struct fuse_file_info *, struct fuse_pollhandle *, unsigned *>::helper<&FuseAppBase::poll>,
+ fuseCall<const char *, int, void *, struct fuse_file_info *, unsigned int, void *>::GetHelper(ioctl),
+ fuseCall<const char *, struct fuse_file_info *, struct fuse_pollhandle *, unsigned *>::GetHelper(poll),
#if (FUSE_MINOR_VERSION >= 9)
- IFIMPL(write_buf) fuseCall<const char *, struct fuse_bufvec *, off_t, struct fuse_file_info *>::helper<&FuseAppBase::write_buf>,
- IFIMPL(read_buf) fuseCall<const char *, struct fuse_bufvec **, size_t, off_t, struct fuse_file_info *>::helper<&FuseAppBase::read_buf>,
- IFIMPL(flock) fuseCall<const char *, struct fuse_file_info *, int>::helper<&FuseAppBase::flock>,
- IFIMPL(fallocate) fuseCall<const char *, int, off_t, off_t, struct fuse_file_info *>::helper<&FuseAppBase::fallocate>,
+ fuseCall<const char *, struct fuse_bufvec *, off_t, struct fuse_file_info *>::GetHelper(write_buf),
+ fuseCall<const char *, struct fuse_bufvec **, size_t, off_t, struct fuse_file_info *>::GetHelper(read_buf),
+ fuseCall<const char *, struct fuse_file_info *, int>::GetHelper(flock),
+ fuseCall<const char *, int, off_t, off_t, struct fuse_file_info *>::GetHelper(fallocate),
#endif
#endif
#endif
@@ -129,6 +129,13 @@ class FuseAppBase {
template <typename... Args>
class fuseCall {
public:
+ typedef int (*WrapperFunc)(Args...);
+ template <int (FuseAppBase::*b)(Args...)>
+ static WrapperFunc getHelper(bool implemented)
+ {
+ auto func = &helper<b>;
+ return implemented ? func : NULL;
+ }
template <int (FuseAppBase::*f)(Args...)>
static int helper(Args ... a)
{