Commit d79429bd authored by Julius Athenstaedt's avatar Julius Athenstaedt
Browse files

fuse: create direct with open and inode cleanup in rmdir and unlink

parent 289f6d8a
Loading
Loading
Loading
Loading
+21 −10
Original line number Diff line number Diff line
@@ -341,17 +341,17 @@ create_handler(fuse_req_t req, fuse_ino_t parent, const char* name, mode_t mode,
    }
    std::string path = get_path(parent_inode, name);
    fuse_log(FUSE_LOG_DEBUG, "create handler %s\n", path.c_str());
    int rc = gkfs::syscall::gkfs_create(path, mode);
    int errno_bu = errno;
    if(rc == -1) {
        fuse_log(FUSE_LOG_DEBUG,
                 "create failed, here here mode %i flags %i errno %i\n", mode,
                 fi->flags, errno);
    }
    int fd = gkfs::syscall::gkfs_open(path, mode, fi->flags);
    // int rc = gkfs::syscall::gkfs_create(path, mode);
    // int errno_bu = errno;
    // if(rc == -1) {
    //     fuse_log(FUSE_LOG_DEBUG,
    //              "create failed, here here mode %i flags %i errno %i\n", mode,
    //              fi->flags, errno);
    // }
    int fd = gkfs::syscall::gkfs_open(path, mode, fi->flags | O_CREAT);
    if(fd < 0) {
        fuse_log(FUSE_LOG_DEBUG, "create -> open failed errno\n", errno);
        fuse_reply_err(req, rc < 0 ? errno_bu : ENOENT);
        fuse_log(FUSE_LOG_DEBUG, "create -> open failed errno %i\n", errno);
        fuse_reply_err(req, errno);
        return;
    }
    fi->fh = fd;
@@ -398,6 +398,11 @@ unlink_handler(fuse_req_t req, fuse_ino_t parent, const char* name) {
    }

    int rc = gkfs::syscall::gkfs_remove(path);
    auto it_src = path_map.find(path);
    if(it_src != path_map.end()) {
        path_map.erase(it_src);
        ino_map.erase(it_src->second);
    }
    if(rc == -1) {
        fuse_reply_err(req, 1);
        return;
@@ -689,11 +694,17 @@ rmdir_handler(fuse_req_t req, fuse_ino_t parent, const char* name) {
        return;
    }
    std::string path = get_path(parent_inode, name);
    fuse_log(FUSE_LOG_DEBUG, "rmdir  %s\n", path.c_str());
    int rc = gkfs::syscall::gkfs_rmdir(path);
    if(rc == -1) {
        fuse_reply_err(req, errno);
        return;
    }
    auto it_src = path_map.find(path);
    if(it_src != path_map.end()) {
        path_map.erase(it_src);
        ino_map.erase(it_src->second);
    }
    fuse_reply_err(req, 0);
}