Loading include/client/gkfs_libc.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -283,7 +283,8 @@ int fstat64(int fd, struct stat64* buf); int stat(const char* path, struct stat* buf); int stat64(const char* path, struct stat64* buf); int __xstat(int ver, const char* path, struct stat* buf); Loading src/client/gkfs_libc.cpp +45 −4 Original line number Diff line number Diff line Loading @@ -46,8 +46,12 @@ #include <linux/const.h> std::atomic<bool> activated{false}; std::atomic<bool> initializing{false}; // #ifdef GKFS_DEBUG_BUILD // #define debug_info printf // #else #define debug_info(...) // #endif int (*real_open)(char*, int, mode_t) = NULL; Loading Loading @@ -1143,7 +1147,6 @@ write(int fd, const void* buf, size_t nbyte) { // add mkdir int mkdir(const char* path, mode_t mode) { debug_info("[BYPASS] >> Begin mkdir....%s\n", path); int ret = 0; initializeGekko(); if(CTX->interception_enabled()) { Loading @@ -1157,7 +1160,8 @@ mkdir(const char* path, mode_t mode) { case gkfs::preload::RelativizeStatus::internal: ret = gkfs::syscall::gkfs_create(resolved, mode | S_IFDIR); debug_info("[BYPASS] >> End mkdir.... %s\n", path); debug_info("[BYPASS] >> MKDIR GEKKO....%s, %d\n", resolved.c_str(), ret); return ret; default: // Try normal open. Loading Loading @@ -1189,6 +1193,7 @@ rmdir(const char* path) { case gkfs::preload::RelativizeStatus::internal: ret = gkfs::syscall::gkfs_rmdir(resolved); debug_info("[BYPASS] >> rmdir GEKKO.... %s %d\n", path, ret); return ret; default: // Try normal open. Loading Loading @@ -1497,9 +1502,8 @@ __lxstat64(int ver, const char* path, struct stat64* buf) { int __fxstat(int ver, int fd, struct stat* buf) { int res; debug_info("[__fxstat ]....%d \n", fd); initializeGekko(); // Is path from GekkoFS? if(CTX->interception_enabled()) { Loading @@ -1519,6 +1523,7 @@ __fxstat(int ver, int fd, struct stat* buf) { int __fxstatat(int ver, int dfd, const char* path, struct stat* buf, int flags) { debug_info("[__fxstatat ]....%s \n", path); // Is path from GekkoFS? initializeGekko(); Loading Loading @@ -1574,6 +1579,7 @@ int __fxstatat64(int ver, int dfd, const char* path, struct stat64* buf, int flags) { // Is path from GekkoFS? debug_info("[__fxstatat64 ]....%s \n", path); initializeGekko(); if(CTX->interception_enabled()) { std::string resolved; Loading Loading @@ -1666,6 +1672,41 @@ stat(const char* path, struct stat* buf) { return ret; } int stat64(const char* path, struct stat64* buf) { initializeGekko(); struct stat buf2; // Is path from GekkoFS? if(CTX->interception_enabled()) { std::string resolved; auto rstatus = CTX->relativize_fd_path(AT_FDCWD, path, resolved); switch(rstatus) { case gkfs::preload::RelativizeStatus::fd_not_a_dir: return -ENOTDIR; case gkfs::preload::RelativizeStatus::internal: debug_info("[STAT from GKFS]....%s \n", resolved.c_str()); return gkfs::syscall::gkfs_stat(resolved, &buf2); stat_to_stat64(buf, &buf2); return 0; default: // Try normal open. break; } } int ret = dlsym_stat(_STAT_VER, path, &buf2); stat_to_stat64(buf, &buf2); return ret; } // add fstat int fstat(int fd, struct stat* buf) { Loading Loading
include/client/gkfs_libc.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -283,7 +283,8 @@ int fstat64(int fd, struct stat64* buf); int stat(const char* path, struct stat* buf); int stat64(const char* path, struct stat64* buf); int __xstat(int ver, const char* path, struct stat* buf); Loading
src/client/gkfs_libc.cpp +45 −4 Original line number Diff line number Diff line Loading @@ -46,8 +46,12 @@ #include <linux/const.h> std::atomic<bool> activated{false}; std::atomic<bool> initializing{false}; // #ifdef GKFS_DEBUG_BUILD // #define debug_info printf // #else #define debug_info(...) // #endif int (*real_open)(char*, int, mode_t) = NULL; Loading Loading @@ -1143,7 +1147,6 @@ write(int fd, const void* buf, size_t nbyte) { // add mkdir int mkdir(const char* path, mode_t mode) { debug_info("[BYPASS] >> Begin mkdir....%s\n", path); int ret = 0; initializeGekko(); if(CTX->interception_enabled()) { Loading @@ -1157,7 +1160,8 @@ mkdir(const char* path, mode_t mode) { case gkfs::preload::RelativizeStatus::internal: ret = gkfs::syscall::gkfs_create(resolved, mode | S_IFDIR); debug_info("[BYPASS] >> End mkdir.... %s\n", path); debug_info("[BYPASS] >> MKDIR GEKKO....%s, %d\n", resolved.c_str(), ret); return ret; default: // Try normal open. Loading Loading @@ -1189,6 +1193,7 @@ rmdir(const char* path) { case gkfs::preload::RelativizeStatus::internal: ret = gkfs::syscall::gkfs_rmdir(resolved); debug_info("[BYPASS] >> rmdir GEKKO.... %s %d\n", path, ret); return ret; default: // Try normal open. Loading Loading @@ -1497,9 +1502,8 @@ __lxstat64(int ver, const char* path, struct stat64* buf) { int __fxstat(int ver, int fd, struct stat* buf) { int res; debug_info("[__fxstat ]....%d \n", fd); initializeGekko(); // Is path from GekkoFS? if(CTX->interception_enabled()) { Loading @@ -1519,6 +1523,7 @@ __fxstat(int ver, int fd, struct stat* buf) { int __fxstatat(int ver, int dfd, const char* path, struct stat* buf, int flags) { debug_info("[__fxstatat ]....%s \n", path); // Is path from GekkoFS? initializeGekko(); Loading Loading @@ -1574,6 +1579,7 @@ int __fxstatat64(int ver, int dfd, const char* path, struct stat64* buf, int flags) { // Is path from GekkoFS? debug_info("[__fxstatat64 ]....%s \n", path); initializeGekko(); if(CTX->interception_enabled()) { std::string resolved; Loading Loading @@ -1666,6 +1672,41 @@ stat(const char* path, struct stat* buf) { return ret; } int stat64(const char* path, struct stat64* buf) { initializeGekko(); struct stat buf2; // Is path from GekkoFS? if(CTX->interception_enabled()) { std::string resolved; auto rstatus = CTX->relativize_fd_path(AT_FDCWD, path, resolved); switch(rstatus) { case gkfs::preload::RelativizeStatus::fd_not_a_dir: return -ENOTDIR; case gkfs::preload::RelativizeStatus::internal: debug_info("[STAT from GKFS]....%s \n", resolved.c_str()); return gkfs::syscall::gkfs_stat(resolved, &buf2); stat_to_stat64(buf, &buf2); return 0; default: // Try normal open. break; } } int ret = dlsym_stat(_STAT_VER, path, &buf2); stat_to_stat64(buf, &buf2); return ret; } // add fstat int fstat(int fd, struct stat* buf) { Loading