Commit 5e510a6a authored by Marc Vef's avatar Marc Vef
Browse files

Changed loglevel from info to debug. The latter is lower.

Info should be used for temporary develop messages
parent 7a52c56f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,5 +7,6 @@

// Uncomment to enabled logging with info level
#define LOG_INFO
//#define LOG_DEBUG

#endif //FS_CONFIGURE_H
+3 −6
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ using namespace std;
 * passed to readdir, closedir and fsyncdir.
 */
int adafs_opendir(const char* p, struct fuse_file_info* fi) {
    ADAFS_DATA->logger->info("FUSE: adafs_opendir() enter"s);
    ADAFS_DATA->logger->debug("FUSE: adafs_opendir() enter"s);
    // XXX error handling
    auto path = bfs::path(p);
    auto md = make_shared<Metadata>();
@@ -26,7 +26,7 @@ int adafs_opendir(const char* p, struct fuse_file_info* fi) {

    int access = fi->flags & O_ACCMODE;

//    ADAFS_DATA->logger->info("access variable: {}", access);
//    ADAFS_DATA->logger->debug("access variable: {}", access);
    switch (access) {
        case O_RDONLY:
            return chk_access(*md, R_OK);
@@ -58,10 +58,7 @@ int adafs_opendir(const char* p, struct fuse_file_info* fi) {
 */
int adafs_readdir(const char* p, void* buf, fuse_fill_dir_t filler, off_t offset,
                  struct fuse_file_info* fi, enum fuse_readdir_flags flags) {
    ADAFS_DATA->logger->info("FUSE: adafs_readdir() enter"s);
//    ADAFS_DATA->logger->info("FUSE: adafs_readdir(path=\"{}\", buf={}, offset={}", p, buf, offset);
//    ADAFS_DATA->logger->info("bb_readdir(path=\"%s\", buf=0x%08x, filler=0x%08x, offset=%lld, fi=0x%08x)",
//                             p, buf, filler, offset, fi);
    ADAFS_DATA->logger->debug("FUSE: adafs_readdir() enter"s);
    auto path = bfs::path(p);
    auto md = make_shared<Metadata>();
    // first check that dir exists that is trying to be read. I don't know if this is actually needed,
+2 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ int adafs_getattr(const char* p, struct stat* attr, struct fuse_file_info* fi) {
//    if (strcmp(p, "/file/file2") == 0) {
//        auto p_dir = make_shared<struct stat>();
//        lstat("/", p_dir.get());
//        ADAFS_DATA->logger->info(p_dir->st_ino);
//        ADAFS_DATA->logger->debug(p_dir->st_ino);
//        ADAFS_DATA->logger->flush();
//
//        attr->st_mode = S_IFREG | 0755;
@@ -55,6 +55,7 @@ int adafs_getattr(const char* p, struct stat* attr, struct fuse_file_info* fi) {
 * regular files that will be called instead.
 */
int adafs_mknod(const char* p, mode_t mode, dev_t dev) {
    ADAFS_DATA->logger->debug("FUSE: adafs_readdir() enter"s);


    return 0;
+3 −3
Original line number Diff line number Diff line
@@ -7,14 +7,14 @@
using namespace std;

int chk_access(const Metadata& md, const int mode) {
    ADAFS_DATA->logger->info("chk_access() enter: md.uid: {}, fusecontextuid: {}", md.uid(), fuse_get_context()->uid);
    ADAFS_DATA->logger->debug("chk_access() enter: md.uid: {}, fusecontextuid: {}", md.uid(), fuse_get_context()->uid);
    // root user is a god
    if (fuse_get_context()->uid == 0)
        return 0;

    //check user leftmost 3 bits for rwx in md->mode
    if (md.uid() == fuse_get_context()->uid) {
        ADAFS_DATA->logger->info("Metadata UID: {}, fuse context uid: {}, mode: {}",
        ADAFS_DATA->logger->debug("Metadata UID: {}, fuse context uid: {}, mode: {}",
                                 md.uid(), fuse_get_context()->uid, mode);
        // Because mode comes only with the first 3 bits used, the user bits have to be shifted to the right to compare
        if ((mode & md.mode() >> 6) == (unsigned int) mode)
@@ -25,7 +25,7 @@ int chk_access(const Metadata& md, const int mode) {

    //check group middle 3 bits for rwx in md->mode
    if (md.gid() == fuse_get_context()->gid) {
        ADAFS_DATA->logger->info("Metadata GID: {}, fuse context gid: {}, mode: {}",
        ADAFS_DATA->logger->debug("Metadata GID: {}, fuse context gid: {}, mode: {}",
                                 md.uid(), fuse_get_context()->gid, mode);
        if ((mode & md.mode() >> 3) == (unsigned int) mode)
            return 0;
+11 −8
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ static struct fuse_operations adafs_ops;
using namespace std;

void *adafs_init(struct fuse_conn_info *conn, struct fuse_config *cfg) {
    ADAFS_DATA->logger->info("Fuse init() enter"s);
    ADAFS_DATA->logger->debug("Fuse init() enter"s);
    // Make sure directory structure exists
    bfs::create_directories(ADAFS_DATA->dentry_path);
    bfs::create_directories(ADAFS_DATA->inode_path);
@@ -36,7 +36,7 @@ void *adafs_init(struct fuse_conn_info *conn, struct fuse_config *cfg) {

    // Check that root metadata exists. If not initialize it
    if (get_metadata(*md, "/"s) == -ENOENT) {
        ADAFS_DATA->logger->info("Root metadata not found. Initializing..."s);
        ADAFS_DATA->logger->debug("Root metadata not found. Initializing..."s);
        md->init_ACM_time();
        md->mode(S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO); // chmod 777
//        md->mode(S_IFDIR | 0755);
@@ -44,15 +44,15 @@ void *adafs_init(struct fuse_conn_info *conn, struct fuse_config *cfg) {
        md->uid(fuse_get_context()->uid);
        md->gid(fuse_get_context()->gid);
        md->inode_no(ADAFS_ROOT_INODE);
        ADAFS_DATA->logger->info("Writing / metadata to disk..."s);
        ADAFS_DATA->logger->debug("Writing / metadata to disk..."s);
        write_all_metadata(*md, ADAFS_DATA->hashf("/"s));
        ADAFS_DATA->logger->info("Initializing dentry for /"s);
        ADAFS_DATA->logger->debug("Initializing dentry for /"s);
        init_dentry(ADAFS_DATA->hashf("/"s));
        ADAFS_DATA->logger->info("Creating Metadata object"s);
        ADAFS_DATA->logger->debug("Creating Metadata object"s);
    }
#ifdef LOG_INFO
#ifdef LOG_DEBUG
    else
        ADAFS_DATA->logger->info("Metadata object exists"s);
        ADAFS_DATA->logger->debug("Metadata object exists"s);
#endif


@@ -94,7 +94,10 @@ int main(int argc, char *argv[]) {
    auto a_data = make_shared<adafs_data>();
    //set the logger and initialize it with spdlog
    a_data->logger = spdlog::basic_logger_mt("basic_logger", "adafs.log");
#ifdef LOG_INFO
#if defined(LOG_DEBUG)
    spdlog::set_level(spdlog::level::debug);
    a_data->logger->flush_on(spdlog::level::debug);
#elif defined(LOG_INFO)
    spdlog::set_level(spdlog::level::info);
    a_data->logger->flush_on(spdlog::level::info);
#else
Loading