Loading include/client/env.hpp +6 −7 Original line number Diff line number Diff line Loading @@ -43,4 +43,3 @@ static constexpr auto FORWARDING_MAP_FILE = ADD_PREFIX("FORWARDING_MAP_FILE"); #undef ADD_PREFIX #endif // GKFS_CLIENT_ENV include/client/gkfs_functions.hpp +71 −38 Original line number Diff line number Diff line Loading @@ -25,81 +25,114 @@ struct linux_dirent64; namespace gkfs { namespace syscall { int gkfs_open(const std::string& path, mode_t mode, int flags); int gkfs_open(const std::string& path, mode_t mode, int flags); int gkfs_create(const std::string& path, mode_t mode); int gkfs_create(const std::string& path, mode_t mode); int gkfs_remove(const std::string& path); int gkfs_remove(const std::string& path); // Implementation of access, // Follow links is true by default int gkfs_access(const std::string& path, int mask, bool follow_links = true); int gkfs_access(const std::string& path, int mask, bool follow_links = true); // Implementation of stat, // Follow links is true by default int gkfs_stat(const std::string& path, struct stat* buf, bool follow_links = true); int gkfs_stat(const std::string& path, struct stat* buf, bool follow_links = true); // Implementation of statx, it uses the normal stat and maps the information to the statx structure // Follow links is true by default // Implementation of statx, it uses the normal stat and maps the information to // the statx structure Follow links is true by default #ifdef STATX_TYPE int gkfs_statx(int dirfd, const std::string& path, int flags, unsigned int mask, struct statx* buf, bool follow_links = true); int gkfs_statx(int dirfd, const std::string& path, int flags, unsigned int mask, struct statx* buf, bool follow_links = true); #endif int gkfs_statfs(struct statfs* buf); int gkfs_statfs(struct statfs* buf); int gkfs_statvfs(struct statvfs* buf); int gkfs_statvfs(struct statvfs* buf); off64_t gkfs_lseek(unsigned int fd, off64_t offset, unsigned int whence); off64_t gkfs_lseek(unsigned int fd, off64_t offset, unsigned int whence); off64_t gkfs_lseek(std::shared_ptr<gkfs::filemap::OpenFile> gkfs_fd, off64_t offset, unsigned int whence); off64_t gkfs_lseek(std::shared_ptr<gkfs::filemap::OpenFile> gkfs_fd, off64_t offset, unsigned int whence); int gkfs_truncate(const std::string& path, off_t offset); int gkfs_truncate(const std::string& path, off_t offset); int gkfs_truncate(const std::string& path, off_t old_size, off_t new_size); int gkfs_truncate(const std::string& path, off_t old_size, off_t new_size); int gkfs_dup(int oldfd); int gkfs_dup(int oldfd); int gkfs_dup2(int oldfd, int newfd); int gkfs_dup2(int oldfd, int newfd); #ifdef HAS_SYMLINKS int gkfs_mk_symlink(const std::string& path, const std::string& target_path); int gkfs_mk_symlink(const std::string& path, const std::string& target_path); int gkfs_readlink(const std::string& path, char* buf, int bufsize); int gkfs_readlink(const std::string& path, char* buf, int bufsize); #endif ssize_t gkfs_pwrite(std::shared_ptr<gkfs::filemap::OpenFile> file, const char* buf, size_t count, off64_t offset); ssize_t gkfs_pwrite(std::shared_ptr<gkfs::filemap::OpenFile> file, const char* buf, size_t count, off64_t offset); ssize_t gkfs_pwrite_ws(int fd, const void* buf, size_t count, off64_t offset); ssize_t gkfs_pwrite_ws(int fd, const void* buf, size_t count, off64_t offset); ssize_t gkfs_write(int fd, const void* buf, size_t count); ssize_t gkfs_write(int fd, const void* buf, size_t count); ssize_t gkfs_pwritev(int fd, const struct iovec* iov, int iovcnt, off_t offset); ssize_t gkfs_pwritev(int fd, const struct iovec* iov, int iovcnt, off_t offset); ssize_t gkfs_writev(int fd, const struct iovec* iov, int iovcnt); ssize_t gkfs_writev(int fd, const struct iovec* iov, int iovcnt); ssize_t gkfs_pread(std::shared_ptr<gkfs::filemap::OpenFile> file, char* buf, size_t count, off64_t offset); ssize_t gkfs_pread(std::shared_ptr<gkfs::filemap::OpenFile> file, char* buf, size_t count, off64_t offset); ssize_t gkfs_pread_ws(int fd, void* buf, size_t count, off64_t offset); ssize_t gkfs_pread_ws(int fd, void* buf, size_t count, off64_t offset); ssize_t gkfs_read(int fd, void* buf, size_t count); ssize_t gkfs_read(int fd, void* buf, size_t count); ssize_t gkfs_readv(int fd, const struct iovec* iov, int iovcnt); ssize_t gkfs_readv(int fd, const struct iovec* iov, int iovcnt); ssize_t gkfs_preadv(int fd, const struct iovec* iov, int iovcnt, off_t offset); ssize_t gkfs_preadv(int fd, const struct iovec* iov, int iovcnt, off_t offset); int gkfs_opendir(const std::string& path); int gkfs_opendir(const std::string& path); int gkfs_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count); int gkfs_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count); int gkfs_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count); int gkfs_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count); int gkfs_rmdir(const std::string& path); int gkfs_rmdir(const std::string& path); } // namespace syscall } // namespace gkfs Loading include/client/hooks.hpp +83 −42 Original line number Diff line number Diff line Loading @@ -24,88 +24,129 @@ struct linux_dirent64; namespace gkfs { namespace hook { int hook_openat(int dirfd, const char* cpath, int flags, mode_t mode); int hook_openat(int dirfd, const char* cpath, int flags, mode_t mode); int hook_close(int fd); int hook_close(int fd); int hook_stat(const char* path, struct stat* buf); int hook_stat(const char* path, struct stat* buf); #ifdef STATX_TYPE int hook_statx(int dirfd, const char* path, int flags, unsigned int mask,struct statx* buf); int hook_statx(int dirfd, const char* path, int flags, unsigned int mask, struct statx* buf); #endif int hook_lstat(const char* path, struct stat* buf); int hook_lstat(const char* path, struct stat* buf); int hook_fstat(unsigned int fd, struct stat* buf); int hook_fstat(unsigned int fd, struct stat* buf); int hook_fstatat(int dirfd, const char* cpath, struct stat* buf, int flags); int hook_fstatat(int dirfd, const char* cpath, struct stat* buf, int flags); int hook_read(unsigned int fd, void* buf, size_t count); int hook_read(unsigned int fd, void* buf, size_t count); int hook_pread(unsigned int fd, char* buf, size_t count, loff_t pos); int hook_pread(unsigned int fd, char* buf, size_t count, loff_t pos); int hook_readv(unsigned long fd, const struct iovec* iov, unsigned long iovcnt); int hook_readv(unsigned long fd, const struct iovec* iov, unsigned long iovcnt); int hook_preadv(unsigned long fd, const struct iovec* iov, unsigned long iovcnt, int hook_preadv(unsigned long fd, const struct iovec* iov, unsigned long iovcnt, unsigned long pos_l, unsigned long pos_h); int hook_write(unsigned int fd, const char* buf, size_t count); int hook_write(unsigned int fd, const char* buf, size_t count); int hook_pwrite(unsigned int fd, const char* buf, size_t count, loff_t pos); int hook_pwrite(unsigned int fd, const char* buf, size_t count, loff_t pos); int hook_writev(unsigned long fd, const struct iovec* iov, unsigned long iovcnt); int hook_writev(unsigned long fd, const struct iovec* iov, unsigned long iovcnt); int hook_pwritev(unsigned long fd, const struct iovec* iov, unsigned long iovcnt, int hook_pwritev(unsigned long fd, const struct iovec* iov, unsigned long iovcnt, unsigned long pos_l, unsigned long pos_h); int hook_unlinkat(int dirfd, const char* cpath, int flags); int hook_unlinkat(int dirfd, const char* cpath, int flags); int hook_symlinkat(const char* oldname, int newdfd, const char* newname); int hook_symlinkat(const char* oldname, int newdfd, const char* newname); int hook_access(const char* path, int mask); int hook_access(const char* path, int mask); int hook_faccessat(int dirfd, const char* cpath, int mode); int hook_faccessat(int dirfd, const char* cpath, int mode); off_t hook_lseek(unsigned int fd, off_t offset, unsigned int whence); off_t hook_lseek(unsigned int fd, off_t offset, unsigned int whence); int hook_truncate(const char* path, long length); int hook_truncate(const char* path, long length); int hook_ftruncate(unsigned int fd, unsigned long length); int hook_ftruncate(unsigned int fd, unsigned long length); int hook_dup(unsigned int fd); int hook_dup(unsigned int fd); int hook_dup2(unsigned int oldfd, unsigned int newfd); int hook_dup2(unsigned int oldfd, unsigned int newfd); int hook_dup3(unsigned int oldfd, unsigned int newfd, int flags); int hook_dup3(unsigned int oldfd, unsigned int newfd, int flags); int hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count); int hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count); int hook_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count); int hook_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count); int hook_mkdirat(int dirfd, const char* cpath, mode_t mode); int hook_mkdirat(int dirfd, const char* cpath, mode_t mode); int hook_fchmodat(int dirfd, const char* path, mode_t mode); int hook_fchmodat(int dirfd, const char* path, mode_t mode); int hook_fchmod(unsigned int dirfd, mode_t mode); int hook_fchmod(unsigned int dirfd, mode_t mode); int hook_chdir(const char* path); int hook_chdir(const char* path); int hook_fchdir(unsigned int fd); int hook_fchdir(unsigned int fd); int hook_getcwd(char* buf, unsigned long size); int hook_getcwd(char* buf, unsigned long size); int hook_readlinkat(int dirfd, const char* cpath, char* buf, int bufsiz); int hook_readlinkat(int dirfd, const char* cpath, char* buf, int bufsiz); int hook_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg); int hook_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg); int hook_renameat(int olddfd, const char* oldname, int newdfd, const char* newname, int hook_renameat(int olddfd, const char* oldname, int newdfd, const char* newname, unsigned int flags); int hook_statfs(const char* path, struct statfs* buf); int hook_statfs(const char* path, struct statfs* buf); int hook_fstatfs(unsigned int fd, struct statfs* buf); int hook_fstatfs(unsigned int fd, struct statfs* buf); int hook_fsync(unsigned int fd); int hook_fsync(unsigned int fd); } // namespace hook } // namespace gkfs Loading include/client/intercept.hpp +10 −10 Original line number Diff line number Diff line Loading @@ -18,22 +18,22 @@ namespace gkfs { namespace preload { int internal_hook_guard_wrapper(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, internal_hook_guard_wrapper(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long* syscall_return_value); int hook_guard_wrapper(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long* syscall_return_value); hook_guard_wrapper(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long* syscall_return_value); void start_self_interception(); void start_self_interception(); void start_interception(); void start_interception(); void stop_interception(); void stop_interception(); } // namespace preload } // namespace gkfs Loading include/client/logging.hpp +197 −195 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
include/client/env.hpp +6 −7 Original line number Diff line number Diff line Loading @@ -43,4 +43,3 @@ static constexpr auto FORWARDING_MAP_FILE = ADD_PREFIX("FORWARDING_MAP_FILE"); #undef ADD_PREFIX #endif // GKFS_CLIENT_ENV
include/client/gkfs_functions.hpp +71 −38 Original line number Diff line number Diff line Loading @@ -25,81 +25,114 @@ struct linux_dirent64; namespace gkfs { namespace syscall { int gkfs_open(const std::string& path, mode_t mode, int flags); int gkfs_open(const std::string& path, mode_t mode, int flags); int gkfs_create(const std::string& path, mode_t mode); int gkfs_create(const std::string& path, mode_t mode); int gkfs_remove(const std::string& path); int gkfs_remove(const std::string& path); // Implementation of access, // Follow links is true by default int gkfs_access(const std::string& path, int mask, bool follow_links = true); int gkfs_access(const std::string& path, int mask, bool follow_links = true); // Implementation of stat, // Follow links is true by default int gkfs_stat(const std::string& path, struct stat* buf, bool follow_links = true); int gkfs_stat(const std::string& path, struct stat* buf, bool follow_links = true); // Implementation of statx, it uses the normal stat and maps the information to the statx structure // Follow links is true by default // Implementation of statx, it uses the normal stat and maps the information to // the statx structure Follow links is true by default #ifdef STATX_TYPE int gkfs_statx(int dirfd, const std::string& path, int flags, unsigned int mask, struct statx* buf, bool follow_links = true); int gkfs_statx(int dirfd, const std::string& path, int flags, unsigned int mask, struct statx* buf, bool follow_links = true); #endif int gkfs_statfs(struct statfs* buf); int gkfs_statfs(struct statfs* buf); int gkfs_statvfs(struct statvfs* buf); int gkfs_statvfs(struct statvfs* buf); off64_t gkfs_lseek(unsigned int fd, off64_t offset, unsigned int whence); off64_t gkfs_lseek(unsigned int fd, off64_t offset, unsigned int whence); off64_t gkfs_lseek(std::shared_ptr<gkfs::filemap::OpenFile> gkfs_fd, off64_t offset, unsigned int whence); off64_t gkfs_lseek(std::shared_ptr<gkfs::filemap::OpenFile> gkfs_fd, off64_t offset, unsigned int whence); int gkfs_truncate(const std::string& path, off_t offset); int gkfs_truncate(const std::string& path, off_t offset); int gkfs_truncate(const std::string& path, off_t old_size, off_t new_size); int gkfs_truncate(const std::string& path, off_t old_size, off_t new_size); int gkfs_dup(int oldfd); int gkfs_dup(int oldfd); int gkfs_dup2(int oldfd, int newfd); int gkfs_dup2(int oldfd, int newfd); #ifdef HAS_SYMLINKS int gkfs_mk_symlink(const std::string& path, const std::string& target_path); int gkfs_mk_symlink(const std::string& path, const std::string& target_path); int gkfs_readlink(const std::string& path, char* buf, int bufsize); int gkfs_readlink(const std::string& path, char* buf, int bufsize); #endif ssize_t gkfs_pwrite(std::shared_ptr<gkfs::filemap::OpenFile> file, const char* buf, size_t count, off64_t offset); ssize_t gkfs_pwrite(std::shared_ptr<gkfs::filemap::OpenFile> file, const char* buf, size_t count, off64_t offset); ssize_t gkfs_pwrite_ws(int fd, const void* buf, size_t count, off64_t offset); ssize_t gkfs_pwrite_ws(int fd, const void* buf, size_t count, off64_t offset); ssize_t gkfs_write(int fd, const void* buf, size_t count); ssize_t gkfs_write(int fd, const void* buf, size_t count); ssize_t gkfs_pwritev(int fd, const struct iovec* iov, int iovcnt, off_t offset); ssize_t gkfs_pwritev(int fd, const struct iovec* iov, int iovcnt, off_t offset); ssize_t gkfs_writev(int fd, const struct iovec* iov, int iovcnt); ssize_t gkfs_writev(int fd, const struct iovec* iov, int iovcnt); ssize_t gkfs_pread(std::shared_ptr<gkfs::filemap::OpenFile> file, char* buf, size_t count, off64_t offset); ssize_t gkfs_pread(std::shared_ptr<gkfs::filemap::OpenFile> file, char* buf, size_t count, off64_t offset); ssize_t gkfs_pread_ws(int fd, void* buf, size_t count, off64_t offset); ssize_t gkfs_pread_ws(int fd, void* buf, size_t count, off64_t offset); ssize_t gkfs_read(int fd, void* buf, size_t count); ssize_t gkfs_read(int fd, void* buf, size_t count); ssize_t gkfs_readv(int fd, const struct iovec* iov, int iovcnt); ssize_t gkfs_readv(int fd, const struct iovec* iov, int iovcnt); ssize_t gkfs_preadv(int fd, const struct iovec* iov, int iovcnt, off_t offset); ssize_t gkfs_preadv(int fd, const struct iovec* iov, int iovcnt, off_t offset); int gkfs_opendir(const std::string& path); int gkfs_opendir(const std::string& path); int gkfs_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count); int gkfs_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count); int gkfs_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count); int gkfs_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count); int gkfs_rmdir(const std::string& path); int gkfs_rmdir(const std::string& path); } // namespace syscall } // namespace gkfs Loading
include/client/hooks.hpp +83 −42 Original line number Diff line number Diff line Loading @@ -24,88 +24,129 @@ struct linux_dirent64; namespace gkfs { namespace hook { int hook_openat(int dirfd, const char* cpath, int flags, mode_t mode); int hook_openat(int dirfd, const char* cpath, int flags, mode_t mode); int hook_close(int fd); int hook_close(int fd); int hook_stat(const char* path, struct stat* buf); int hook_stat(const char* path, struct stat* buf); #ifdef STATX_TYPE int hook_statx(int dirfd, const char* path, int flags, unsigned int mask,struct statx* buf); int hook_statx(int dirfd, const char* path, int flags, unsigned int mask, struct statx* buf); #endif int hook_lstat(const char* path, struct stat* buf); int hook_lstat(const char* path, struct stat* buf); int hook_fstat(unsigned int fd, struct stat* buf); int hook_fstat(unsigned int fd, struct stat* buf); int hook_fstatat(int dirfd, const char* cpath, struct stat* buf, int flags); int hook_fstatat(int dirfd, const char* cpath, struct stat* buf, int flags); int hook_read(unsigned int fd, void* buf, size_t count); int hook_read(unsigned int fd, void* buf, size_t count); int hook_pread(unsigned int fd, char* buf, size_t count, loff_t pos); int hook_pread(unsigned int fd, char* buf, size_t count, loff_t pos); int hook_readv(unsigned long fd, const struct iovec* iov, unsigned long iovcnt); int hook_readv(unsigned long fd, const struct iovec* iov, unsigned long iovcnt); int hook_preadv(unsigned long fd, const struct iovec* iov, unsigned long iovcnt, int hook_preadv(unsigned long fd, const struct iovec* iov, unsigned long iovcnt, unsigned long pos_l, unsigned long pos_h); int hook_write(unsigned int fd, const char* buf, size_t count); int hook_write(unsigned int fd, const char* buf, size_t count); int hook_pwrite(unsigned int fd, const char* buf, size_t count, loff_t pos); int hook_pwrite(unsigned int fd, const char* buf, size_t count, loff_t pos); int hook_writev(unsigned long fd, const struct iovec* iov, unsigned long iovcnt); int hook_writev(unsigned long fd, const struct iovec* iov, unsigned long iovcnt); int hook_pwritev(unsigned long fd, const struct iovec* iov, unsigned long iovcnt, int hook_pwritev(unsigned long fd, const struct iovec* iov, unsigned long iovcnt, unsigned long pos_l, unsigned long pos_h); int hook_unlinkat(int dirfd, const char* cpath, int flags); int hook_unlinkat(int dirfd, const char* cpath, int flags); int hook_symlinkat(const char* oldname, int newdfd, const char* newname); int hook_symlinkat(const char* oldname, int newdfd, const char* newname); int hook_access(const char* path, int mask); int hook_access(const char* path, int mask); int hook_faccessat(int dirfd, const char* cpath, int mode); int hook_faccessat(int dirfd, const char* cpath, int mode); off_t hook_lseek(unsigned int fd, off_t offset, unsigned int whence); off_t hook_lseek(unsigned int fd, off_t offset, unsigned int whence); int hook_truncate(const char* path, long length); int hook_truncate(const char* path, long length); int hook_ftruncate(unsigned int fd, unsigned long length); int hook_ftruncate(unsigned int fd, unsigned long length); int hook_dup(unsigned int fd); int hook_dup(unsigned int fd); int hook_dup2(unsigned int oldfd, unsigned int newfd); int hook_dup2(unsigned int oldfd, unsigned int newfd); int hook_dup3(unsigned int oldfd, unsigned int newfd, int flags); int hook_dup3(unsigned int oldfd, unsigned int newfd, int flags); int hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count); int hook_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count); int hook_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count); int hook_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count); int hook_mkdirat(int dirfd, const char* cpath, mode_t mode); int hook_mkdirat(int dirfd, const char* cpath, mode_t mode); int hook_fchmodat(int dirfd, const char* path, mode_t mode); int hook_fchmodat(int dirfd, const char* path, mode_t mode); int hook_fchmod(unsigned int dirfd, mode_t mode); int hook_fchmod(unsigned int dirfd, mode_t mode); int hook_chdir(const char* path); int hook_chdir(const char* path); int hook_fchdir(unsigned int fd); int hook_fchdir(unsigned int fd); int hook_getcwd(char* buf, unsigned long size); int hook_getcwd(char* buf, unsigned long size); int hook_readlinkat(int dirfd, const char* cpath, char* buf, int bufsiz); int hook_readlinkat(int dirfd, const char* cpath, char* buf, int bufsiz); int hook_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg); int hook_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg); int hook_renameat(int olddfd, const char* oldname, int newdfd, const char* newname, int hook_renameat(int olddfd, const char* oldname, int newdfd, const char* newname, unsigned int flags); int hook_statfs(const char* path, struct statfs* buf); int hook_statfs(const char* path, struct statfs* buf); int hook_fstatfs(unsigned int fd, struct statfs* buf); int hook_fstatfs(unsigned int fd, struct statfs* buf); int hook_fsync(unsigned int fd); int hook_fsync(unsigned int fd); } // namespace hook } // namespace gkfs Loading
include/client/intercept.hpp +10 −10 Original line number Diff line number Diff line Loading @@ -18,22 +18,22 @@ namespace gkfs { namespace preload { int internal_hook_guard_wrapper(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, internal_hook_guard_wrapper(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long* syscall_return_value); int hook_guard_wrapper(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long* syscall_return_value); hook_guard_wrapper(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long* syscall_return_value); void start_self_interception(); void start_self_interception(); void start_interception(); void start_interception(); void stop_interception(); void stop_interception(); } // namespace preload } // namespace gkfs Loading
include/client/logging.hpp +197 −195 File changed.Preview size limit exceeded, changes collapsed. Show changes