Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gburca/rofs-filtered
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: wfrisch/rofs-filtered
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Apr 5, 2023

  1. upgrade to FUSE v3

    wfrisch committed Apr 5, 2023
    Copy the full SHA
    38d7eb6 View commit details
  2. update README (fuse3)

    wfrisch committed Apr 5, 2023
    Copy the full SHA
    4f410c0 View commit details
  3. Update README.md

    wfrisch authored Apr 5, 2023
    Copy the full SHA
    6ae4693 View commit details
Showing with 68 additions and 61 deletions.
  1. +4 −4 CMakeLists.txt
  2. +7 −5 README.md
  3. +0 −33 cmake/FindFUSE.cmake
  4. +36 −0 cmake/Findfuse3.cmake
  5. +21 −19 rofs-filtered.c
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -10,11 +10,11 @@ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/InstallIf.cmake)

add_definitions(-D_GNU_SOURCE)
set(CMAKE_C_FLAGS "-Wall -std=c99")
set(CMAKE_C_FLAGS "-Wall -std=c11")

# find fuse library
find_package (FUSE REQUIRED)
include_directories (${FUSE_INCLUDE_DIR})
find_package (fuse3 REQUIRED)
include_directories (${FUSE3_INCLUDE_DIR})
add_definitions(-D_FILE_OFFSET_BITS=64)

# generate config file
@@ -25,7 +25,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})

# create and configure targets
add_executable(rofs-filtered rofs-filtered.c)
target_link_libraries(rofs-filtered ${FUSE_LIBRARIES})
target_link_libraries(rofs-filtered ${FUSE3_LIBRARY})

