Commit c0a072a1 authored by Marc Vef's avatar Marc Vef
Browse files

Migration to Fuse3

parent f46ec7a0
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
# Try to find fuse (devel)
# Once done, this will define
#
# FUSE3_FOUND - system has fuse
# FUSE3_INCLUDE_DIRS - the fuse include directories
# FUSE3_LIBRARIES - fuse libraries directories

if(FUSE3_INCLUDE_DIRS AND FUSE3_LIBRARIES)
    set(FUSE3_FIND_QUIETLY TRUE)
endif(FUSE3_INCLUDE_DIRS AND FUSE3_LIBRARIES)

find_path( FUSE3_INCLUDE_DIR fuse3/fuse_lowlevel.h
        HINTS
        /usr
        /usr/local
        ${FUSE3_DIR}
        PATH_SUFFIXES include )

find_library( FUSE3_LIBRARY fuse3
        HINTS
        /usr
        /usr/local
        ${FUSE3_DIR}
        PATH_SUFFIXES lib )

set(FUSE3_INCLUDE_DIRS ${FUSE3_INCLUDE_DIR})
set(FUSE3_LIBRARIES ${FUSE3_LIBRARY})

# handle the QUIETLY and REQUIRED arguments and set FUSE3_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(fuse3 DEFAULT_MSG FUSE3_INCLUDE_DIR FUSE3_LIBRARY)

mark_as_advanced(FUSE3_INCLUDE_DIR FUSE3_LIBRARY)
 No newline at end of file
+3 −3
Original line number Diff line number Diff line
@@ -10,12 +10,12 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
find_package(FUSE REQUIRED)
find_package(FUSE3 REQUIRED)

# boost dependencies #TODO VERSION UNTESTED. I USE 1.62
find_package(Boost 1.56.0 COMPONENTS system filesystem serialization)

include_directories(${FUSE_INCLUDE_DIR} include/)
include_directories(${FUSE3_INCLUDE_DIR} include/)
set(SOURCE_FILES src/main.cpp src/main.h src/fuse_ops.h src/util.cpp src/metadata.h src/metadata.cpp src/metadata_ops.h src/metadata_ops.cpp)
add_executable(adafs ${SOURCE_FILES} src/main.cpp)
target_link_libraries(adafs ${FUSE_LIBRARIES} -lpthread -lboost_system -lboost_filesystem -lboost_serialization)
 No newline at end of file
target_link_libraries(adafs ${FUSE3_LIBRARIES} -lpthread -lboost_system -lboost_filesystem -lboost_serialization)
 No newline at end of file
+5 −2
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ using namespace std;

//std::shared_ptr<Metadata> md;

int adafs_getattr(const char *path, struct stat *attr){
int adafs_getattr(const char *path, struct stat *attr, struct fuse_file_info *fi){
    auto fpath = util::adafs_fullpath("meta/inodes"s);
    auto md = make_shared<Metadata>();
    md->mode(S_IFDIR | 0755);
@@ -39,7 +39,7 @@ int adafs_getattr(const char *path, struct stat *attr){
    return -ENOENT;
}

void *adafs_init(struct fuse_conn_info *conn) {
void *adafs_init(struct fuse_conn_info *conn, struct fuse_config *cfg) {

//    ADAFS_DATA->logger->info("init function"s);
//    ADAFS_DATA->logger->info("uid_: {}", fuse_get_context()->uid);
@@ -50,6 +50,7 @@ void *adafs_init(struct fuse_conn_info *conn) {
    boost::filesystem::create_directories(ADAFS_DATA->rootdir + "/meta/dentries"s);
    boost::filesystem::create_directories(ADAFS_DATA->rootdir + "/meta/inodes"s);
    boost::filesystem::create_directories(ADAFS_DATA->rootdir + "/data/chunks"s);
    cfg->use_ino = 1;
    //Init file system configuration
    ADAFS_DATA->blocksize = 4096;

@@ -98,5 +99,7 @@ int main(int argc, char *argv[]) {
    argv[argc-1] = NULL;
    argc--;
    //init fuse and give the private data for further reference.
    //print version
    cout << "Fuse library version: "s + to_string(FUSE_MAJOR_VERSION) + to_string(FUSE_MINOR_VERSION) << endl;
    return fuse_main(argc, argv, &adafs_ops, a_data.get());
}
+3 −2
Original line number Diff line number Diff line
@@ -5,9 +5,10 @@
#ifndef MAIN_H
#define MAIN_H

#define FUSE_USE_VERSION 26
#define FUSE_USE_VERSION 30

#include <fuse/fuse.h>

#include <fuse3/fuse.h>
#include <string>
#include <iostream>
#include <cstdint>