Loading CMake/gkfs-options.cmake +16 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,14 @@ gkfs_define_option( DEFAULT_VALUE OFF ) # use old resolve function gkfs_define_option( GKFS_USE_OLD_PATH_RESOLVE HELP_TEXT "Use the old implementation of the resolve function" DEFAULT_VALUE OFF ) cmake_dependent_option(GKFS_INSTALL_TESTS "Install GekkoFS self tests" OFF "GKFS_BUILD_TESTS" OFF) Loading Loading @@ -265,6 +273,14 @@ gkfs_define_option( DESCRIPTION "Compile with support for rename ops (experimental)" ) ## external link support gkfs_define_option( GKFS_FOLLOW_EXTERNAL_SYMLINKS HELP_TEXT "Enable support for following external links for resolving the path" DEFAULT_VALUE OFF DESCRIPTION "Compile with lstat usage in path resolve" ) ################################################################################ # Options and variables that control how GekkoFS behaves internally Loading CMakeLists.txt +8 −0 Original line number Diff line number Diff line Loading @@ -272,6 +272,14 @@ if (GKFS_SYMLINK_SUPPORT) add_definitions(-DHAS_SYMLINKS) endif () if (GKFS_USE_OLD_PATH_RESOLVE) add_definitions(-DGKFS_USE_OLD_PATH_RESOLVE) endif () if (GKFS_FOLLOW_EXTERNAL_SYMLINKS) add_definitions(-DGKFS_FOLLOW_EXTERNAL_SYMLINKS) endif () if (GKFS_RENAME_SUPPORT) # Rename depends on symlink support add_definitions(-DHAS_SYMLINKS) Loading include/client/path.hpp +6 −2 Original line number Diff line number Diff line Loading @@ -36,10 +36,14 @@ unsigned int match_components(const std::string& path, unsigned int& path_components, const std::vector<std::string>& components); /// @resolve_last_link is used only for the old implementation: GKFS_USE_OLD_PATH_RESOLVE std::pair<bool, std::string> resolve_new(const std::string& path, std::string mountdir); resolve(const std::string& path, bool resolve_last_link = true); bool std::pair<bool, std::string> resolve_new(const std::string& path); [[deprecated("Use GKFS_USE_OLD_PATH_RESOLVE to use old implementation")]] bool resolve(const std::string& path, std::string& resolved, bool resolve_last_link = true); Loading src/client/path.cpp +16 −4 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ #include <vector> #include <string> #include <cassert> #include <climits> #ifndef BYPASS_SYSCALL #include <libsyscall_intercept_hook_point.h> Loading Loading @@ -126,7 +125,19 @@ follow_symlinks(const string& path) { } pair<bool, string> resolve_new(const string& path, string mountdir) { resolve(const string& path, bool resolve_last_link) { #ifdef GKFS_USE_OLD_PATH_RESOLVE string resolved; bool is_in_path = resolve(path, resolved, resolve_last_link); return make_pair(is_in_path, resolved); #else return resolve_new(path); #endif } pair<bool, string> resolve_new(const string& path) { const string& mountdir = CTX->mountdir(); LOG(DEBUG, "path: \"{}\", mountdir: \"{}\"", path, mountdir); string resolved = ""; stack<size_t> last_component_pos; Loading @@ -145,7 +156,8 @@ resolve_new(const string& path, string mountdir) { if(comp_size == 2 && path.at(start) == '.' && path.at(start + 1) == '.') { // component is '..', we skip it assert(!last_component_pos.empty()); LOG(DEBUG, "path: \"{}\", mountdir: \"{}\"", path, mountdir); resolved.erase(last_component_pos.top()); last_component_pos.pop(); continue; Loading @@ -155,7 +167,7 @@ resolve_new(const string& path, string mountdir) { last_component_pos.push(resolved.size() - 1); resolved.append(path, start, comp_size); #ifdef GKFS_FOLLOW_SYMLINKS // HAS_SYMLINKS ??? #ifdef GKFS_FOLLOW_EXTERNAL_SYMLINKS resolved = follow_symlinks(resolved); #endif } Loading src/client/preload_context.cpp +8 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ #include <cassert> #include <filesystem> #include <utility> #ifndef BYPASS_SYSCALL #include <libsyscall_intercept_hook_point.h> Loading Loading @@ -317,7 +318,9 @@ PreloadContext::relativize_fd_path(int dirfd, const char* raw_path, path = raw_path; } if(gkfs::path::resolve(path, relative_path, resolve_last_link)) { std::pair<bool, std::string> resolved_path = gkfs::path::resolve(path, resolve_last_link); relative_path = resolved_path.second; if(resolved_path.first) { return RelativizeStatus::internal; } return RelativizeStatus::external; Loading Loading @@ -347,7 +350,10 @@ PreloadContext::relativize_path(const char* raw_path, path = raw_path; } return gkfs::path::resolve(path, relative_path, resolve_last_link); std::pair<bool, std::string> resolved_path = gkfs::path::resolve(path, resolve_last_link); relative_path = resolved_path.second; return resolved_path.first; } const std::string& Loading Loading
CMake/gkfs-options.cmake +16 −0 Original line number Diff line number Diff line Loading @@ -234,6 +234,14 @@ gkfs_define_option( DEFAULT_VALUE OFF ) # use old resolve function gkfs_define_option( GKFS_USE_OLD_PATH_RESOLVE HELP_TEXT "Use the old implementation of the resolve function" DEFAULT_VALUE OFF ) cmake_dependent_option(GKFS_INSTALL_TESTS "Install GekkoFS self tests" OFF "GKFS_BUILD_TESTS" OFF) Loading Loading @@ -265,6 +273,14 @@ gkfs_define_option( DESCRIPTION "Compile with support for rename ops (experimental)" ) ## external link support gkfs_define_option( GKFS_FOLLOW_EXTERNAL_SYMLINKS HELP_TEXT "Enable support for following external links for resolving the path" DEFAULT_VALUE OFF DESCRIPTION "Compile with lstat usage in path resolve" ) ################################################################################ # Options and variables that control how GekkoFS behaves internally Loading
CMakeLists.txt +8 −0 Original line number Diff line number Diff line Loading @@ -272,6 +272,14 @@ if (GKFS_SYMLINK_SUPPORT) add_definitions(-DHAS_SYMLINKS) endif () if (GKFS_USE_OLD_PATH_RESOLVE) add_definitions(-DGKFS_USE_OLD_PATH_RESOLVE) endif () if (GKFS_FOLLOW_EXTERNAL_SYMLINKS) add_definitions(-DGKFS_FOLLOW_EXTERNAL_SYMLINKS) endif () if (GKFS_RENAME_SUPPORT) # Rename depends on symlink support add_definitions(-DHAS_SYMLINKS) Loading
include/client/path.hpp +6 −2 Original line number Diff line number Diff line Loading @@ -36,10 +36,14 @@ unsigned int match_components(const std::string& path, unsigned int& path_components, const std::vector<std::string>& components); /// @resolve_last_link is used only for the old implementation: GKFS_USE_OLD_PATH_RESOLVE std::pair<bool, std::string> resolve_new(const std::string& path, std::string mountdir); resolve(const std::string& path, bool resolve_last_link = true); bool std::pair<bool, std::string> resolve_new(const std::string& path); [[deprecated("Use GKFS_USE_OLD_PATH_RESOLVE to use old implementation")]] bool resolve(const std::string& path, std::string& resolved, bool resolve_last_link = true); Loading
src/client/path.cpp +16 −4 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ #include <vector> #include <string> #include <cassert> #include <climits> #ifndef BYPASS_SYSCALL #include <libsyscall_intercept_hook_point.h> Loading Loading @@ -126,7 +125,19 @@ follow_symlinks(const string& path) { } pair<bool, string> resolve_new(const string& path, string mountdir) { resolve(const string& path, bool resolve_last_link) { #ifdef GKFS_USE_OLD_PATH_RESOLVE string resolved; bool is_in_path = resolve(path, resolved, resolve_last_link); return make_pair(is_in_path, resolved); #else return resolve_new(path); #endif } pair<bool, string> resolve_new(const string& path) { const string& mountdir = CTX->mountdir(); LOG(DEBUG, "path: \"{}\", mountdir: \"{}\"", path, mountdir); string resolved = ""; stack<size_t> last_component_pos; Loading @@ -145,7 +156,8 @@ resolve_new(const string& path, string mountdir) { if(comp_size == 2 && path.at(start) == '.' && path.at(start + 1) == '.') { // component is '..', we skip it assert(!last_component_pos.empty()); LOG(DEBUG, "path: \"{}\", mountdir: \"{}\"", path, mountdir); resolved.erase(last_component_pos.top()); last_component_pos.pop(); continue; Loading @@ -155,7 +167,7 @@ resolve_new(const string& path, string mountdir) { last_component_pos.push(resolved.size() - 1); resolved.append(path, start, comp_size); #ifdef GKFS_FOLLOW_SYMLINKS // HAS_SYMLINKS ??? #ifdef GKFS_FOLLOW_EXTERNAL_SYMLINKS resolved = follow_symlinks(resolved); #endif } Loading
src/client/preload_context.cpp +8 −2 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ #include <cassert> #include <filesystem> #include <utility> #ifndef BYPASS_SYSCALL #include <libsyscall_intercept_hook_point.h> Loading Loading @@ -317,7 +318,9 @@ PreloadContext::relativize_fd_path(int dirfd, const char* raw_path, path = raw_path; } if(gkfs::path::resolve(path, relative_path, resolve_last_link)) { std::pair<bool, std::string> resolved_path = gkfs::path::resolve(path, resolve_last_link); relative_path = resolved_path.second; if(resolved_path.first) { return RelativizeStatus::internal; } return RelativizeStatus::external; Loading Loading @@ -347,7 +350,10 @@ PreloadContext::relativize_path(const char* raw_path, path = raw_path; } return gkfs::path::resolve(path, relative_path, resolve_last_link); std::pair<bool, std::string> resolved_path = gkfs::path::resolve(path, resolve_last_link); relative_path = resolved_path.second; return resolved_path.first; } const std::string& Loading