Loading src/client/fuse/fuse_client.cpp +97 −45 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ passthrough_ll_help(void) { static void init_handler(void* userdata, struct fuse_conn_info* conn) { struct u_data* ud = (struct u_data*) userdata; if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "init handler readahead %i direct_io %i \n", ud->max_readahead, ud->direct_io); Loading Loading @@ -153,20 +154,24 @@ init_handler(void* userdata, struct fuse_conn_info* conn) { static void destroy_handler(void* userdata) { struct u_data* ud = (struct u_data*) userdata; if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "destroy handler \n"); // userdata is GekkoFuse* if passed } static void lookup_handler(fuse_req_t req, fuse_ino_t parent, const char* name) { fuse_log(FUSE_LOG_DEBUG, "lookup handler ino %u\n", parent); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "lookup handler ino %u\n", parent); auto* parent_inode = get_inode(parent); if(!parent_inode) { fuse_reply_err(req, ENOENT); return; } std::string child = get_path(parent_inode, name); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "lookup %s\n", child.c_str()); if(ud->fifo) { Loading Loading @@ -212,8 +217,10 @@ lookup_handler(fuse_req_t req, fuse_ino_t parent, const char* name) { static void getattr_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { fuse_log(FUSE_LOG_DEBUG, "getattr handler \n"); auto* ud = udata(req); if(ud->debug) { fuse_log(FUSE_LOG_DEBUG, "getattr handler \n"); } auto* inode = get_inode(ino); if(!inode) { fuse_reply_err(req, ENOENT); Loading @@ -223,6 +230,7 @@ getattr_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { struct stat st; int rc = gkfs::syscall::gkfs_stat(inode->path, &st); if(rc) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "getattr error %u\n", rc); fuse_reply_err(req, ENOENT); return; Loading @@ -234,8 +242,9 @@ getattr_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { static void setattr_handler(fuse_req_t req, fuse_ino_t ino, struct stat* attr, int to_set, struct fuse_file_info* fi) { fuse_log(FUSE_LOG_DEBUG, "setattr handler ino %u\n", ino); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "setattr handler ino %u\n", ino); auto* inode = get_inode(ino); if(!inode) { fuse_reply_err(req, ENOENT); Loading @@ -246,6 +255,7 @@ setattr_handler(fuse_req_t req, fuse_ino_t ino, struct stat* attr, int to_set, off_t new_size = attr->st_size; int res = gkfs::syscall::gkfs_truncate(inode->path, new_size); if(res < 0) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "setattr truncate failed on %s\n", inode->path.c_str()); fuse_reply_err(req, EIO); Loading @@ -268,8 +278,9 @@ setattr_handler(fuse_req_t req, fuse_ino_t ino, struct stat* attr, int to_set, static void open_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { fuse_log(FUSE_LOG_DEBUG, "open handler \n"); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "open handler \n"); auto* inode = get_inode(ino); if(!inode) { fuse_reply_err(req, ENOENT); Loading @@ -290,6 +301,8 @@ open_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { static void lseek_handler(fuse_req_t req, fuse_ino_t ino, off_t off, int whence, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "lseek handler \n"); int lc = gkfs::syscall::gkfs_lseek(fi->fh, off, whence); if(lc < 0) { Loading @@ -302,6 +315,8 @@ lseek_handler(fuse_req_t req, fuse_ino_t ino, off_t off, int whence, static void read_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "read handler \n"); auto* inode = get_inode(ino); if(!inode) { Loading @@ -311,6 +326,7 @@ read_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, std::vector<char> buf(size); int rc = gkfs::syscall::gkfs_pread(fi->fh, buf.data(), size, off); if(rc < 0) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "read fail \n"); fuse_reply_err(req, errno); return; Loading @@ -321,6 +337,8 @@ read_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, static void write_handler(fuse_req_t req, fuse_ino_t ino, const char* buf, size_t size, off_t off, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "write handler \n"); auto* inode = get_inode(ino); if(!inode) { Loading @@ -329,6 +347,7 @@ write_handler(fuse_req_t req, fuse_ino_t ino, const char* buf, size_t size, } int rc = gkfs::syscall::gkfs_pwrite(fi->fh, buf, size, off); if(rc < 0) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "write fail \n"); fuse_reply_err(req, errno); return; Loading @@ -346,9 +365,11 @@ create_handler(fuse_req_t req, fuse_ino_t parent, const char* name, mode_t mode, return; } std::string path = get_path(parent_inode, name); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "create handler %s\n", path.c_str()); int fd = gkfs::syscall::gkfs_open(path, mode, fi->flags | O_CREAT); if(fd < 0) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "create -> open failed errno %i\n", errno); fuse_reply_err(req, errno); return; Loading @@ -362,6 +383,7 @@ create_handler(fuse_req_t req, fuse_ino_t parent, const char* name, mode_t mode, return; } fuse_ino_t ino = alloc_inode(path); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "create new inode ino %i\n", ino); ino_map[ino].st = st; fuse_entry_param e = {}; Loading @@ -376,8 +398,9 @@ create_handler(fuse_req_t req, fuse_ino_t parent, const char* name, mode_t mode, /// problem? static void unlink_handler(fuse_req_t req, fuse_ino_t parent, const char* name) { fuse_log(FUSE_LOG_DEBUG, "unlink handler \n"); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "unlink handler \n"); auto* parent_inode = get_inode(parent); if(!parent_inode) { fuse_reply_err(req, ENOENT); Loading Loading @@ -411,6 +434,8 @@ unlink_handler(fuse_req_t req, fuse_ino_t parent, const char* name) { static void opendir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "opendir handler \n"); auto* inode = get_inode(ino); if(!inode) { Loading @@ -418,6 +443,7 @@ opendir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { return; } struct stat st; if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "open dir %s \n", inode->path.c_str()); if(gkfs::syscall::gkfs_stat(inode->path, &st) != 0 || S_ISREG(st.st_mode)) { fuse_reply_err(req, ENOTDIR); Loading Loading @@ -457,8 +483,9 @@ opendir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { static void readdir_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, struct fuse_file_info* fi) { fuse_log(FUSE_LOG_DEBUG, "readdir handler \n"); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "readdir handler \n"); auto* dir_ptr = reinterpret_cast<GkfsDir*>(fi->fh); if(!dir_ptr) { fuse_reply_err(req, EBADF); Loading @@ -467,6 +494,7 @@ readdir_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, auto open_dir = CTX->file_map()->get_dir(dir_ptr->fd); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "read dir %s \n", open_dir->path().c_str()); if(open_dir == nullptr) { Loading Loading @@ -541,6 +569,8 @@ readdir_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, static void releasedir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "releasedir handler \n"); GkfsDir* dir_ptr = reinterpret_cast<GkfsDir*>(fi->fh); if(CTX->interception_enabled() && CTX->file_map()->exist(dir_ptr->fd)) { Loading @@ -560,19 +590,24 @@ releasedir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { /// releases file descriptor, not connected to lookup_count static void release_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "release handler \n"); auto* inode = get_inode(ino); if(!inode) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "release here \n"); fuse_reply_err(req, ENOENT); return; } int lc = gkfs::syscall::gkfs_close(fi->fh); if(lc < 0) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "release there \n"); fuse_reply_err(req, 1); return; } if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "release success \n"); fuse_reply_err(req, 0); } Loading @@ -580,6 +615,8 @@ release_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { /// decrement lookup count static void forget_handler(fuse_req_t req, fuse_ino_t ino, uint64_t nlookup) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "forget handler \n"); auto it = ino_map.find(ino); Loading @@ -597,6 +634,7 @@ forget_handler(fuse_req_t req, fuse_ino_t ino, uint64_t nlookup) { if(inode.lookup_count == 0) { // && inode.open_count == 0 path_map.erase(inode.path); ino_map.erase(it); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "reached lookup_count 0 \n"); } Loading @@ -606,6 +644,8 @@ forget_handler(fuse_req_t req, fuse_ino_t ino, uint64_t nlookup) { static void flush_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "flush handler \n"); auto* inode = get_inode(ino); if(!inode) { Loading @@ -629,8 +669,9 @@ fsync_handler(fuse_req_t req, fuse_ino_t ino, int datasync, static void access_handler(fuse_req_t req, fuse_ino_t ino, int mask) { fuse_log(FUSE_LOG_DEBUG, "access handler \n"); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "access handler \n"); if(ud->access && !ud->fifo) { auto* inode = get_inode(ino); if(!inode) { Loading Loading @@ -660,6 +701,7 @@ mkdir_handler(fuse_req_t req, fuse_ino_t parent, const char* name, return; } std::string path = get_path(parent_inode, name); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "mkdir parent %s name %s\n", parent_inode->path.c_str(), name); int rc = gkfs::syscall::gkfs_create(path, mode | S_IFDIR); Loading @@ -670,11 +712,13 @@ mkdir_handler(fuse_req_t req, fuse_ino_t parent, const char* name, struct stat st; int sc = gkfs::syscall::gkfs_stat(path, &st); if(sc == -1) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "thats why its not allowed \n"); fuse_reply_err(req, 1); return; } fuse_ino_t ino = alloc_inode(path); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "create new inode ino %i\n", ino); ino_map[ino].st = st; fuse_entry_param e = {}; Loading @@ -687,12 +731,14 @@ mkdir_handler(fuse_req_t req, fuse_ino_t parent, const char* name, static void rmdir_handler(fuse_req_t req, fuse_ino_t parent, const char* name) { auto* ud = udata(req); auto* parent_inode = get_inode(parent); if(!parent_inode) { fuse_reply_err(req, ENOENT); return; } std::string path = get_path(parent_inode, name); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "rmdir %s\n", path.c_str()); int rc = gkfs::syscall::gkfs_rmdir(path); if(rc == -1) { Loading Loading @@ -732,11 +778,13 @@ static void symlink_handler(fuse_req_t req, const char* linkname, fuse_ino_t parent, const char* name) { #ifdef HAS_SYMLINKS fuse_log(FUSE_LOG_DEBUG, "symlink handler linkname %s name %s\n", linkname, name); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "symlink handler linkname %s name %s\n", linkname, name); auto* parent_inode = get_inode(parent); if(!parent_inode) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "symlink parent inode ino %i\n", parent); fuse_reply_err(req, ENOENT); return; Loading @@ -751,6 +799,7 @@ symlink_handler(fuse_req_t req, const char* linkname, fuse_ino_t parent, target.substr(strlen(ud->mountpoint)).c_str()); } if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "mk symlink path %s target %s\n", path.c_str(), target.c_str()); int rc = gkfs::syscall::gkfs_mk_symlink(path, target); Loading @@ -762,11 +811,14 @@ symlink_handler(fuse_req_t req, const char* linkname, fuse_ino_t parent, // Stat the new symlink so we can reply with entry info struct stat st; if(gkfs::syscall::gkfs_stat(path, &st) < 0) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "stat failed\n"); fuse_reply_err(req, errno); return; } fuse_log(FUSE_LOG_DEBUG, "stat mode %i, iflink %i\n", st.st_mode, S_IFLNK); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "stat mode %i, iflink %i\n", st.st_mode, S_IFLNK); // TODO this meta is not saved and therefore on restart gone // this shows the link on ls -l st.st_mode = S_IFLNK | 0777; // mark as symlink + full perms Loading Loading
src/client/fuse/fuse_client.cpp +97 −45 Original line number Diff line number Diff line Loading @@ -123,6 +123,7 @@ passthrough_ll_help(void) { static void init_handler(void* userdata, struct fuse_conn_info* conn) { struct u_data* ud = (struct u_data*) userdata; if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "init handler readahead %i direct_io %i \n", ud->max_readahead, ud->direct_io); Loading Loading @@ -153,20 +154,24 @@ init_handler(void* userdata, struct fuse_conn_info* conn) { static void destroy_handler(void* userdata) { struct u_data* ud = (struct u_data*) userdata; if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "destroy handler \n"); // userdata is GekkoFuse* if passed } static void lookup_handler(fuse_req_t req, fuse_ino_t parent, const char* name) { fuse_log(FUSE_LOG_DEBUG, "lookup handler ino %u\n", parent); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "lookup handler ino %u\n", parent); auto* parent_inode = get_inode(parent); if(!parent_inode) { fuse_reply_err(req, ENOENT); return; } std::string child = get_path(parent_inode, name); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "lookup %s\n", child.c_str()); if(ud->fifo) { Loading Loading @@ -212,8 +217,10 @@ lookup_handler(fuse_req_t req, fuse_ino_t parent, const char* name) { static void getattr_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { fuse_log(FUSE_LOG_DEBUG, "getattr handler \n"); auto* ud = udata(req); if(ud->debug) { fuse_log(FUSE_LOG_DEBUG, "getattr handler \n"); } auto* inode = get_inode(ino); if(!inode) { fuse_reply_err(req, ENOENT); Loading @@ -223,6 +230,7 @@ getattr_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { struct stat st; int rc = gkfs::syscall::gkfs_stat(inode->path, &st); if(rc) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "getattr error %u\n", rc); fuse_reply_err(req, ENOENT); return; Loading @@ -234,8 +242,9 @@ getattr_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { static void setattr_handler(fuse_req_t req, fuse_ino_t ino, struct stat* attr, int to_set, struct fuse_file_info* fi) { fuse_log(FUSE_LOG_DEBUG, "setattr handler ino %u\n", ino); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "setattr handler ino %u\n", ino); auto* inode = get_inode(ino); if(!inode) { fuse_reply_err(req, ENOENT); Loading @@ -246,6 +255,7 @@ setattr_handler(fuse_req_t req, fuse_ino_t ino, struct stat* attr, int to_set, off_t new_size = attr->st_size; int res = gkfs::syscall::gkfs_truncate(inode->path, new_size); if(res < 0) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "setattr truncate failed on %s\n", inode->path.c_str()); fuse_reply_err(req, EIO); Loading @@ -268,8 +278,9 @@ setattr_handler(fuse_req_t req, fuse_ino_t ino, struct stat* attr, int to_set, static void open_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { fuse_log(FUSE_LOG_DEBUG, "open handler \n"); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "open handler \n"); auto* inode = get_inode(ino); if(!inode) { fuse_reply_err(req, ENOENT); Loading @@ -290,6 +301,8 @@ open_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { static void lseek_handler(fuse_req_t req, fuse_ino_t ino, off_t off, int whence, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "lseek handler \n"); int lc = gkfs::syscall::gkfs_lseek(fi->fh, off, whence); if(lc < 0) { Loading @@ -302,6 +315,8 @@ lseek_handler(fuse_req_t req, fuse_ino_t ino, off_t off, int whence, static void read_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "read handler \n"); auto* inode = get_inode(ino); if(!inode) { Loading @@ -311,6 +326,7 @@ read_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, std::vector<char> buf(size); int rc = gkfs::syscall::gkfs_pread(fi->fh, buf.data(), size, off); if(rc < 0) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "read fail \n"); fuse_reply_err(req, errno); return; Loading @@ -321,6 +337,8 @@ read_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, static void write_handler(fuse_req_t req, fuse_ino_t ino, const char* buf, size_t size, off_t off, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "write handler \n"); auto* inode = get_inode(ino); if(!inode) { Loading @@ -329,6 +347,7 @@ write_handler(fuse_req_t req, fuse_ino_t ino, const char* buf, size_t size, } int rc = gkfs::syscall::gkfs_pwrite(fi->fh, buf, size, off); if(rc < 0) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "write fail \n"); fuse_reply_err(req, errno); return; Loading @@ -346,9 +365,11 @@ create_handler(fuse_req_t req, fuse_ino_t parent, const char* name, mode_t mode, return; } std::string path = get_path(parent_inode, name); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "create handler %s\n", path.c_str()); int fd = gkfs::syscall::gkfs_open(path, mode, fi->flags | O_CREAT); if(fd < 0) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "create -> open failed errno %i\n", errno); fuse_reply_err(req, errno); return; Loading @@ -362,6 +383,7 @@ create_handler(fuse_req_t req, fuse_ino_t parent, const char* name, mode_t mode, return; } fuse_ino_t ino = alloc_inode(path); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "create new inode ino %i\n", ino); ino_map[ino].st = st; fuse_entry_param e = {}; Loading @@ -376,8 +398,9 @@ create_handler(fuse_req_t req, fuse_ino_t parent, const char* name, mode_t mode, /// problem? static void unlink_handler(fuse_req_t req, fuse_ino_t parent, const char* name) { fuse_log(FUSE_LOG_DEBUG, "unlink handler \n"); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "unlink handler \n"); auto* parent_inode = get_inode(parent); if(!parent_inode) { fuse_reply_err(req, ENOENT); Loading Loading @@ -411,6 +434,8 @@ unlink_handler(fuse_req_t req, fuse_ino_t parent, const char* name) { static void opendir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "opendir handler \n"); auto* inode = get_inode(ino); if(!inode) { Loading @@ -418,6 +443,7 @@ opendir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { return; } struct stat st; if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "open dir %s \n", inode->path.c_str()); if(gkfs::syscall::gkfs_stat(inode->path, &st) != 0 || S_ISREG(st.st_mode)) { fuse_reply_err(req, ENOTDIR); Loading Loading @@ -457,8 +483,9 @@ opendir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { static void readdir_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, struct fuse_file_info* fi) { fuse_log(FUSE_LOG_DEBUG, "readdir handler \n"); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "readdir handler \n"); auto* dir_ptr = reinterpret_cast<GkfsDir*>(fi->fh); if(!dir_ptr) { fuse_reply_err(req, EBADF); Loading @@ -467,6 +494,7 @@ readdir_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, auto open_dir = CTX->file_map()->get_dir(dir_ptr->fd); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "read dir %s \n", open_dir->path().c_str()); if(open_dir == nullptr) { Loading Loading @@ -541,6 +569,8 @@ readdir_handler(fuse_req_t req, fuse_ino_t ino, size_t size, off_t off, static void releasedir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "releasedir handler \n"); GkfsDir* dir_ptr = reinterpret_cast<GkfsDir*>(fi->fh); if(CTX->interception_enabled() && CTX->file_map()->exist(dir_ptr->fd)) { Loading @@ -560,19 +590,24 @@ releasedir_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { /// releases file descriptor, not connected to lookup_count static void release_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "release handler \n"); auto* inode = get_inode(ino); if(!inode) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "release here \n"); fuse_reply_err(req, ENOENT); return; } int lc = gkfs::syscall::gkfs_close(fi->fh); if(lc < 0) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "release there \n"); fuse_reply_err(req, 1); return; } if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "release success \n"); fuse_reply_err(req, 0); } Loading @@ -580,6 +615,8 @@ release_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { /// decrement lookup count static void forget_handler(fuse_req_t req, fuse_ino_t ino, uint64_t nlookup) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "forget handler \n"); auto it = ino_map.find(ino); Loading @@ -597,6 +634,7 @@ forget_handler(fuse_req_t req, fuse_ino_t ino, uint64_t nlookup) { if(inode.lookup_count == 0) { // && inode.open_count == 0 path_map.erase(inode.path); ino_map.erase(it); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "reached lookup_count 0 \n"); } Loading @@ -606,6 +644,8 @@ forget_handler(fuse_req_t req, fuse_ino_t ino, uint64_t nlookup) { static void flush_handler(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info* fi) { auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "flush handler \n"); auto* inode = get_inode(ino); if(!inode) { Loading @@ -629,8 +669,9 @@ fsync_handler(fuse_req_t req, fuse_ino_t ino, int datasync, static void access_handler(fuse_req_t req, fuse_ino_t ino, int mask) { fuse_log(FUSE_LOG_DEBUG, "access handler \n"); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "access handler \n"); if(ud->access && !ud->fifo) { auto* inode = get_inode(ino); if(!inode) { Loading Loading @@ -660,6 +701,7 @@ mkdir_handler(fuse_req_t req, fuse_ino_t parent, const char* name, return; } std::string path = get_path(parent_inode, name); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "mkdir parent %s name %s\n", parent_inode->path.c_str(), name); int rc = gkfs::syscall::gkfs_create(path, mode | S_IFDIR); Loading @@ -670,11 +712,13 @@ mkdir_handler(fuse_req_t req, fuse_ino_t parent, const char* name, struct stat st; int sc = gkfs::syscall::gkfs_stat(path, &st); if(sc == -1) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "thats why its not allowed \n"); fuse_reply_err(req, 1); return; } fuse_ino_t ino = alloc_inode(path); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "create new inode ino %i\n", ino); ino_map[ino].st = st; fuse_entry_param e = {}; Loading @@ -687,12 +731,14 @@ mkdir_handler(fuse_req_t req, fuse_ino_t parent, const char* name, static void rmdir_handler(fuse_req_t req, fuse_ino_t parent, const char* name) { auto* ud = udata(req); auto* parent_inode = get_inode(parent); if(!parent_inode) { fuse_reply_err(req, ENOENT); return; } std::string path = get_path(parent_inode, name); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "rmdir %s\n", path.c_str()); int rc = gkfs::syscall::gkfs_rmdir(path); if(rc == -1) { Loading Loading @@ -732,11 +778,13 @@ static void symlink_handler(fuse_req_t req, const char* linkname, fuse_ino_t parent, const char* name) { #ifdef HAS_SYMLINKS fuse_log(FUSE_LOG_DEBUG, "symlink handler linkname %s name %s\n", linkname, name); auto* ud = udata(req); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "symlink handler linkname %s name %s\n", linkname, name); auto* parent_inode = get_inode(parent); if(!parent_inode) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "symlink parent inode ino %i\n", parent); fuse_reply_err(req, ENOENT); return; Loading @@ -751,6 +799,7 @@ symlink_handler(fuse_req_t req, const char* linkname, fuse_ino_t parent, target.substr(strlen(ud->mountpoint)).c_str()); } if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "mk symlink path %s target %s\n", path.c_str(), target.c_str()); int rc = gkfs::syscall::gkfs_mk_symlink(path, target); Loading @@ -762,11 +811,14 @@ symlink_handler(fuse_req_t req, const char* linkname, fuse_ino_t parent, // Stat the new symlink so we can reply with entry info struct stat st; if(gkfs::syscall::gkfs_stat(path, &st) < 0) { if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "stat failed\n"); fuse_reply_err(req, errno); return; } fuse_log(FUSE_LOG_DEBUG, "stat mode %i, iflink %i\n", st.st_mode, S_IFLNK); if(ud->debug) fuse_log(FUSE_LOG_DEBUG, "stat mode %i, iflink %i\n", st.st_mode, S_IFLNK); // TODO this meta is not saved and therefore on restart gone // this shows the link on ls -l st.st_mode = S_IFLNK | 0777; // mark as symlink + full perms Loading