Loading include/client/gkfs_libc.hpp +63 −13 Original line number Diff line number Diff line Loading @@ -40,6 +40,28 @@ extern "C" { #include <dirent.h> #include <stdlib.h> #include <stdio.h> #include <sys/statvfs.h> #include <sys/types.h> #include <dirent.h> #ifndef _STAT_VER #define _STAT_VER 0 #endif struct __dirstream { int fd; // File descriptor. //__libc_lock_define (, lock) // Mutex lock for this structure. //TODO size_t allocation; // Space allocated for the block. size_t size; // Total valid data in the block. size_t offset; // Current offset into the block. off_t filepos; // Position of next entry to read. // Directory block. char data[0] __attribute__((aligned(__alignof__(void*)))); char* path; }; // File API Loading Loading @@ -84,22 +106,25 @@ off64_t dlsym_lseek64(int fd, off64_t offset, int whence); int dlsym_fstat(int fd, struct stat* buf); dlsym_fstat(int ver, int fd, struct stat* buf); int dlsym_fxstat64(int fd, struct stat64* buf); dlsym_fxstat64(int ver, int fd, struct stat64* buf); int dlsym_stat(const char* path, struct stat* buf); dlsym_stat(int ver, const char* path, struct stat* buf); int dlsym_lstat(const char* path, struct stat* buf); dlsym_lstat(int ver, const char* path, struct stat* buf); int dlsym_lxstat64(const char* path, struct stat64* buf); dlsym_lxstat64(int ver, const char* path, struct stat64* buf); int dlsym_xstat64(const char* path, struct stat64* buf); dlsym_xstat64(int ver, const char* path, struct stat64* buf); int dlsym_fstatat(int dfd, const char* path, struct stat* buf, int flags); int dlsym_fstatat64(int dfd, const char* path, struct stat64* buf, int flags); int dlsym_statx(int dirfd, const char* path, int flags, unsigned int mask, struct statx* buf); int dlsym_rename(const char* old_path, const char* new_path); int Loading Loading @@ -205,7 +230,12 @@ open64(const char* path, int flags, ...); int open(const char* path, int flags, ...); // openat int openat (int __fd, const char *__file, int __oflag, ...); int openat(int __fd, const char* __file, int __oflag, ...); int openat64(int dirfd, const char* path, int flags, ...); int Loading Loading @@ -246,6 +276,12 @@ off_t lseek(int fd, off_t offset, int whence) __THROW; off64_t lseek64(int fd, off64_t offset, int whence) __THROW; // statvfs int statvfs(const char* path, struct statvfs* buf); int fstatvfs(int fd, struct statvfs* buf); int fstat(int fd, struct stat* buf); Loading @@ -253,17 +289,28 @@ int fstat64(int fd, struct stat64* buf); int stat(const char* path, struct stat* buf); int lstat(const char* path, struct stat* buf); __xstat(int ver, const char* path, struct stat* buf); int stat64(const char* path, struct stat64* buf); __xstat64(int ver, const char* path, struct stat64* buf); int lstat64(const char* path, struct stat64* buf); __fxstat64(int ver, int fd, struct stat64* buf); int fstatat(int dfd, const char* path, struct stat* buf, int flags); __lxstat(int ver, const char* path, struct stat* buf); int fstatat64(int dfd, const char* path, struct stat64* buf, int flags); __lxstat64(int ver, const char* path, struct stat64* buf); int __fxstat(int ver, int fd, struct stat* buf); int __fxstatat(int ver, int dfd, const char* path, struct stat* buf, int flags); int __fxstatat64(int ver, int dfd, const char* path, struct stat64* buf, int flags); int statx(int dirfd, const char* pathname, int flags, unsigned int mask, struct statx* statxbuf); int rename(const char* old_path, const char* new_path); int Loading @@ -288,6 +335,9 @@ readdir(DIR* dirp); struct dirent64* readdir64(DIR* dirp); int clone(int (*fn)(void*), void* stack, int flags, void* arg, ...); /* pid_t *parent_tid, void *tls, pid_t *child_tid */ /* ................................................................... */ Loading include/client/preload.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ #define CTX gkfs::preload::PreloadContext::getInstance() namespace gkfs::preload { void init_environment(); void init_ld_env_if_needed(); } // namespace gkfs::preload Loading include/client/user_functions.hpp +20 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ extern "C" { #include <sys/stat.h> } struct linux_dirent; struct linux_dirent64; namespace gkfs { Loading @@ -51,6 +52,8 @@ gkfs_create(const std::string& path, mode_t mode); int gkfs_remove(const std::string& path); int gkfs_rmdir(const std::string& path); ssize_t gkfs_write(int fd, const void* buf, size_t count); Loading @@ -73,6 +76,10 @@ gkfs_pread(int fd, void* buf, size_t count, off64_t offset); int gkfs_stat(const std::string& path, struct stat* buf, bool follow_links = true); int gkfs_statx(int dirfs, const std::string& path, int flags, unsigned int mask, struct statx* buf, bool follow_links = true); int gkfs_remove(const std::string& path); Loading @@ -87,6 +94,19 @@ gkfs_access(const std::string& path, const int mask, bool follow_links); std::vector<std::string> gkfs_get_file_list(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_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count); } // namespace syscall namespace malleable { Loading src/client/gkfs_functions.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -65,9 +65,15 @@ using namespace std; * kernel: fs/readdir.c. */ struct linux_dirent { #ifndef __USE_FILE_OFFSET64 unsigned long d_ino; unsigned long d_off; #else uint64_t d_ino; int64_t d_off; #endif unsigned short d_reclen; unsigned char d_type; // Does it break dirents? char d_name[1]; }; /* Loading Loading @@ -1488,7 +1494,7 @@ gkfs_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count) { current_dirp->d_reclen = total_size; *(reinterpret_cast<char*>(current_dirp) + total_size - 1) = current_dirp->d_type = ((de.type() == gkfs::filemap::FileType::regular) ? DT_REG : DT_DIR); Loading src/client/gkfs_libc.cpp +906 −147 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
include/client/gkfs_libc.hpp +63 −13 Original line number Diff line number Diff line Loading @@ -40,6 +40,28 @@ extern "C" { #include <dirent.h> #include <stdlib.h> #include <stdio.h> #include <sys/statvfs.h> #include <sys/types.h> #include <dirent.h> #ifndef _STAT_VER #define _STAT_VER 0 #endif struct __dirstream { int fd; // File descriptor. //__libc_lock_define (, lock) // Mutex lock for this structure. //TODO size_t allocation; // Space allocated for the block. size_t size; // Total valid data in the block. size_t offset; // Current offset into the block. off_t filepos; // Position of next entry to read. // Directory block. char data[0] __attribute__((aligned(__alignof__(void*)))); char* path; }; // File API Loading Loading @@ -84,22 +106,25 @@ off64_t dlsym_lseek64(int fd, off64_t offset, int whence); int dlsym_fstat(int fd, struct stat* buf); dlsym_fstat(int ver, int fd, struct stat* buf); int dlsym_fxstat64(int fd, struct stat64* buf); dlsym_fxstat64(int ver, int fd, struct stat64* buf); int dlsym_stat(const char* path, struct stat* buf); dlsym_stat(int ver, const char* path, struct stat* buf); int dlsym_lstat(const char* path, struct stat* buf); dlsym_lstat(int ver, const char* path, struct stat* buf); int dlsym_lxstat64(const char* path, struct stat64* buf); dlsym_lxstat64(int ver, const char* path, struct stat64* buf); int dlsym_xstat64(const char* path, struct stat64* buf); dlsym_xstat64(int ver, const char* path, struct stat64* buf); int dlsym_fstatat(int dfd, const char* path, struct stat* buf, int flags); int dlsym_fstatat64(int dfd, const char* path, struct stat64* buf, int flags); int dlsym_statx(int dirfd, const char* path, int flags, unsigned int mask, struct statx* buf); int dlsym_rename(const char* old_path, const char* new_path); int Loading Loading @@ -205,7 +230,12 @@ open64(const char* path, int flags, ...); int open(const char* path, int flags, ...); // openat int openat (int __fd, const char *__file, int __oflag, ...); int openat(int __fd, const char* __file, int __oflag, ...); int openat64(int dirfd, const char* path, int flags, ...); int Loading Loading @@ -246,6 +276,12 @@ off_t lseek(int fd, off_t offset, int whence) __THROW; off64_t lseek64(int fd, off64_t offset, int whence) __THROW; // statvfs int statvfs(const char* path, struct statvfs* buf); int fstatvfs(int fd, struct statvfs* buf); int fstat(int fd, struct stat* buf); Loading @@ -253,17 +289,28 @@ int fstat64(int fd, struct stat64* buf); int stat(const char* path, struct stat* buf); int lstat(const char* path, struct stat* buf); __xstat(int ver, const char* path, struct stat* buf); int stat64(const char* path, struct stat64* buf); __xstat64(int ver, const char* path, struct stat64* buf); int lstat64(const char* path, struct stat64* buf); __fxstat64(int ver, int fd, struct stat64* buf); int fstatat(int dfd, const char* path, struct stat* buf, int flags); __lxstat(int ver, const char* path, struct stat* buf); int fstatat64(int dfd, const char* path, struct stat64* buf, int flags); __lxstat64(int ver, const char* path, struct stat64* buf); int __fxstat(int ver, int fd, struct stat* buf); int __fxstatat(int ver, int dfd, const char* path, struct stat* buf, int flags); int __fxstatat64(int ver, int dfd, const char* path, struct stat64* buf, int flags); int statx(int dirfd, const char* pathname, int flags, unsigned int mask, struct statx* statxbuf); int rename(const char* old_path, const char* new_path); int Loading @@ -288,6 +335,9 @@ readdir(DIR* dirp); struct dirent64* readdir64(DIR* dirp); int clone(int (*fn)(void*), void* stack, int flags, void* arg, ...); /* pid_t *parent_tid, void *tls, pid_t *child_tid */ /* ................................................................... */ Loading
include/client/preload.hpp +2 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ #define CTX gkfs::preload::PreloadContext::getInstance() namespace gkfs::preload { void init_environment(); void init_ld_env_if_needed(); } // namespace gkfs::preload Loading
include/client/user_functions.hpp +20 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ extern "C" { #include <sys/stat.h> } struct linux_dirent; struct linux_dirent64; namespace gkfs { Loading @@ -51,6 +52,8 @@ gkfs_create(const std::string& path, mode_t mode); int gkfs_remove(const std::string& path); int gkfs_rmdir(const std::string& path); ssize_t gkfs_write(int fd, const void* buf, size_t count); Loading @@ -73,6 +76,10 @@ gkfs_pread(int fd, void* buf, size_t count, off64_t offset); int gkfs_stat(const std::string& path, struct stat* buf, bool follow_links = true); int gkfs_statx(int dirfs, const std::string& path, int flags, unsigned int mask, struct statx* buf, bool follow_links = true); int gkfs_remove(const std::string& path); Loading @@ -87,6 +94,19 @@ gkfs_access(const std::string& path, const int mask, bool follow_links); std::vector<std::string> gkfs_get_file_list(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_getdents64(unsigned int fd, struct linux_dirent64* dirp, unsigned int count); } // namespace syscall namespace malleable { Loading
src/client/gkfs_functions.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -65,9 +65,15 @@ using namespace std; * kernel: fs/readdir.c. */ struct linux_dirent { #ifndef __USE_FILE_OFFSET64 unsigned long d_ino; unsigned long d_off; #else uint64_t d_ino; int64_t d_off; #endif unsigned short d_reclen; unsigned char d_type; // Does it break dirents? char d_name[1]; }; /* Loading Loading @@ -1488,7 +1494,7 @@ gkfs_getdents(unsigned int fd, struct linux_dirent* dirp, unsigned int count) { current_dirp->d_reclen = total_size; *(reinterpret_cast<char*>(current_dirp) + total_size - 1) = current_dirp->d_type = ((de.type() == gkfs::filemap::FileType::regular) ? DT_REG : DT_DIR); Loading
src/client/gkfs_libc.cpp +906 −147 File changed.Preview size limit exceeded, changes collapsed. Show changes