Loading src/client/hooks.cpp +19 −20 Original line number Diff line number Diff line Loading @@ -93,23 +93,15 @@ hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { case gkfs::preload::RelativizeStatus::internal: { auto md_ = gkfs::utils::get_metadata(resolved); if(S_ISDIR(md_->mode())) { // if its a directory, it is handled without fuse // TODO this could cause problems in the filemap if a dir fd and // a file fd are overwriting each other return gkfs::syscall::gkfs_opendir(resolved); } else { // pass open to fuse to sync fd in file_map int fd = gsl::narrow_cast<int>(syscall_no_intercept_wrapper( SYS_openat, dirfd, cpath, flags, mode)); LOG(DEBUG, "{}() open passed to fuse fd: {}", __func__, fd); // should be the same fd CTX->file_map()->add( fd, std::make_shared<gkfs::filemap::OpenFile>(resolved, flags)); CTX->file_map()->add(fd, std::make_shared<gkfs::filemap::OpenFile>( resolved, flags)); return with_errno(fd); } } default: LOG(ERROR, "{}() relativize status unknown: {}", __func__); return -EINVAL; Loading @@ -121,11 +113,12 @@ hook_close(int fd) { LOG(DEBUG, "{}() called with fd: {}", __func__, fd); auto ret = gkfs::syscall::gkfs_close(fd); //auto ret = gkfs::syscall::gkfs_close(fd); CTX->file_map()->remove(fd); if(ret < 0) LOG(DEBUG, "{}() close failed with fd: {}, errno {}", __func__, fd, errno); //if(ret < 0) //LOG(DEBUG, "{}() close failed with fd: {}, errno {}", __func__, fd, //errno); // we also close the fd in fuse // TODO does this make inconsistency if both use gkfs_close? Loading Loading @@ -633,9 +626,12 @@ hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count) { LOG(DEBUG, "{}() called with fd: {}, dirp: {}, count: {}", __func__, fd, fmt::ptr(dirp), count); /* * dirs are handled in fuse if(CTX->file_map()->exist(fd)) { return with_errno(gkfs::syscall::gkfs_getdents(fd, dirp, count)); } */ return syscall_no_intercept_wrapper(SYS_getdents, fd, dirp, count); } #endif Loading @@ -647,9 +643,12 @@ hook_getdents64(unsigned int fd, struct linux_dirent64* dirp, LOG(DEBUG, "{}() called with fd: {}, dirp: {}, count: {}", __func__, fd, fmt::ptr(dirp), count); /* * dirs are handled in fuse if(CTX->file_map()->exist(fd)) { return with_errno(gkfs::syscall::gkfs_getdents64(fd, dirp, count)); } */ return syscall_no_intercept_wrapper(SYS_getdents64, fd, dirp, count); } Loading Loading
src/client/hooks.cpp +19 −20 Original line number Diff line number Diff line Loading @@ -93,23 +93,15 @@ hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { case gkfs::preload::RelativizeStatus::internal: { auto md_ = gkfs::utils::get_metadata(resolved); if(S_ISDIR(md_->mode())) { // if its a directory, it is handled without fuse // TODO this could cause problems in the filemap if a dir fd and // a file fd are overwriting each other return gkfs::syscall::gkfs_opendir(resolved); } else { // pass open to fuse to sync fd in file_map int fd = gsl::narrow_cast<int>(syscall_no_intercept_wrapper( SYS_openat, dirfd, cpath, flags, mode)); LOG(DEBUG, "{}() open passed to fuse fd: {}", __func__, fd); // should be the same fd CTX->file_map()->add( fd, std::make_shared<gkfs::filemap::OpenFile>(resolved, flags)); CTX->file_map()->add(fd, std::make_shared<gkfs::filemap::OpenFile>( resolved, flags)); return with_errno(fd); } } default: LOG(ERROR, "{}() relativize status unknown: {}", __func__); return -EINVAL; Loading @@ -121,11 +113,12 @@ hook_close(int fd) { LOG(DEBUG, "{}() called with fd: {}", __func__, fd); auto ret = gkfs::syscall::gkfs_close(fd); //auto ret = gkfs::syscall::gkfs_close(fd); CTX->file_map()->remove(fd); if(ret < 0) LOG(DEBUG, "{}() close failed with fd: {}, errno {}", __func__, fd, errno); //if(ret < 0) //LOG(DEBUG, "{}() close failed with fd: {}, errno {}", __func__, fd, //errno); // we also close the fd in fuse // TODO does this make inconsistency if both use gkfs_close? Loading Loading @@ -633,9 +626,12 @@ hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count) { LOG(DEBUG, "{}() called with fd: {}, dirp: {}, count: {}", __func__, fd, fmt::ptr(dirp), count); /* * dirs are handled in fuse if(CTX->file_map()->exist(fd)) { return with_errno(gkfs::syscall::gkfs_getdents(fd, dirp, count)); } */ return syscall_no_intercept_wrapper(SYS_getdents, fd, dirp, count); } #endif Loading @@ -647,9 +643,12 @@ hook_getdents64(unsigned int fd, struct linux_dirent64* dirp, LOG(DEBUG, "{}() called with fd: {}, dirp: {}, count: {}", __func__, fd, fmt::ptr(dirp), count); /* * dirs are handled in fuse if(CTX->file_map()->exist(fd)) { return with_errno(gkfs::syscall::gkfs_getdents64(fd, dirp, count)); } */ return syscall_no_intercept_wrapper(SYS_getdents64, fd, dirp, count); } Loading