Commit 05b4b8dc authored by Ramon Nou's avatar Ramon Nou Committed by Ramon Nou
Browse files

Solve Chain of renames

parent 0d3b8e50
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -95,8 +95,8 @@ MERCURY_GEN_PROC(rpc_mk_symlink_in_t, ((hg_const_string_t) (path))((

#endif
#ifdef HAS_RENAME
MERCURY_GEN_PROC(rpc_rename_in_t, ((hg_const_string_t) (path))((
                                              hg_const_string_t) (target_path)))
MERCURY_GEN_PROC(rpc_rename_in_t, ((hg_const_string_t) (path))(
                                          (hg_const_string_t) (target_path)))

#endif

+9 −0
Original line number Diff line number Diff line
@@ -436,6 +436,15 @@ gkfs_rename(const string& old_path, const string& new_path) {
    if(!md_old || md_old.value().blocks() == -1) {
        return -1;
    }
    if(!md_old.value().target_path().empty()) {
        // the file is a renamed one, we need to get the metadata of the
        // original file. (There will be only one level)
        md_old = gkfs::utils::get_metadata(md_old.value().target_path(), false);
        if(!md_old) {
            return -1;
        }
    }

    auto md_new = gkfs::utils::get_metadata(new_path, false);
    if(md_new) {
        // the new file exists... check for circular...
+4 −0
Original line number Diff line number Diff line
@@ -385,7 +385,9 @@ hook_symlinkat(const char* oldname, int newdfd, const char* newname) {
    LOG(DEBUG, "{}() called with oldname: \"{}\", newfd: {}, newname: \"{}\"",
        __func__, oldname, newdfd, newname);

#ifdef HAS_SYMLINKS
    bool internal1 = false;
#endif
    std::string oldname_resolved;
    if(CTX->relativize_path(oldname, oldname_resolved)) {
#ifdef HAS_SYMLINKS
@@ -417,6 +419,8 @@ hook_symlinkat(const char* oldname, int newdfd, const char* newname) {
                return with_errno(gkfs::syscall::gkfs_mk_symlink(
                        newname_resolved, oldname_resolved));
            }
            LOG(WARNING, "{}() operation not supported", __func__);
            return -ENOTSUP;
#else
            LOG(WARNING, "{}() operation not supported", __func__);
            return -ENOTSUP;
+7 −7
Original line number Diff line number Diff line
@@ -125,7 +125,8 @@ follow_symlinks(const string& path) {
    if(S_ISLNK(st.st_mode)) {
        auto link_resolved = ::unique_ptr<char[]>(new char[PATH_MAX]);
        if(real_realpath == nullptr) {
		real_realpath = reinterpret_cast<char* (*) (const char* path, char* resolved_path)>(
            real_realpath = reinterpret_cast<char* (*) (const char* path,
                                                        char* resolved_path)>(
                    dlsym(((void*) -1l), "realpath"));
        }

@@ -218,7 +219,6 @@ resolve_new(const string& path, bool resolve_last_link) {
    }
    LOG(DEBUG, "external: \"{}\"", resolved);
    return make_pair(false, resolved);

}

/** Resolve path to its canonical representation
+3 −6
Original line number Diff line number Diff line
@@ -206,9 +206,6 @@ load_hostfile(const std::string& path) {
        // convert match[11] and match[12] to unsigned integers.
        CTX->fs_conf()->uid = std::stoi(match[11]);
        CTX->fs_conf()->gid = std::stoi(match[12]);



    }
    if(hosts.empty()) {
        throw runtime_error(
Loading