Loading src/client/gkfs_functions.cpp +2 −22 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ namespace gkfs::syscall { * @return 0 on success, -1 on failure */ int gkfs_open(const std::string& path, mode_t mode, int flags) { gkfs_open(const std::string& path, mode_t mode, int flags, bool force) { // metadata object filled during create or stat gkfs::metadata::Metadata md{}; if(flags & O_CREAT) { Loading Loading @@ -156,7 +156,7 @@ gkfs_open(const std::string& path, mode_t mode, int flags) { md = *md_; #ifdef HAS_RENAME // This is an old file that was renamed which we do not open if(md.blocks() == -1) { if(md.blocks() == -1 and !force) { LOG(DEBUG, "This file was renamed and we do not open. path '{}'", path); Loading Loading @@ -1687,26 +1687,6 @@ gkfs_mk_symlink(const std::string& path, const std::string& target_path) { errno = ENOTSUP; return -1; } // Check for renamed files if(target_md->blocks() == -1) { // This is an old file that was renamed and essentially no longer // exists errno = ENOENT; return -1; } else { if(!target_md->is_link()) { if(!target_md.value().target_path().empty()) { auto md_ = gkfs::utils::get_metadata( target_md.value().target_path()); new_path = target_md.value().target_path(); if(!md_) { return -1; } } } } } if(check_parent_dir(path)) { Loading src/client/gkfs_libc.cpp +28 −0 Original line number Diff line number Diff line Loading @@ -443,6 +443,10 @@ DLSYM_WRAPPER(int, scandir, DLSYM_WRAPPER(int, symlink, (const char* path1, const char* path2), (path1, path2), "symlink") DLSYM_WRAPPER(int, symlinkat, (int dfd, const char* path1, int dfd2, const char* path2), (dfd, path1, dfd2, path2), "symlinkat") // NEED HAS_SYMLINKS DLSYM_WRAPPER(ssize_t, readlink, (const char* path, char* buf, size_t bufsize), (path, buf, bufsize), "readlink") Loading Loading @@ -2241,6 +2245,30 @@ symlink(const char* path1, const char* path2) { GKFS_FALLBACK(symlink, path1, path2); } int symlinkat(int dfd, const char* path1, int dfd2, const char* path2) { initializeGekko(); if(CTX->interception_enabled()) { std::string resolved; if(resolve_gkfs_path(dfd, path1, resolved) == PathStatus::Internal) { DEBUG_INFO("[GKFS] path 1 internal {}", resolved); std::string resolved2; if(resolve_gkfs_path(dfd2, path2, resolved2) == PathStatus::Internal) { DEBUG_INFO("[GKFS] path 2 internal {}", resolved2); #ifdef HAS_SYMLINKS // In Gekko we invert the parameters. return gkfs::syscall::gkfs_mk_symlink(resolved2, resolved); #else DEBUG_INFO("[GKFS] symlinks not supported/compiled"); errno = ENOTSUP; return -1; #endif } } } GKFS_FALLBACK(symlinkat, dfd, path1, dfd2, path2); } #ifdef HAS_SYMLINKS ssize_t readlink(const char* path, char* buf, size_t bufsize) { Loading Loading
src/client/gkfs_functions.cpp +2 −22 Original line number Diff line number Diff line Loading @@ -125,7 +125,7 @@ namespace gkfs::syscall { * @return 0 on success, -1 on failure */ int gkfs_open(const std::string& path, mode_t mode, int flags) { gkfs_open(const std::string& path, mode_t mode, int flags, bool force) { // metadata object filled during create or stat gkfs::metadata::Metadata md{}; if(flags & O_CREAT) { Loading Loading @@ -156,7 +156,7 @@ gkfs_open(const std::string& path, mode_t mode, int flags) { md = *md_; #ifdef HAS_RENAME // This is an old file that was renamed which we do not open if(md.blocks() == -1) { if(md.blocks() == -1 and !force) { LOG(DEBUG, "This file was renamed and we do not open. path '{}'", path); Loading Loading @@ -1687,26 +1687,6 @@ gkfs_mk_symlink(const std::string& path, const std::string& target_path) { errno = ENOTSUP; return -1; } // Check for renamed files if(target_md->blocks() == -1) { // This is an old file that was renamed and essentially no longer // exists errno = ENOENT; return -1; } else { if(!target_md->is_link()) { if(!target_md.value().target_path().empty()) { auto md_ = gkfs::utils::get_metadata( target_md.value().target_path()); new_path = target_md.value().target_path(); if(!md_) { return -1; } } } } } if(check_parent_dir(path)) { Loading
src/client/gkfs_libc.cpp +28 −0 Original line number Diff line number Diff line Loading @@ -443,6 +443,10 @@ DLSYM_WRAPPER(int, scandir, DLSYM_WRAPPER(int, symlink, (const char* path1, const char* path2), (path1, path2), "symlink") DLSYM_WRAPPER(int, symlinkat, (int dfd, const char* path1, int dfd2, const char* path2), (dfd, path1, dfd2, path2), "symlinkat") // NEED HAS_SYMLINKS DLSYM_WRAPPER(ssize_t, readlink, (const char* path, char* buf, size_t bufsize), (path, buf, bufsize), "readlink") Loading Loading @@ -2241,6 +2245,30 @@ symlink(const char* path1, const char* path2) { GKFS_FALLBACK(symlink, path1, path2); } int symlinkat(int dfd, const char* path1, int dfd2, const char* path2) { initializeGekko(); if(CTX->interception_enabled()) { std::string resolved; if(resolve_gkfs_path(dfd, path1, resolved) == PathStatus::Internal) { DEBUG_INFO("[GKFS] path 1 internal {}", resolved); std::string resolved2; if(resolve_gkfs_path(dfd2, path2, resolved2) == PathStatus::Internal) { DEBUG_INFO("[GKFS] path 2 internal {}", resolved2); #ifdef HAS_SYMLINKS // In Gekko we invert the parameters. return gkfs::syscall::gkfs_mk_symlink(resolved2, resolved); #else DEBUG_INFO("[GKFS] symlinks not supported/compiled"); errno = ENOTSUP; return -1; #endif } } } GKFS_FALLBACK(symlinkat, dfd, path1, dfd2, path2); } #ifdef HAS_SYMLINKS ssize_t readlink(const char* path, char* buf, size_t bufsize) { Loading