Commit 33d1d6e9 authored by Marc Vef's avatar Marc Vef
Browse files

c++14 is now used. playing around with pointers, using logging

parent 96e2746c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
project(fs VERSION 0.0.1)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall --pedantic -g")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
+1 −0
Original line number Diff line number Diff line
@@ -7,4 +7,5 @@

int adafs_getattr(const char *path, struct stat *attr);
void *adafs_init(struct fuse_conn_info *conn);
void adafs_destroy(void *);
#endif //FS_FUSE_OPS_H
+13 −6
Original line number Diff line number Diff line
@@ -36,20 +36,26 @@ int adafs_getattr(const char *path, struct stat *attr){
        attr->st_mode = S_IFREG | 0755;
        attr->st_nlink = 1;
        attr->st_size = strlen("blubb");
        ADAFS_DATA->logger->info(ADAFS_DATA->rootdir);
        return 0;
    }
    return -ENOENT;
}

void *adafs_init(struct fuse_conn_info *conn) {

    return ADAFS_DATA;
}

void adafs_destroy(void *adafs_data) {
    delete ADAFS_DATA;
}


static void init_adafs_ops(fuse_operations *ops) {
    ops->getattr = adafs_getattr;

    ops->init = adafs_init;
    ops->destroy = adafs_destroy;
}


@@ -59,14 +65,15 @@ int main(int argc, char *argv[]) {
    //Initialize the mapping of Fuse functions
    init_adafs_ops(&adafs_ops);

    // create the adafs_data object (struct)
    auto a_data = std::make_shared<adafs_data>();


    //set the logger and initialize it with spdlog
    a_data->logger = spdlog::basic_logger_mt("basic_logger", "adafs.log");
    //extract the rootdir from argv and put it into rootdir of adafs_data
    a_data->rootdir = std::string(realpath(argv[argc-2], NULL));

    argv[argc-2] = argv[argc-1];
    argv[argc-1] = NULL;
    argc--;

    return fuse_main(argc, argv, &adafs_ops, &a_data);
    //init fuse and give the private data for further reference.
    return fuse_main(argc, argv, &adafs_ops, a_data.get());
}
+3 −2
Original line number Diff line number Diff line
@@ -9,10 +9,11 @@

#include <fuse/fuse.h>
#include <string>
#include "spdlog/spdlog.h"

struct adafs_data {
    std::string         rootdir;
    FILE            *logfile;
    std::shared_ptr<spdlog::logger>       logger;
};

#define ADAFS_DATA ((struct adafs_data*) fuse_get_context()->private_data)