Commit 532bf230 authored by Ramon Nou's avatar Ramon Nou
Browse files

lstat support for wacomm libc

parent 101037d2
Loading
Loading
Loading
Loading
Loading
+24 −4
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ std::atomic<bool> initializing{false};
 */
// Define a debug macro, can be easily disabled

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

#ifdef GKFS_DEBUG_BUILD
@@ -280,9 +280,12 @@ DLSYM_WRAPPER(int, xstat64, (int ver, const char* path, struct stat64* buf),
              (ver, path, buf), "__xstat64")
DLSYM_WRAPPER(int, fxstat64, (int ver, int fd, struct stat64* buf),
              (ver, fd, buf), "__fxstat64")
DLSYM_WRAPPER(int, lstat, (int ver, const char* path, struct stat* buf),
DLSYM_WRAPPER(int, __lxstat, (int ver, const char* path, struct stat* buf),
              (ver, path, buf), "__lxstat")

DLSYM_WRAPPER(int, lstat, (const char* path, struct stat* buf),
              (path, buf), "lstat")

DLSYM_WRAPPER(int, lstat64, (const char* path, struct stat64* buf), (path, buf),
              "lstat64")

@@ -994,7 +997,7 @@ __lxstat(int ver, const char* path, struct stat* buf) {
            }
        }
    }
    GKFS_FALLBACK(lstat, ver, path, buf);
    GKFS_FALLBACK(__lxstat, ver, path, buf);
}

int
@@ -2153,6 +2156,20 @@ llistxattr(const char* path, char* list, size_t size) {
    GKFS_FALLBACK(llistxattr, path, list, size);
}

int
lstat(const char* path, struct stat* st) {
    initializeGekko();
    if(CTX->interception_enabled()) {
        std::string resolved;
        if(resolve_gkfs_path(AT_FDCWD, path, resolved, 0, false) ==
           PathStatus::Internal) {
            DEBUG_INFO("[GKFS] {}", resolved);
            auto res = gkfs::syscall::gkfs_stat(resolved, st, false);
            return res;
        }
    }
    GKFS_FALLBACK(lstat, path, st);
}

int
lstat64(const char* path, struct stat64* buf) {
@@ -2556,3 +2573,6 @@ renameat2(int olddirfd, const char* oldpath, int newdirfd, const char* newpath,
    }
    GKFS_FALLBACK(renameat2, olddirfd, oldpath, newdirfd, newpath, flags);
}