Commit d14bac97 authored by Ramon Nou's avatar Ramon Nou
Browse files

unlink should not follow link files (remove only link)

parent 541cdd51
Loading
Loading
Loading
Loading
Loading
+20 −16
Original line number Diff line number Diff line
@@ -325,7 +325,7 @@ gkfs_create(const std::string& path, mode_t mode) {
 */
int
gkfs_remove(const std::string& path) {
#ifdef HAS_SYMLINKS

#ifdef HAS_RENAME
    auto md = gkfs::utils::get_metadata(path);
    if(!md) {
@@ -337,17 +337,20 @@ gkfs_remove(const std::string& path) {
        errno = EISDIR;
        return -1;
    }

    if(md.value().blocks() == -1) {
        errno = ENOENT;
        return -1;
    } else {
        if(!md->is_link()) {
            if(!md.value().target_path().empty()) {
                auto md_ = gkfs::utils::get_metadata(md.value().target_path());
                std::string new_path = md.value().target_path();
                while(!md.value().target_path().empty() and
                      md.value().blocks() != -1) {
                    new_path = md.value().target_path();
                md = gkfs::utils::get_metadata(md.value().target_path(), false);
                    md = gkfs::utils::get_metadata(md.value().target_path(),
                                                   false);
                    if(!md) {
                        return -1;
                    }
@@ -360,8 +363,9 @@ gkfs_remove(const std::string& path) {
                }
            }
        }
    }
#endif // HAS_RENAME
#endif // HAS_SYMLINKS

    int err = 0;
    if(gkfs::config::proxy::fwd_remove && CTX->use_proxy()) {
        err = gkfs::rpc::forward_remove_proxy(path, false);
+2 −3
Original line number Diff line number Diff line
@@ -1158,7 +1158,6 @@ int
rename(const char* oldpath, const char* newpath) {
    initializeGekko();
    // Is path from GekkoFS?
    DEBUG_INFO("rename {} --> {}", oldpath, newpath);
    if(CTX->interception_enabled()) {
        std::string resolved_old;
        std::string resolved_new;
@@ -1170,8 +1169,8 @@ rename(const char* oldpath, const char* newpath) {
            case PathStatus::Internal:
                switch(rstatus_new) {
                    case PathStatus::Internal:
                        DEBUG_INFO("[GKFS] {} {}{}", "NOT IMPLEMENTED",
                                   resolved_old, resolved_new);
                        DEBUG_INFO("[GKFS] {} {} {}", "Renaming", resolved_old,
                                   resolved_new);

                        return gkfs::syscall::gkfs_rename(resolved_old,
                                                          resolved_new);