Loading include/client/hooks.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ int hook_openat(int dirfd, const char *cpath, int flags, mode_t mode); int hook_close(int fd); int hook_stat(const char* path, struct stat* buf); int hook_lstat(const char* path, struct stat* buf); int hook_fstat(unsigned int, struct stat* buf); int hook_read(int fd, void* buf, size_t count); int hook_write(int fd, void* buf, size_t count); int hook_unlink(const char* path); Loading src/client/hooks.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,24 @@ int hook_stat(const char* path, struct stat* buf) { return syscall_no_intercept(SYS_stat, rel_path.c_str(), buf); } int hook_lstat(const char* path, struct stat* buf) { CTX->log()->trace("{}() called with path '{}'", __func__, path); std::string rel_path; if (CTX->relativize_path(path, rel_path)) { return with_errno(adafs_stat(rel_path, buf)); } return syscall_no_intercept(SYS_lstat, rel_path.c_str(), buf); } int hook_fstat(unsigned int fd, struct stat* buf) { CTX->log()->trace("{}() called with fd '{}'", __func__, fd); if (CTX->file_map()->exist(fd)) { auto path = CTX->file_map()->get(fd)->path(); return with_errno(adafs_stat(path, buf)); } return syscall_no_intercept(SYS_fstat, fd, buf); } int hook_read(int fd, void* buf, size_t count) { CTX->log()->trace("{}() called with fd {}, count {}", __func__, fd, count); if (CTX->file_map()->exist(fd)) { Loading src/client/intercept.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,16 @@ static inline int hook(long syscall_number, reinterpret_cast<struct stat*>(arg1)); break; case SYS_lstat: *result = hook_lstat(reinterpret_cast<char*>(arg0), reinterpret_cast<struct stat*>(arg1)); break; case SYS_fstat: *result = hook_fstat(static_cast<int>(arg0), reinterpret_cast<struct stat*>(arg1)); break; case SYS_read: *result = hook_read(static_cast<int>(arg0), reinterpret_cast<void*>(arg1), Loading Loading
include/client/hooks.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ int hook_openat(int dirfd, const char *cpath, int flags, mode_t mode); int hook_close(int fd); int hook_stat(const char* path, struct stat* buf); int hook_lstat(const char* path, struct stat* buf); int hook_fstat(unsigned int, struct stat* buf); int hook_read(int fd, void* buf, size_t count); int hook_write(int fd, void* buf, size_t count); int hook_unlink(const char* path); Loading
src/client/hooks.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,24 @@ int hook_stat(const char* path, struct stat* buf) { return syscall_no_intercept(SYS_stat, rel_path.c_str(), buf); } int hook_lstat(const char* path, struct stat* buf) { CTX->log()->trace("{}() called with path '{}'", __func__, path); std::string rel_path; if (CTX->relativize_path(path, rel_path)) { return with_errno(adafs_stat(rel_path, buf)); } return syscall_no_intercept(SYS_lstat, rel_path.c_str(), buf); } int hook_fstat(unsigned int fd, struct stat* buf) { CTX->log()->trace("{}() called with fd '{}'", __func__, fd); if (CTX->file_map()->exist(fd)) { auto path = CTX->file_map()->get(fd)->path(); return with_errno(adafs_stat(path, buf)); } return syscall_no_intercept(SYS_fstat, fd, buf); } int hook_read(int fd, void* buf, size_t count) { CTX->log()->trace("{}() called with fd {}, count {}", __func__, fd, count); if (CTX->file_map()->exist(fd)) { Loading
src/client/intercept.cpp +10 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,16 @@ static inline int hook(long syscall_number, reinterpret_cast<struct stat*>(arg1)); break; case SYS_lstat: *result = hook_lstat(reinterpret_cast<char*>(arg0), reinterpret_cast<struct stat*>(arg1)); break; case SYS_fstat: *result = hook_fstat(static_cast<int>(arg0), reinterpret_cast<struct stat*>(arg1)); break; case SYS_read: *result = hook_read(static_cast<int>(arg0), reinterpret_cast<void*>(arg1), Loading