diff options
author | Radek Podgorny <radek@podgorny.cz> | 2022-01-04 21:50:18 +0100 |
---|---|---|
committer | Radek Podgorny <radek@podgorny.cz> | 2022-01-04 21:50:18 +0100 |
commit | dc20e4723e2fce314da40c7f948979d366aa4b73 (patch) | |
tree | 956a7c6099d5a8db5b40b4430a3db8c71de57da6 | |
parent | 6e44e72cf8a908d7fcb9643b613df0e4a586bde4 (diff) | |
parent | 40eb7403b8d3e970f3452758c5bac734b78b0da5 (diff) | |
download | unionfs-fuse-git-dc20e4723e2fce314da40c7f948979d366aa4b73.tar.gz |
Merge branch 'fuse3'
-rw-r--r-- | .travis.yml | 12 | ||||
-rw-r--r-- | src/CMakeLists.txt | 26 | ||||
-rw-r--r-- | src/Makefile | 6 | ||||
-rw-r--r-- | src/fuse_ops.c | 61 | ||||
-rw-r--r-- | src/readdir.c | 15 | ||||
-rw-r--r-- | src/readdir.h | 7 | ||||
-rwxr-xr-x | test_vagrant_macos.sh | 7 | ||||
-rwxr-xr-x | test_vagrant_ubuntu.sh | 14 | ||||
-rwxr-xr-x | travis_install.sh | 13 |
9 files changed, 126 insertions, 35 deletions
diff --git a/.travis.yml b/.travis.yml index 9dbd5ae..104904a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,19 @@ sudo: required -dist: trusty +dist: focal language: python python: - - "3.5" + - "3.8" before_install: - sudo apt-get update -qq - - sudo apt-get install -qq pkg-config fuse + - sudo apt-get install -qq pkg-config fuse3 - sudo modprobe fuse - sudo chmod 666 /dev/fuse - sudo chown root:$USER /etc/fuse.conf install: - sudo apt-get install cmake make gcc - - sudo apt-get install -qq fuse libfuse-dev - - cmake . + - sudo apt-get install libfuse3-dev + #- sudo apt-get install meson ninja-build + #- ./travis_install.sh + #- cmake . - make script: ./test diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6802366..3e114f4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,24 +9,24 @@ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") SET(CMAKE_C_FLAGS_RELEASE "-O2") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG") -# this should not be needed anymore since we use pkg_check_modules (see below) -#if (UNIX AND APPLE) -# # Legacy include path for osxfuse -# include_directories("/usr/local/include/osxfuse/fuse") -# # New include path for MacFuse -# include_directories("/usr/local/include/fuse") -# link_directories("/usr/local/lib") -#endif() - -add_definitions(-DFUSE_USE_VERSION=30) - add_executable(unionfs ${UNIONFS_SRCS} ${HASHTABLE_SRCS}) +option(WITH_LIBFUSE3 "Enable libfuse3 support" ON) + find_package(PkgConfig REQUIRED) -pkg_check_modules(FUSE REQUIRED fuse) + +IF (WITH_LIBFUSE3) + add_definitions(-DFUSE_USE_VERSION=30) + pkg_check_modules(FUSE REQUIRED fuse3) +ELSE (WITH_LIBFUSE3) + add_definitions(-DFUSE_USE_VERSION=29) + pkg_check_modules(FUSE REQUIRED fuse) + target_link_libraries(unionfs pthread) +ENDIF (WITH_LIBFUSE3) + target_include_directories(unionfs PUBLIC ${FUSE_INCLUDE_DIRS}) target_compile_options(unionfs PUBLIC ${FUSE_CFLAGS_OTHER}) -target_link_libraries(unionfs ${FUSE_LIBRARIES} pthread) +target_link_libraries(unionfs ${FUSE_LIBRARIES}) add_executable(unionfsctl ${UNIONFSCTL_SRCS}) diff --git a/src/Makefile b/src/Makefile index 3300b84..a57a23e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ CFLAGS += -W -Wall -fPIC -CPPFLAGS += $(shell pkg-config --cflags fuse) -CPPFLAGS += -DFUSE_USE_VERSION=29 +CPPFLAGS += $(shell pkg-config --cflags fuse3) +CPPFLAGS += -DFUSE_USE_VERSION=30 CPPFLAGS += -DLIBC_XATTR # glibc nowadays includes xattr # CPPFLAGS += -DLIBATTR_XATTR # define this to libattr xattr include @@ -10,7 +10,7 @@ CPPFLAGS += -DLIBC_XATTR # glibc nowadays includes xattr LDFLAGS += -LIB = $(shell pkg-config --libs fuse) -lpthread +LIB = $(shell pkg-config --libs fuse3) HASHTABLE_OBJ = hashtable.o hashtable_itr.o LIBUNIONFS_OBJ = fuse_ops.o opts.o debug.o findbranch.o readdir.o \ diff --git a/src/fuse_ops.c b/src/fuse_ops.c index 8af0bfe..70f13ac 100644 --- a/src/fuse_ops.c +++ b/src/fuse_ops.c @@ -58,7 +58,14 @@ #include "conf.h" #include "uioctl.h" +#if FUSE_USE_VERSION < 30 static int unionfs_chmod(const char *path, mode_t mode) { +#else +static int unionfs_chmod(const char *path, mode_t mode, struct fuse_file_info *fi) { + // just to prevent the compiler complaining about unused variables + (void) fi; +#endif + DBG("%s\n", path); int i = find_rw_branch_cow(path); @@ -73,7 +80,14 @@ static int unionfs_chmod(const char *path, mode_t mode) { RETURN(0); } +#if FUSE_USE_VERSION < 30 static int unionfs_chown(const char *path, uid_t uid, gid_t gid) { +#else +static int unionfs_chown(const char *path, uid_t uid, gid_t gid, struct fuse_file_info *fi) { + // just to prevent the compiler complaining about unused variables + (void) fi; +#endif + DBG("%s\n", path); int i = find_rw_branch_cow(path); @@ -172,7 +186,14 @@ static int unionfs_fsync(const char *path, int isdatasync, struct fuse_file_info RETURN(0); } +#if FUSE_USE_VERSION < 30 static int unionfs_getattr(const char *path, struct stat *stbuf) { +#else +static int unionfs_getattr(const char *path, struct stat *stbuf, struct fuse_file_info *fi) { + // just to prevent the compiler complaining about unused variables + (void) fi; +#endif + DBG("%s\n", path); int i = find_rorw_branch(path); @@ -199,7 +220,11 @@ static int unionfs_getattr(const char *path, struct stat *stbuf) { static int unionfs_access(const char *path, int mask) { struct stat s; +#if FUSE_USE_VERSION < 30 if (unionfs_getattr(path, &s) != 0) +#else + if (unionfs_getattr(path, &s, NULL) != 0) +#endif RETURN(-ENOENT); if ((mask & X_OK) && (s.st_mode & S_IXUSR) == 0) @@ -218,7 +243,12 @@ static int unionfs_access(const char *path, int mask) { * init method * called before first access to the filesystem */ -static void * unionfs_init(struct fuse_conn_info *conn) { +#if FUSE_USE_VERSION < 30 +static void *unionfs_init(struct fuse_conn_info *conn) { +#else +static void *unionfs_init(struct fuse_conn_info *conn, struct fuse_config *cfg) { + (void) cfg; +#endif // just to prevent the compiler complaining about unused variables (void) conn; @@ -266,8 +296,11 @@ static int unionfs_link(const char *from, const char *to) { RETURN(0); } -#if FUSE_VERSION >= 28 +#if FUSE_USE_VERSION < 35 static int unionfs_ioctl(const char *path, int cmd, void *arg, struct fuse_file_info *fi, unsigned int flags, void *data) { +#else +static int unionfs_ioctl(const char *path, unsigned int cmd, void *arg, struct fuse_file_info *fi, unsigned int flags, void *data) { +#endif (void) path; (void) arg; // avoid compiler warning (void) fi; // avoid compiler warning @@ -304,7 +337,6 @@ static int unionfs_ioctl(const char *path, int cmd, void *arg, struct fuse_file_ return 0; } -#endif /** * unionfs mkdir() implementation @@ -449,7 +481,14 @@ static int unionfs_release(const char *path, struct fuse_file_info *fi) { * TODO: If we rename a directory on a read-only branch, we need to copy over * all files to the renamed directory on the read-write branch. */ +#if FUSE_USE_VERSION < 30 static int unionfs_rename(const char *from, const char *to) { +#else +static int unionfs_rename(const char *from, const char *to, unsigned int flags) { + // just to prevent the compiler complaining about unused variables + (void) flags; +#endif + DBG("from %s to %s\n", from, to); bool is_dir = false; // is 'from' a file or directory @@ -663,7 +702,14 @@ static int unionfs_symlink(const char *from, const char *to) { RETURN(0); } +#if FUSE_USE_VERSION < 30 static int unionfs_truncate(const char *path, off_t size) { +#else +static int unionfs_truncate(const char *path, off_t size, struct fuse_file_info *fi) { + // just to prevent the compiler complaining about unused variables + (void) fi; +#endif + DBG("%s\n", path); int i = find_rw_branch_cow(path); @@ -679,7 +725,14 @@ static int unionfs_truncate(const char *path, off_t size) { RETURN(0); } +#if FUSE_USE_VERSION < 30 static int unionfs_utimens(const char *path, const struct timespec ts[2]) { +#else +static int unionfs_utimens(const char *path, const struct timespec ts[2], struct fuse_file_info *fi) { + // just to prevent the compiler complaining about unused variables + (void) fi; +#endif + DBG("%s\n", path); int i = find_rw_branch_cow(path); @@ -815,9 +868,7 @@ struct fuse_operations unionfs_oper = { .getattr = unionfs_getattr, .access = unionfs_access, .init = unionfs_init, -#if FUSE_VERSION >= 28 .ioctl = unionfs_ioctl, -#endif .link = unionfs_link, .mkdir = unionfs_mkdir, .mknod = unionfs_mknod, diff --git a/src/readdir.c b/src/readdir.c index bbab6da..3c20007 100644 --- a/src/readdir.c +++ b/src/readdir.c @@ -110,11 +110,18 @@ static void read_whiteouts(const char *path, struct hashtable *whiteouts, int br /** * unionfs-fuse readdir function */ +#if FUSE_USE_VERSION < 30 int unionfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { +#else +int unionfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi, enum fuse_readdir_flags flags) { + (void) flags; +#endif + // just to prevent the compiler complaining about unused variables + (void) offset; + (void) fi; + DBG("%s\n", path); - (void)offset; - (void)fi; int i = 0; int rc = 0; @@ -173,7 +180,11 @@ int unionfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t o st.st_ino = de->d_ino; st.st_mode = de->d_type << 12; +#if FUSE_USE_VERSION < 30 if (filler(buf, de->d_name, &st, 0)) break; +#else + if (filler(buf, de->d_name, &st, 0, 0)) break; +#endif } closedir(dp); diff --git a/src/readdir.h b/src/readdir.h index cfbf227..688f90a 100644 --- a/src/readdir.h +++ b/src/readdir.h @@ -3,7 +3,12 @@ #include <fuse.h> -int unionfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi); +#if FUSE_USE_VERSION < 30 +int unionfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t off, struct fuse_file_info *fi); +#else +int unionfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t off, struct fuse_file_info *fi, enum fuse_readdir_flags flags); +#endif + int dir_not_empty(const char *path); #endif diff --git a/test_vagrant_macos.sh b/test_vagrant_macos.sh index 1b9eb56..f95d43a 100755 --- a/test_vagrant_macos.sh +++ b/test_vagrant_macos.sh @@ -1,6 +1,9 @@ #!/bin/sh set -e -x +# libfuse3 is disabled for macos since there's no support in macfuse +# see https://github.com/osxfuse/osxfuse/issues/390 + trap "vagrant destroy --force; rm -rf Vagrantfile" SIGINT SIGTERM ERR EXIT rm -rf Vagrantfile @@ -14,12 +17,14 @@ echo " set -e -x source .bashrc +uname -a + cd xxx rm -rf build mkdir build cd build -cmake .. +cmake .. -DWITH_LIBFUSE3=FALSE make python3 ../test_all.py diff --git a/test_vagrant_ubuntu.sh b/test_vagrant_ubuntu.sh index d7b2d28..401b762 100755 --- a/test_vagrant_ubuntu.sh +++ b/test_vagrant_ubuntu.sh @@ -11,24 +11,28 @@ vagrant up echo " set -e -x -sudo apt-get update -y -sudo apt-get install -y pkg-config fuse - -sudo modprobe fuse +uname -a -sudo apt-get install -y gcc make pkg-config cmake libfuse-dev +sudo apt-get update -y +sudo apt-get install -y gcc make pkg-config cmake fuse3 libfuse3-dev sudo apt-get install -y python3 python3-pip sudo pip install pytest +" | vagrant ssh + +echo " +set -e -x cp -av /vagrant /var/tmp/xxx cd /var/tmp/xxx +rm -rf build mkdir build cd build cmake .. make +sudo modprobe fuse python3 ../test_all.py " | vagrant ssh diff --git a/travis_install.sh b/travis_install.sh new file mode 100755 index 0000000..b604261 --- /dev/null +++ b/travis_install.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +FUSE_VER=3.10.3 +wget https://github.com/libfuse/libfuse/releases/download/fuse-${FUSE_VER}/fuse-${FUSE_VER}.tar.gz +tar xzf fuse-${FUSE_VER}.tar.gz +cd fuse-${FUSE_VER} +mkdir build +cd build +meson .. +ninja +sudo ninja install +test -e /usr/local/lib/pkgconfig || sudo mkdir /usr/local/lib/pkgconfig +sudo mv /usr/local/lib/*/pkgconfig/* /usr/local/lib/pkgconfig/ |