Skip to content

Commit

Permalink
support RHEL6
Browse files Browse the repository at this point in the history
closes: #29
  • Loading branch information
trapexit committed Nov 4, 2014
1 parent 9245a22 commit 940ef36
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 28 deletions.
67 changes: 40 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions src/fallocate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
THE SOFTWARE.
*/

#if FALLOCATE

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
Expand Down Expand Up @@ -82,3 +84,5 @@ namespace mergerfs
}
}
}

#endif
2 changes: 2 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 4 additions & 0 deletions src/ioctl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -130,6 +131,7 @@ _ioctl_dir(const string fusepath,
flags,
data);
}
#endif

namespace mergerfs
{
Expand All @@ -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,
Expand Down
12 changes: 11 additions & 1 deletion src/mergerfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions src/read_buf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
THE SOFTWARE.
*/

#if READ_BUF

#include <fuse.h>

#include <stdlib.h>
Expand Down Expand Up @@ -72,3 +74,5 @@ namespace mergerfs
}
}
}

#endif
4 changes: 4 additions & 0 deletions src/write_buf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
THE SOFTWARE.
*/

#if WRITE_BUF

#include <fuse.h>

#include <stdlib.h>
Expand Down Expand Up @@ -63,3 +65,5 @@ namespace mergerfs
}
}
}

#endif
7 changes: 7 additions & 0 deletions tools/cppfind
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

FUSE_CFLAGS=$(pkg-config --cflags fuse)

echo "#include <fuse.h>" | cpp ${FUSE_CFLAGS} | grep -q "${1}"

[ "$?" != "0" ]; echo $?

0 comments on commit 940ef36

Please sign in to comment.