Loading include/client/gkfs_libc.hpp +30 −29 Original line number Diff line number Diff line Loading @@ -166,9 +166,9 @@ __fxstat64(int ver, int fd, struct stat64* buf); int mkdir(const char* path, mode_t mode); int mkdirat(int dirfd, const char* path, mode_t mode); mkdirat(int dirfd, const char* path, mode_t mode) throw(); int rmdir(const char* path); rmdir(const char* path) throw(); DIR* opendir(const char* dirname); DIR* Loading @@ -191,11 +191,11 @@ readdir64(DIR* dirp); int closedir(DIR* dirp); void seekdir(DIR* dirp, long loc); seekdir(DIR* dirp, long loc) throw(); long telldir(DIR* dirp); telldir(DIR* dirp) throw(); void rewinddir(DIR* dirstream); rewinddir(DIR* dirstream) throw(); int scandir(const char* dirname, struct dirent*** namelist, scandir_filter_func_t filter, scandir_compar_func_t compar); Loading @@ -203,21 +203,22 @@ scandir(const char* dirname, struct dirent*** namelist, //------------------------- Path Operations ----------------------------------// int remove(const char* path); remove(const char* path) throw(); int unlink(const char* path); unlink(const char* path) throw(); int rename(const char* oldpath, const char* newpath); rename(const char* oldpath, const char* newpath) throw(); int renameat(int olddirfd, const char* oldpath, int newdirfd, const char* newpath); renameat(int olddirfd, const char* oldpath, int newdirfd, const char* newpath) throw(); int renameat2(int olddirfd, const char* oldpath, int newdirfd, const char* newpath, unsigned int flags); unsigned int flags) throw(); int symlink(const char* target_path, const char* link_path); // POSIX: target, linkpath const char* link_path) throw(); // POSIX: target, linkpath int symlinkat(const char* target_path, int newdirfd, const char* link_path); symlinkat(const char* target_path, int newdirfd, const char* link_path) throw(); #ifdef HAS_SYMLINKS ssize_t Loading @@ -227,43 +228,43 @@ readlinkat(int dfd, const char* path, char* buf, size_t bufsize); #endif char* realpath(const char* path, char* resolved_path); realpath(const char* path, char* resolved_path) throw(); char* __realpath_chk(const char* path, char* resolved_path, size_t resolved_len); // GNU Fortify Source variant int access(const char* path, int mode); access(const char* path, int mode) throw(); int faccessat(int dfd, const char* path, int mode, int flags); faccessat(int dfd, const char* path, int mode, int flags) throw(); int chdir(const char* path); chdir(const char* path) throw(); int fchdir(int fd); fchdir(int fd) throw(); char* getcwd(char* buffer, size_t size); getcwd(char* buffer, size_t size) throw(); //------------------------- Permissions --------------------------------------// int chmod(const char* path, mode_t mode); chmod(const char* path, mode_t mode) throw(); int fchmod(int fd, mode_t mode); fchmod(int fd, mode_t mode) throw(); int fchmodat(int dfd, const char* path, mode_t mode, int flags); fchmodat(int dfd, const char* path, mode_t mode, int flags) throw(); int chown(const char* path, uid_t owner, gid_t group); chown(const char* path, uid_t owner, gid_t group) throw(); int fchown(int fd, uid_t owner, gid_t group); fchown(int fd, uid_t owner, gid_t group) throw(); //------------------------- Process and Descriptor Management //------------------// int dup(int fd); dup(int fd) throw(); int dup2(int oldfd, int newfd); dup2(int oldfd, int newfd) throw(); int dup3(int oldfd, int newfd, int flags); dup3(int oldfd, int newfd, int flags) throw(); int fcntl(int fd, int cmd, ...); Loading @@ -279,7 +280,7 @@ pipe(int pipefd[2]); FILE* fopen(const char* path, const char* mode); FILE* fdopen(int fd, const char* mode); fdopen(int fd, const char* mode) throw(); FILE* freopen64(const char* path, const char* mode, FILE* stream); // Note: Source uses "freopen" symbol Loading @@ -296,9 +297,9 @@ ftell(FILE* stream); void rewind(FILE* stream); int feof(FILE* stream); feof(FILE* stream) throw(); void clearerr(FILE* stream); clearerr(FILE* stream) throw(); int fputs(const char* str, FILE* stream); char* Loading include/client/hooks.hpp +35 −1 Original line number Diff line number Diff line Loading @@ -75,9 +75,19 @@ struct statfs; namespace gkfs::hook { struct open_how { uint64_t flags; uint64_t mode; uint64_t resolve; }; int hook_openat(int dirfd, const char* cpath, int flags, mode_t mode); int hook_openat2(int dirfd, const char* cpath, struct open_how* how, size_t size); int hook_close(int fd); Loading Loading @@ -174,11 +184,27 @@ int hook_mkdirat(int dirfd, const char* cpath, mode_t mode); int hook_fchmodat(int dirfd, const char* path, mode_t mode); hook_fchmodat(int dirfd, const char* path, mode_t mode, int flags); int hook_fchmod(unsigned int dirfd, mode_t mode); int hook_chmod(const char* path, mode_t mode); int hook_lchown(const char* path, uid_t owner, gid_t group); int hook_chown(const char* path, uid_t owner, gid_t group); int hook_fchown(unsigned int fd, uid_t owner, gid_t group); int hook_fchownat(int dirfd, const char* cpath, uid_t owner, gid_t group, int flags); int hook_chdir(const char* path); Loading Loading @@ -236,6 +262,14 @@ hook_munmap(void* addr, size_t length); int hook_msync(void* addr, size_t length, int flags); int hook_utimensat(int dirfd, const char* cpath, const struct timespec times[2], int flags); int hook_futimens(unsigned int fd, const struct timespec times[2]); } // namespace gkfs::hook #endif include/client/intercept.hpp +0 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ struct linux_dirent { int64_t d_off; #endif unsigned short d_reclen; unsigned char d_type; // Does it break dirents? char d_name[1]; }; /* Loading include/client/logging.hpp +5 −3 Original line number Diff line number Diff line Loading @@ -44,12 +44,13 @@ #include <libsyscall_intercept_hook_point.h> #include <type_traits> #include <memory> #include <client/make_array.hpp> #include <client/syscalls.hpp> #include <optional> #include <fmt/format.h> #include <fmt/ostream.h> #include <hermes.hpp> #ifdef GKFS_DEBUG_BUILD #include <bitset> Loading Loading @@ -213,7 +214,7 @@ mini_gmtime_r(const time_t* timep, struct tm* tm) { unsigned hms = ts % 86400; /* -86399 <= hms <= 86399. This needs sizeof(int) >= 4. */ time_t c, f; time_t c; unsigned yday; /* 0 <= yday <= 426. Also fits to an `unsigned short', but `int' is faster. */ unsigned a; /* 0 <= a <= 2133. Also fits to an `unsigned short', but `int' Loading @@ -231,6 +232,7 @@ mini_gmtime_r(const time_t* timep, struct tm* tm) { if(sizeof(time_t) > 4) { /* Optimization. For int32_t, this would keep t intact, so we won't have to do it. This produces unreachable code. */ time_t f; f = (t + 4) % 7; if(f < 0) f += 7; /* Fix negative remainder if (t + 4) was negative. */ Loading Loading @@ -299,7 +301,7 @@ mini_gmtime(const time_t* timep) { static inline ssize_t format_timeval(struct timeval* tv, char* buf, size_t sz) { ssize_t written = -1; struct tm* gm = mini_gmtime(&tv->tv_sec); const struct tm* gm = mini_gmtime(&tv->tv_sec); written = (ssize_t) strftime(buf, sz, "%Y-%m-%d %H:%M:%S", gm); Loading include/client/open_file_map.hpp +26 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,8 @@ enum class OpenFile_flags { wronly, rdwr, cloexec, created, // indicates if the file was created during open creation_pending, // indicates if the file creation is delayed flag_count // this is purely used as a size variable of this enum class }; Loading @@ -75,6 +77,7 @@ protected: unsigned long pos_; std::mutex pos_mutex_; std::mutex flag_mutex_; mode_t mode_; public: // multiple threads may want to update the file position if fd has been Loading @@ -86,7 +89,7 @@ public: ~OpenFile() = default; // getter/setter std::string const std::string& path() const; void Loading @@ -106,6 +109,28 @@ public: FileType type() const; mode_t mode() const; void mode(mode_t mode_); const std::string& inline_data() const; void inline_data(const std::string& data); size_t inline_data_size() const; void inline_data_size(size_t size); private: std::string inline_data_; size_t inline_data_size_{0}; }; Loading Loading
include/client/gkfs_libc.hpp +30 −29 Original line number Diff line number Diff line Loading @@ -166,9 +166,9 @@ __fxstat64(int ver, int fd, struct stat64* buf); int mkdir(const char* path, mode_t mode); int mkdirat(int dirfd, const char* path, mode_t mode); mkdirat(int dirfd, const char* path, mode_t mode) throw(); int rmdir(const char* path); rmdir(const char* path) throw(); DIR* opendir(const char* dirname); DIR* Loading @@ -191,11 +191,11 @@ readdir64(DIR* dirp); int closedir(DIR* dirp); void seekdir(DIR* dirp, long loc); seekdir(DIR* dirp, long loc) throw(); long telldir(DIR* dirp); telldir(DIR* dirp) throw(); void rewinddir(DIR* dirstream); rewinddir(DIR* dirstream) throw(); int scandir(const char* dirname, struct dirent*** namelist, scandir_filter_func_t filter, scandir_compar_func_t compar); Loading @@ -203,21 +203,22 @@ scandir(const char* dirname, struct dirent*** namelist, //------------------------- Path Operations ----------------------------------// int remove(const char* path); remove(const char* path) throw(); int unlink(const char* path); unlink(const char* path) throw(); int rename(const char* oldpath, const char* newpath); rename(const char* oldpath, const char* newpath) throw(); int renameat(int olddirfd, const char* oldpath, int newdirfd, const char* newpath); renameat(int olddirfd, const char* oldpath, int newdirfd, const char* newpath) throw(); int renameat2(int olddirfd, const char* oldpath, int newdirfd, const char* newpath, unsigned int flags); unsigned int flags) throw(); int symlink(const char* target_path, const char* link_path); // POSIX: target, linkpath const char* link_path) throw(); // POSIX: target, linkpath int symlinkat(const char* target_path, int newdirfd, const char* link_path); symlinkat(const char* target_path, int newdirfd, const char* link_path) throw(); #ifdef HAS_SYMLINKS ssize_t Loading @@ -227,43 +228,43 @@ readlinkat(int dfd, const char* path, char* buf, size_t bufsize); #endif char* realpath(const char* path, char* resolved_path); realpath(const char* path, char* resolved_path) throw(); char* __realpath_chk(const char* path, char* resolved_path, size_t resolved_len); // GNU Fortify Source variant int access(const char* path, int mode); access(const char* path, int mode) throw(); int faccessat(int dfd, const char* path, int mode, int flags); faccessat(int dfd, const char* path, int mode, int flags) throw(); int chdir(const char* path); chdir(const char* path) throw(); int fchdir(int fd); fchdir(int fd) throw(); char* getcwd(char* buffer, size_t size); getcwd(char* buffer, size_t size) throw(); //------------------------- Permissions --------------------------------------// int chmod(const char* path, mode_t mode); chmod(const char* path, mode_t mode) throw(); int fchmod(int fd, mode_t mode); fchmod(int fd, mode_t mode) throw(); int fchmodat(int dfd, const char* path, mode_t mode, int flags); fchmodat(int dfd, const char* path, mode_t mode, int flags) throw(); int chown(const char* path, uid_t owner, gid_t group); chown(const char* path, uid_t owner, gid_t group) throw(); int fchown(int fd, uid_t owner, gid_t group); fchown(int fd, uid_t owner, gid_t group) throw(); //------------------------- Process and Descriptor Management //------------------// int dup(int fd); dup(int fd) throw(); int dup2(int oldfd, int newfd); dup2(int oldfd, int newfd) throw(); int dup3(int oldfd, int newfd, int flags); dup3(int oldfd, int newfd, int flags) throw(); int fcntl(int fd, int cmd, ...); Loading @@ -279,7 +280,7 @@ pipe(int pipefd[2]); FILE* fopen(const char* path, const char* mode); FILE* fdopen(int fd, const char* mode); fdopen(int fd, const char* mode) throw(); FILE* freopen64(const char* path, const char* mode, FILE* stream); // Note: Source uses "freopen" symbol Loading @@ -296,9 +297,9 @@ ftell(FILE* stream); void rewind(FILE* stream); int feof(FILE* stream); feof(FILE* stream) throw(); void clearerr(FILE* stream); clearerr(FILE* stream) throw(); int fputs(const char* str, FILE* stream); char* Loading
include/client/hooks.hpp +35 −1 Original line number Diff line number Diff line Loading @@ -75,9 +75,19 @@ struct statfs; namespace gkfs::hook { struct open_how { uint64_t flags; uint64_t mode; uint64_t resolve; }; int hook_openat(int dirfd, const char* cpath, int flags, mode_t mode); int hook_openat2(int dirfd, const char* cpath, struct open_how* how, size_t size); int hook_close(int fd); Loading Loading @@ -174,11 +184,27 @@ int hook_mkdirat(int dirfd, const char* cpath, mode_t mode); int hook_fchmodat(int dirfd, const char* path, mode_t mode); hook_fchmodat(int dirfd, const char* path, mode_t mode, int flags); int hook_fchmod(unsigned int dirfd, mode_t mode); int hook_chmod(const char* path, mode_t mode); int hook_lchown(const char* path, uid_t owner, gid_t group); int hook_chown(const char* path, uid_t owner, gid_t group); int hook_fchown(unsigned int fd, uid_t owner, gid_t group); int hook_fchownat(int dirfd, const char* cpath, uid_t owner, gid_t group, int flags); int hook_chdir(const char* path); Loading Loading @@ -236,6 +262,14 @@ hook_munmap(void* addr, size_t length); int hook_msync(void* addr, size_t length, int flags); int hook_utimensat(int dirfd, const char* cpath, const struct timespec times[2], int flags); int hook_futimens(unsigned int fd, const struct timespec times[2]); } // namespace gkfs::hook #endif
include/client/intercept.hpp +0 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,6 @@ struct linux_dirent { int64_t d_off; #endif unsigned short d_reclen; unsigned char d_type; // Does it break dirents? char d_name[1]; }; /* Loading
include/client/logging.hpp +5 −3 Original line number Diff line number Diff line Loading @@ -44,12 +44,13 @@ #include <libsyscall_intercept_hook_point.h> #include <type_traits> #include <memory> #include <client/make_array.hpp> #include <client/syscalls.hpp> #include <optional> #include <fmt/format.h> #include <fmt/ostream.h> #include <hermes.hpp> #ifdef GKFS_DEBUG_BUILD #include <bitset> Loading Loading @@ -213,7 +214,7 @@ mini_gmtime_r(const time_t* timep, struct tm* tm) { unsigned hms = ts % 86400; /* -86399 <= hms <= 86399. This needs sizeof(int) >= 4. */ time_t c, f; time_t c; unsigned yday; /* 0 <= yday <= 426. Also fits to an `unsigned short', but `int' is faster. */ unsigned a; /* 0 <= a <= 2133. Also fits to an `unsigned short', but `int' Loading @@ -231,6 +232,7 @@ mini_gmtime_r(const time_t* timep, struct tm* tm) { if(sizeof(time_t) > 4) { /* Optimization. For int32_t, this would keep t intact, so we won't have to do it. This produces unreachable code. */ time_t f; f = (t + 4) % 7; if(f < 0) f += 7; /* Fix negative remainder if (t + 4) was negative. */ Loading Loading @@ -299,7 +301,7 @@ mini_gmtime(const time_t* timep) { static inline ssize_t format_timeval(struct timeval* tv, char* buf, size_t sz) { ssize_t written = -1; struct tm* gm = mini_gmtime(&tv->tv_sec); const struct tm* gm = mini_gmtime(&tv->tv_sec); written = (ssize_t) strftime(buf, sz, "%Y-%m-%d %H:%M:%S", gm); Loading
include/client/open_file_map.hpp +26 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,8 @@ enum class OpenFile_flags { wronly, rdwr, cloexec, created, // indicates if the file was created during open creation_pending, // indicates if the file creation is delayed flag_count // this is purely used as a size variable of this enum class }; Loading @@ -75,6 +77,7 @@ protected: unsigned long pos_; std::mutex pos_mutex_; std::mutex flag_mutex_; mode_t mode_; public: // multiple threads may want to update the file position if fd has been Loading @@ -86,7 +89,7 @@ public: ~OpenFile() = default; // getter/setter std::string const std::string& path() const; void Loading @@ -106,6 +109,28 @@ public: FileType type() const; mode_t mode() const; void mode(mode_t mode_); const std::string& inline_data() const; void inline_data(const std::string& data); size_t inline_data_size() const; void inline_data_size(size_t size); private: std::string inline_data_; size_t inline_data_size_{0}; }; Loading