Commit 768d555f authored by Ramon Nou's avatar Ramon Nou
Browse files

PATH shortcut needed, added extra calls

parent f01486ee
Loading
Loading
Loading
Loading
+55 −1
Original line number Original line Diff line number Diff line
@@ -52,7 +52,7 @@ std::atomic<bool> initializing{false};
// Define a debug macro, can be easily disabled
// Define a debug macro, can be easily disabled


// #define GKFS_TRACE
// #define GKFS_TRACE
// #define PATH_SHORTCUT
#define PATH_SHORTCUT


#ifdef GKFS_DEBUG_BUILD
#ifdef GKFS_DEBUG_BUILD
#ifdef GKFS_TRACE
#ifdef GKFS_TRACE
@@ -334,6 +334,13 @@ DLSYM_WRAPPER(int, fputs, (const char* str, FILE* stream), (str, stream),
DLSYM_WRAPPER(char*, fgets, (char* str, int n, FILE* stream), (str, n, stream),
DLSYM_WRAPPER(char*, fgets, (char* str, int n, FILE* stream), (str, n, stream),
              "fgets")
              "fgets")
DLSYM_WRAPPER(int, fflush, (FILE * stream), (stream), "fflush")
DLSYM_WRAPPER(int, fflush, (FILE * stream), (stream), "fflush")
DLSYM_WRAPPER(int, fchown, (int fd, uid_t owner, gid_t group),
              (fd, owner, group), "fchown")
DLSYM_WRAPPER(int, futimes, (int fd, const struct timeval times[2]),
              (fd, times), "futimes")
DLSYM_WRAPPER(int, utimes, (const char* path, const struct timeval times[2]),
              (path, times), "utimes")

/*CDLSYM_WRAPPER(ssize_t, readlink, (const char* path, char* buf, size_t
/*CDLSYM_WRAPPER(ssize_t, readlink, (const char* path, char* buf, size_t
bufsize), (path, buf, bufsize), "readlink")
bufsize), (path, buf, bufsize), "readlink")


@@ -1814,3 +1821,50 @@ munmap(void* addr, size_t length) {
    }
    }
    GKFS_FALLBACK(munmap, addr, length);
    GKFS_FALLBACK(munmap, addr, length);
}
}

// fchown
int
fchown(int fd, uid_t owner, gid_t group) {
    initializeGekko();
    if(is_gkfs_fd(fd)) {
        DEBUG_INFO("[GKFS] {}", CTX->file_map()->get(fd)->path());
        return 0;
    }
    GKFS_FALLBACK(fchown, fd, owner, group);
}

// fchmod
int
fchmod(int fd, mode_t mode) {
    initializeGekko();
    if(is_gkfs_fd(fd)) {
        DEBUG_INFO("[GKFS] {}", CTX->file_map()->get(fd)->path());
        return 0;
    }
    GKFS_FALLBACK(fchmod, fd, mode);
}

// futimes
int
futimes(int fd, const struct timeval tv[2]) {
    initializeGekko();
    if(is_gkfs_fd(fd)) {
        DEBUG_INFO("[GKFS] {}", CTX->file_map()->get(fd)->path());
        return 0;
    }
    GKFS_FALLBACK(futimes, fd, tv);
}

int
utimes(const char* path, const struct timeval tv[2]) {
    initializeGekko();
    if(CTX->interception_enabled()) {
        std::string resolved;
        if(resolve_gkfs_path(AT_FDCWD, path, resolved) ==
           PathStatus::Internal) {
            DEBUG_INFO("[GKFS] {}", resolved);
            return 0;
        }
    }
    GKFS_FALLBACK(utimes, path, tv);
}