Loading ifs/include/preload/passthrough.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ extern void* libc_fileno; extern void* libc_mkdir; extern void* libc_mkdirat; extern void* libc_unlink; extern void* libc_unlinkat; extern void* libc_rmdir; extern void* libc_close; Loading ifs/src/preload/intcp_functions.cpp +40 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ #include <sys/statfs.h> #include <sys/stat.h> #include <sys/uio.h> #include <sys/unistd.h> #include <preload/preload.hpp> #include <preload/passthrough.hpp> Loading Loading @@ -326,6 +327,45 @@ int unlink(const char* path) __THROW { return (reinterpret_cast<decltype(&unlink)>(libc_unlink))(path); } int unlinkat(int dirfd, const char *cpath, int flags) { init_passthrough_if_needed(); if(CTX->initialized()) { std::string path(cpath); CTX->log()->trace("{}() called with path {}, dirfd {}, flags {}", __func__, path, dirfd, flags); if(flags & AT_REMOVEDIR) { CTX->log()->error("{}() AT_REMOVEDIR flag is not supported", __func__); errno = ENOTDIR; return -1; } if(is_relative_path(path)) { if(!(CTX->file_map()->exist(dirfd))) { goto passthrough; } auto dir = CTX->file_map()->get_dir(dirfd); if(dir == nullptr) { CTX->log()->error("{}() dirfd is not a directory ", __func__); errno = ENOTDIR; return -1; } if(has_trailing_slash(path)){ path.pop_back(); } return adafs_rm_node(dir->path() + '/' + path); } else { // Path is absolute assert(is_absolute_path(path)); if (CTX->relativize_path(path)) { return adafs_rm_node(path); } } } passthrough: return (reinterpret_cast<decltype(&unlinkat)>(libc_unlinkat))(dirfd, cpath, flags); } int rmdir(const char* path) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { Loading ifs/src/preload/passthrough.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ void* libc_fileno; void* libc_mkdir; void* libc_mkdirat; void* libc_unlink; void* libc_unlinkat; void* libc_rmdir; void* libc_close; Loading Loading @@ -111,6 +112,7 @@ void init_passthrough_() { libc_mkdirat = dlsym(libc, "mkdirat"); libc_unlink = dlsym(libc, "unlink"); libc_unlinkat = dlsym(libc, "unlinkat"); libc_rmdir = dlsym(libc, "rmdir"); libc_close = dlsym(libc, "close"); Loading Loading
ifs/include/preload/passthrough.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ extern void* libc_fileno; extern void* libc_mkdir; extern void* libc_mkdirat; extern void* libc_unlink; extern void* libc_unlinkat; extern void* libc_rmdir; extern void* libc_close; Loading
ifs/src/preload/intcp_functions.cpp +40 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ #include <sys/statfs.h> #include <sys/stat.h> #include <sys/uio.h> #include <sys/unistd.h> #include <preload/preload.hpp> #include <preload/passthrough.hpp> Loading Loading @@ -326,6 +327,45 @@ int unlink(const char* path) __THROW { return (reinterpret_cast<decltype(&unlink)>(libc_unlink))(path); } int unlinkat(int dirfd, const char *cpath, int flags) { init_passthrough_if_needed(); if(CTX->initialized()) { std::string path(cpath); CTX->log()->trace("{}() called with path {}, dirfd {}, flags {}", __func__, path, dirfd, flags); if(flags & AT_REMOVEDIR) { CTX->log()->error("{}() AT_REMOVEDIR flag is not supported", __func__); errno = ENOTDIR; return -1; } if(is_relative_path(path)) { if(!(CTX->file_map()->exist(dirfd))) { goto passthrough; } auto dir = CTX->file_map()->get_dir(dirfd); if(dir == nullptr) { CTX->log()->error("{}() dirfd is not a directory ", __func__); errno = ENOTDIR; return -1; } if(has_trailing_slash(path)){ path.pop_back(); } return adafs_rm_node(dir->path() + '/' + path); } else { // Path is absolute assert(is_absolute_path(path)); if (CTX->relativize_path(path)) { return adafs_rm_node(path); } } } passthrough: return (reinterpret_cast<decltype(&unlinkat)>(libc_unlinkat))(dirfd, cpath, flags); } int rmdir(const char* path) __THROW { init_passthrough_if_needed(); if(CTX->initialized()) { Loading
ifs/src/preload/passthrough.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ void* libc_fileno; void* libc_mkdir; void* libc_mkdirat; void* libc_unlink; void* libc_unlinkat; void* libc_rmdir; void* libc_close; Loading Loading @@ -111,6 +112,7 @@ void init_passthrough_() { libc_mkdirat = dlsym(libc, "mkdirat"); libc_unlink = dlsym(libc, "unlink"); libc_unlinkat = dlsym(libc, "unlinkat"); libc_rmdir = dlsym(libc, "rmdir"); libc_close = dlsym(libc, "close"); Loading