diff --git a/Makefile b/Makefile index fb221a4f9..83f33382a 100644 --- a/Makefile +++ b/Makefile @@ -21,18 +21,19 @@ # THE SOFTWARE. PKGCONFIG = $(shell which pkg-config) -GIT = $(shell which git) -TAR = $(shell which tar) -MKDIR = $(shell which mkdir) -TOUCH = $(shell which touch) -CP = $(shell which cp) -RM = $(shell which rm) -FIND = $(shell which find) -INSTALL = $(shell which install) -MKTEMP = $(shell which mktemp) -STRIP = $(shell which strip) -PANDOC = $(shell which pandoc) +GIT = $(shell which git) +TAR = $(shell which tar) +MKDIR = $(shell which mkdir) +TOUCH = $(shell which touch) +CP = $(shell which cp) +RM = $(shell which rm) +FIND = $(shell which find) +INSTALL = $(shell which install) +MKTEMP = $(shell which mktemp) +STRIP = $(shell which strip) +PANDOC = $(shell which pandoc) GIT2DEBCL = ./tools/git2debcl +CPPFIND = ./tools/cppfind ifeq ($(PKGCONFIG),"") $(error "pkg-config not installed" @@ -54,23 +55,35 @@ ifeq ($(FUSE_AVAILABLE),0) $(error "FUSE development package doesn't appear available") endif -OPTS = -O2 -SRC = $(wildcard src/*.cpp) -OBJ = $(SRC:src/%.cpp=obj/%.o) -DEPS = $(OBJ:obj/%.o=obj/%.d) -TARGET = mergerfs -MANPAGE = $(TARGET).1 -CFLAGS = -g -Wall \ - $(OPTS) \ - $(shell $(PKGCONFIG) fuse --cflags) \ - -DFUSE_USE_VERSION=26 \ - -MMD -LDFLAGS = $(shell $(PKGCONFIG) fuse --libs) - -BINDIR = $(PREFIX)/usr/bin -MANDIR = $(PREFIX)/usr/share/man/man1 +FLAG_NOPATH = $(shell $(CPPFIND) "flag_nopath") +FALLOCATE = $(shell $(CPPFIND) "fuse_fs_fallocate") +FLOCK = $(shell $(CPPFIND) "fuse_fs_flock") +READ_BUF = $(shell $(CPPFIND) "fuse_fs_read_buf") +WRITE_BUF = $(shell $(CPPFIND) "fuse_fs_write_buf") + +OPTS = -O2 +SRC = $(wildcard src/*.cpp) +OBJ = $(SRC:src/%.cpp=obj/%.o) +DEPS = $(OBJ:obj/%.o=obj/%.d) +TARGET = mergerfs +MANPAGE = $(TARGET).1 +FUSE_CFLAGS = $(shell $(PKGCONFIG) --cflags fuse) +CFLAGS = -g -Wall \ + $(OPTS) \ + $(FUSE_CFLAGS) \ + -DFUSE_USE_VERSION=26 \ + -MMD \ + -DFLAG_NOPATH=$(FLAG_NOPATH) \ + -DFALLOCATE=$(FALLOCATE) \ + -DFLOCK=$(FLOCK) \ + -DREAD_BUF=$(READ_BUF) \ + -DWRITE_BUF=$(WRITE_BUF) +LDFLAGS = $(shell $(PKGCONFIG) fuse --libs) + +BINDIR = $(PREFIX)/usr/bin +MANDIR = $(PREFIX)/usr/share/man/man1 INSTALLTARGET = $(DESTDIR)/$(BINDIR)/$(TARGET) -MANTARGET = $(DESTDIR)/$(MANDIR)/$(MANPAGE) +MANTARGET = $(DESTDIR)/$(MANDIR)/$(MANPAGE) ifeq ($(XATTR_AVAILABLE),0) $(warning "xattr not available: disabling") diff --git a/src/fallocate.cpp b/src/fallocate.cpp index d2c4998f9..ca6982560 100644 --- a/src/fallocate.cpp +++ b/src/fallocate.cpp @@ -22,6 +22,8 @@ THE SOFTWARE. */ +#if FALLOCATE + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif @@ -82,3 +84,5 @@ namespace mergerfs } } } + +#endif diff --git a/src/init.cpp b/src/init.cpp index 8507ebc68..e532c1a5c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -33,7 +33,9 @@ namespace mergerfs void * init(struct fuse_conn_info *conn) { +#ifdef FUSE_CAP_IOCTL_DIR conn->want |= FUSE_CAP_IOCTL_DIR; +#endif return &config::get_writable(); } diff --git a/src/ioctl.cpp b/src/ioctl.cpp index de8cbb503..b30b7c3f3 100644 --- a/src/ioctl.cpp +++ b/src/ioctl.cpp @@ -80,6 +80,7 @@ _ioctl(const int fd, return ((rv == -1) ? -errno : rv); } +#ifdef FUSE_IOCTL_DIR static int _ioctl_dir_base(const fs::SearchFunc searchFunc, @@ -130,6 +131,7 @@ _ioctl_dir(const string fusepath, flags, data); } +#endif namespace mergerfs { @@ -145,12 +147,14 @@ namespace mergerfs { const FileInfo *fileinfo = (FileInfo*)ffi->fh; +#ifdef FUSE_IOCTL_DIR if(flags & FUSE_IOCTL_DIR) return _ioctl_dir(fusepath, cmd, arg, flags, data); +#endif return _ioctl(fileinfo->fd, cmd, diff --git a/src/mergerfs.cpp b/src/mergerfs.cpp index 06a3ecaa7..97abbddf8 100644 --- a/src/mergerfs.cpp +++ b/src/mergerfs.cpp @@ -76,9 +76,11 @@ static struct fuse_operations get_fuse_operations() { - struct fuse_operations ops = {}; + struct fuse_operations ops = {0}; +#if FLAG_NOPATH ops.flag_nopath = false; +#endif ops.flag_nullpath_ok = false; ops.access = mergerfs::access::access; @@ -87,9 +89,13 @@ get_fuse_operations() ops.chown = mergerfs::chown::chown; ops.create = mergerfs::create::create; ops.destroy = mergerfs::destroy::destroy; +#if FALLOCATE ops.fallocate = mergerfs::fallocate::fallocate; +#endif ops.fgetattr = mergerfs::fgetattr::fgetattr; +#if FLOCK ops.flock = NULL; +#endif ops.flush = mergerfs::flush::flush; ops.fsync = mergerfs::fsync::fsync; ops.fsyncdir = NULL; @@ -108,7 +114,9 @@ get_fuse_operations() ops.opendir = mergerfs::opendir::opendir; ops.poll = NULL; ops.read = mergerfs::read::read; +#if READ_BUF ops.read_buf = mergerfs::read_buf::read_buf; +#endif ops.readdir = mergerfs::readdir::readdir; ops.readlink = mergerfs::readlink::readlink; ops.release = mergerfs::release::release; @@ -124,7 +132,9 @@ get_fuse_operations() ops.utime = NULL; /* deprecated; use utimens() */ ops.utimens = mergerfs::utimens::utimens; ops.write = mergerfs::write::write; +#if WRITE_BUF ops.write_buf = mergerfs::write_buf::write_buf; +#endif return ops; } diff --git a/src/read_buf.cpp b/src/read_buf.cpp index a6094d2d7..79df8d384 100644 --- a/src/read_buf.cpp +++ b/src/read_buf.cpp @@ -22,6 +22,8 @@ THE SOFTWARE. */ +#if READ_BUF + #include #include @@ -72,3 +74,5 @@ namespace mergerfs } } } + +#endif diff --git a/src/write_buf.cpp b/src/write_buf.cpp index 9e0b8f488..7950a0931 100644 --- a/src/write_buf.cpp +++ b/src/write_buf.cpp @@ -22,6 +22,8 @@ THE SOFTWARE. */ +#if WRITE_BUF + #include #include @@ -63,3 +65,5 @@ namespace mergerfs } } } + +#endif diff --git a/tools/cppfind b/tools/cppfind new file mode 100755 index 000000000..e325c4382 --- /dev/null +++ b/tools/cppfind @@ -0,0 +1,7 @@ +#!/bin/bash + +FUSE_CFLAGS=$(pkg-config --cflags fuse) + +echo "#include " | cpp ${FUSE_CFLAGS} | grep -q "${1}" + +[ "$?" != "0" ]; echo $?