# configure installation
install(TARGETS rofs-filtered DESTINATION ${CMAKE_INSTALL_BINDIR})
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[![Build Status](https://travis-ci.org/gburca/rofs-filtered.svg?branch=master)](https://travis-ci.org/gburca/rofs-filtered)
[![Coverity](https://scan.coverity.com/projects/11175/badge.svg)](https://scan.coverity.com/projects/gburca-rofs-filtered)
Forked from [gburca/rofs-filtered](https://github.com/gburca/rofs-filtered) with changes:
* upgrade to FUSE v3

------------------------------------------------------------------------

This FUSE file system allows the user to mount a directory tree as read-only
and filter the files shown in the read-only directory tree based on regular
@@ -25,10 +27,10 @@ Get the latest version from:


### Dependencies:
* libfuse2
* libfuse-dev
* libfuse3
* libfuse3-dev
* fuse
* Version 2.5 or later of FUSE is required.
* Version 3.1 or later of FUSE is required.


### Building:
33 changes: 0 additions & 33 deletions cmake/FindFUSE.cmake

This file was deleted.

36 changes: 36 additions & 0 deletions cmake/Findfuse3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Try to find fuse (devel)
# Once done, this will define
#
# FUSE3_FOUND - system has fuse
#
# and the following imported target
#
# FUSE3::FUSE3

find_path(FUSE3_INCLUDE_DIR
NAMES fuse3/fuse_lowlevel.h
HINTS ${FUSE3_ROOT})

find_library(FUSE3_LIBRARY
NAMES fuse3
HINTS ${FUSE3_ROOT}
PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(fuse3
REQUIRED_VARS FUSE3_LIBRARY FUSE3_INCLUDE_DIR)

if (FUSE3_FOUND AND NOT TARGET FUSE3::FUSE3)
mark_as_advanced(FUSE3_INCLUDE_DIR FUSE3_LIBRARY)
add_library(FUSE3::FUSE3 UNKNOWN IMPORTED)
set_target_properties(FUSE3::FUSE3 PROPERTIES
IMPORTED_LOCATION "${FUSE3_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${FUSE3_INCLUDE_DIR}"
INTERFACE_COMPILE_DEFINITIONS "USE_FUSE3=1")
else()
message(WARNING "Notice: fuse3 not found, no fuse3 support")
add_library(FUSE3::FUSE3 INTERFACE IMPORTED)
endif()

unset(FUSE3_INCLUDE_DIR)
unset(FUSE3_LIBRARY)
40 changes: 21 additions & 19 deletions rofs-filtered.c
Original file line number Diff line number Diff line change
@@ -67,11 +67,7 @@
#define lsetxattr(path, name, value, size, flags) (setxattr(path, name, value, size, 0, flags | XATTR_NOFOLLOW))
#endif

// We depend on version 2.5 of FUSE because it provides an "access" callback.
// Some applications would call "access" and figure out a file is writable
// (which was the default behavior of "access" prior to 2.5), then attempt to
// open the file "rw", fail, and bomb out because of the conflicting info.
#define FUSE_USE_VERSION 25
#define FUSE_USE_VERSION 31

#include <sys/types.h>
#include <sys/stat.h>
@@ -87,7 +83,7 @@
#include <sys/xattr.h>
#include <regex.h>
#include <syslog.h>
#include <fuse.h>
#include <fuse3/fuse.h>

// AC_HEADER_STDC
#include <stdlib.h>
@@ -421,7 +417,8 @@ static int should_hide(const char *name, mode_t mode) {
*
******************************/

static int callback_getattr(const char *path, struct stat *st_data) {
static int callback_getattr(const char *path, struct stat *st_data, struct fuse_file_info *finfo) {
(void)finfo;
char *trpath=translate_path(path);
if (!trpath) {
errno = ENOMEM;
@@ -462,7 +459,7 @@ static int callback_readlink(const char *path, char *buf, size_t size) {
}

static int callback_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi)
off_t offset, struct fuse_file_info *fi, enum fuse_readdir_flags)
{
if (should_hide(path, S_IFREG)) return -ENOENT;

@@ -526,7 +523,7 @@ static int callback_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
memset(&st, 0, sizeof(st));
st.st_ino = de->d_ino;
st.st_mode = de->d_type << 12;
if (filler(buf, de->d_name, &st, 0))
if (filler(buf, de->d_name, &st, 0, 0))
break;
}

@@ -566,11 +563,12 @@ static int callback_symlink(const char *from, const char *to)
return -EPERM;
}

static int callback_rename(const char *from, const char *to) {
static int callback_rename(const char *from, const char *to, unsigned int flags) {
if (should_hide(from, S_IFREG)) return -ENOENT;

(void)from;
(void)to;
(void)flags;
return -EPERM;
}

@@ -582,35 +580,39 @@ static int callback_link(const char *from, const char *to) {
return -EPERM;
}

static int callback_chmod(const char *path, mode_t mode) {
static int callback_chmod(const char *path, mode_t mode, struct fuse_file_info *finfo) {
if (should_hide(path, S_IFREG)) return -ENOENT;

(void)path;
(void)mode;
(void)finfo;
return -EPERM;
}

static int callback_chown(const char *path, uid_t uid, gid_t gid) {
static int callback_chown(const char *path, uid_t uid, gid_t gid, struct fuse_file_info *finfo) {
if (should_hide(path, S_IFREG)) return -ENOENT;

(void)path;
(void)uid;
(void)gid;
(void)finfo;
return -EPERM;
}

static int callback_truncate(const char *path, off_t size) {
static int callback_truncate(const char *path, off_t size, struct fuse_file_info *finfo) {
if (should_hide(path, S_IFREG)) return -ENOENT;

(void)path;
(void)size;
(void)finfo;
return -EPERM;
}

static int callback_utime(const char *path, struct utimbuf *buf)
static int callback_utimens(const char *path, const struct timespec tv[2], struct fuse_file_info *finfo)
{
(void)path;
(void)buf;
(void)tv;
(void)finfo;
return -EPERM;
}

@@ -895,7 +897,7 @@ struct fuse_operations callback_oper = {
.chmod = callback_chmod,
.chown = callback_chown,
.truncate = callback_truncate,
.utime = callback_utime,
.utimens = callback_utimens,
.open = callback_open,
.read = callback_read,
.write = callback_write,
@@ -948,14 +950,14 @@ static int rofs_opt_proc(void *data, const char *arg, int key, struct fuse_args
, outargs->argv[0], default_config_file);
// Let fuse print out its help text as well...
fuse_opt_add_arg(outargs, "-ho");
fuse_main(outargs->argc, outargs->argv, &callback_oper);
fuse_main(outargs->argc, outargs->argv, &callback_oper, NULL);
exit(1);

case KEY_VERSION:
fprintf(stderr, "%s version: %s\n", EXEC_NAME, PACKAGE_VERSION);
// Let fuse also print its version
fuse_opt_add_arg(outargs, "--version");
fuse_main(outargs->argc, outargs->argv, &callback_oper);
fuse_main(outargs->argc, outargs->argv, &callback_oper, NULL);
exit(0);

case KEY_DEBUG:
@@ -994,5 +996,5 @@ int main(int argc, char *argv[]) {
exit(3);
}

return fuse_main(args.argc, args.argv, &callback_oper);
return fuse_main(args.argc, args.argv, &callback_oper, NULL);
}