Commit 6a960853 authored by Julius Athenstaedt's avatar Julius Athenstaedt Committed by Marc Vef
Browse files

userlib for tests

parent 34efceff
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ gkfs_define_option(

# use old resolve function
gkfs_define_option(
	GKFS_USE_OLD_PATH_RESOLVE
  GKFS_USE_LEGACY_PATH_RESOLVE
  HELP_TEXT "Use the old implementation of the resolve function"
  DEFAULT_VALUE OFF
)
+2 −2
Original line number Diff line number Diff line
@@ -272,8 +272,8 @@ if (GKFS_SYMLINK_SUPPORT)
    add_definitions(-DHAS_SYMLINKS)
endif ()

if (GKFS_USE_OLD_PATH_RESOLVE)
    add_definitions(-DGKFS_USE_OLD_PATH_RESOLVE)
if (GKFS_USE_LEGACY_PATH_RESOLVE)
    add_definitions(-DGKFS_USE_LEGACY_PATH_RESOLVE)
endif ()

if (GKFS_FOLLOW_EXTERNAL_SYMLINKS)
+5 −3
Original line number Diff line number Diff line
@@ -36,14 +36,16 @@ 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
/// @resolve_last_link is used only for the old implementation:
/// GKFS_USE_LEGACY_PATH_RESOLVE
std::pair<bool, std::string>
resolve(const std::string& path, bool resolve_last_link = true);

std::pair<bool, std::string>
resolve_new(const std::string& path);
resolve_new(const std::string& path, const std::string& mountdir);

[[deprecated("Use GKFS_USE_OLD_PATH_RESOLVE to use old implementation")]] bool
[[deprecated(
        "Use GKFS_USE_LEGACY_PATH_RESOLVE to use old implementation")]] bool
resolve(const std::string& path, std::string& resolved,
        bool resolve_last_link = true);

+4 −6
Original line number Diff line number Diff line
@@ -126,18 +126,17 @@ follow_symlinks(const string& path) {

pair<bool, string>
resolve(const string& path, bool resolve_last_link) {
#ifdef GKFS_USE_OLD_PATH_RESOLVE
#ifdef GKFS_USE_LEGACY_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);
    return resolve_new(path, CTX->mountdir());
#endif
}

pair<bool, string>
resolve_new(const string& path) {
    const string& mountdir = CTX->mountdir();
resolve_new(const string& path, const string& mountdir) {
    LOG(DEBUG, "path: \"{}\", mountdir: \"{}\"", path, mountdir);
    string resolved = "";
    stack<size_t> last_component_pos;
@@ -156,8 +155,7 @@ resolve_new(const string& path) {
        if(comp_size == 2 && path.at(start) == '.' &&
           path.at(start + 1) == '.') {
            // component is '..', we skip it
            LOG(DEBUG, "path: \"{}\", mountdir: \"{}\"", path,
                mountdir);
            LOG(DEBUG, "path: \"{}\", mountdir: \"{}\"", path, mountdir);
            resolved.erase(last_component_pos.top());
            last_component_pos.pop();
            continue;
+8 −7
Original line number Diff line number Diff line
@@ -318,9 +318,10 @@ PreloadContext::relativize_fd_path(int dirfd, const char* raw_path,
        path = raw_path;
    }

    std::pair<bool, std::string> resolved_path = gkfs::path::resolve(path, resolve_last_link);
	  relative_path = resolved_path.second;
    if(resolved_path.first) {
    auto [is_in_path, resolved_path] =
            gkfs::path::resolve(path, resolve_last_link);
    relative_path = resolved_path;
    if(is_in_path) {
        return RelativizeStatus::internal;
    }
    return RelativizeStatus::external;
@@ -350,10 +351,10 @@ PreloadContext::relativize_path(const char* raw_path,
        path = raw_path;
    }

    std::pair<bool, std::string> resolved_path = gkfs::path::resolve(path, resolve_last_link);
	  relative_path = resolved_path.second;
	  return resolved_path.first;

    auto [is_in_path, resolved_path] =
            gkfs::path::resolve(path, resolve_last_link);
    relative_path = resolved_path;
    return is_in_path;
}

const std::string&
Loading