Loading src/client/hooks.cpp +26 −4 Original line number Diff line number Diff line Loading @@ -92,15 +92,20 @@ hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { return -ENOTDIR; case gkfs::preload::RelativizeStatus::internal: { auto md_ = gkfs::utils::get_metadata(resolved); struct stat st; syscall_no_intercept_wrapper( SYS_newfstatat, dirfd, ".", &st, AT_SYMLINK_NOFOLLOW); //auto md_ = gkfs::utils::get_metadata(resolved); // 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)); if(fd < 0) return fd; 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)); return with_errno(fd); return fd; } default: LOG(ERROR, "{}() relativize status unknown: {}", __func__); Loading @@ -110,6 +115,8 @@ hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { int hook_close(int fd) { if(fd == 0) return 0; LOG(DEBUG, "{}() called with fd: {}", __func__, fd); Loading Loading @@ -673,10 +680,25 @@ hook_mkdirat(int dirfd, const char* cpath, mode_t mode) { case gkfs::preload::RelativizeStatus::fd_not_a_dir: return -ENOTDIR; case gkfs::preload::RelativizeStatus::internal: case gkfs::preload::RelativizeStatus::internal: { return with_errno( gkfs::syscall::gkfs_create(resolved, mode | S_IFDIR)); /* int ret = gsl::narrow_cast<int>(syscall_no_intercept_wrapper( SYS_mkdirat, dirfd, cpath, mode | )); if(ret < 0 && errno == EEXIST) { struct stat st; int k_ret = gsl::narrow_cast<int>(syscall_no_intercept_wrapper(SYS_newfstatat, dirfd, cpath, &st, 0)); if (k_ret == 0 && S_ISDIR(st.st_mode)) { return 0; // Local Kernel now 'sees' it, safe to return success } } return ret; */ } default: LOG(ERROR, "{}() relativize status unknown: {}", __func__); return -EINVAL; Loading src/client/open_file_map.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -206,7 +206,7 @@ OpenFileMap::remove(const int fd) { if(!CTX->protect_fds()) { if(!CTX->range_fd()) { // We close the dev null fd close(fd); // close(fd); return true; } } Loading Loading
src/client/hooks.cpp +26 −4 Original line number Diff line number Diff line Loading @@ -92,15 +92,20 @@ hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { return -ENOTDIR; case gkfs::preload::RelativizeStatus::internal: { auto md_ = gkfs::utils::get_metadata(resolved); struct stat st; syscall_no_intercept_wrapper( SYS_newfstatat, dirfd, ".", &st, AT_SYMLINK_NOFOLLOW); //auto md_ = gkfs::utils::get_metadata(resolved); // 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)); if(fd < 0) return fd; 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)); return with_errno(fd); return fd; } default: LOG(ERROR, "{}() relativize status unknown: {}", __func__); Loading @@ -110,6 +115,8 @@ hook_openat(int dirfd, const char* cpath, int flags, mode_t mode) { int hook_close(int fd) { if(fd == 0) return 0; LOG(DEBUG, "{}() called with fd: {}", __func__, fd); Loading Loading @@ -673,10 +680,25 @@ hook_mkdirat(int dirfd, const char* cpath, mode_t mode) { case gkfs::preload::RelativizeStatus::fd_not_a_dir: return -ENOTDIR; case gkfs::preload::RelativizeStatus::internal: case gkfs::preload::RelativizeStatus::internal: { return with_errno( gkfs::syscall::gkfs_create(resolved, mode | S_IFDIR)); /* int ret = gsl::narrow_cast<int>(syscall_no_intercept_wrapper( SYS_mkdirat, dirfd, cpath, mode | )); if(ret < 0 && errno == EEXIST) { struct stat st; int k_ret = gsl::narrow_cast<int>(syscall_no_intercept_wrapper(SYS_newfstatat, dirfd, cpath, &st, 0)); if (k_ret == 0 && S_ISDIR(st.st_mode)) { return 0; // Local Kernel now 'sees' it, safe to return success } } return ret; */ } default: LOG(ERROR, "{}() relativize status unknown: {}", __func__); return -EINVAL; Loading
src/client/open_file_map.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -206,7 +206,7 @@ OpenFileMap::remove(const int fd) { if(!CTX->protect_fds()) { if(!CTX->range_fd()) { // We close the dev null fd close(fd); // close(fd); return true; } } Loading