Unverified Commit a7795a9d authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

intercept statat

parent 76ea4f61
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ extern void* libc___xstat;
extern void* libc___xstat64;
extern void* libc___fxstat;
extern void* libc___fxstat64;
extern void* libc___fxstatat;
extern void* libc___fxstatat64;
extern void* libc___lxstat;
extern void* libc___lxstat64;

+27 −0
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@
 * All intercepted functions are defined here
 */
#include <sys/statfs.h>
#include <sys/stat.h>
#include <sys/uio.h>

#include <preload/preload.hpp>
#include <preload/passthrough.hpp>
@@ -402,6 +404,31 @@ int __fxstat(int ver, int fd, struct stat* buf) __THROW {
    return (reinterpret_cast<decltype(&__fxstat)>(libc___fxstat))(ver, fd, buf);
}

int __fxstatat(int ver, int dirfd, const char * path, struct stat * buf, int flags) {
    init_passthrough_if_needed();
    if(CTX->initialized()) {
        CTX->log()->trace("{}() called with path '{}'", __func__, path);
        std::string rel_path(path);
        if (CTX->relativize_path(rel_path)) {
            return adafs_stat(rel_path, buf);
        }
    }
    return (reinterpret_cast<decltype(&__fxstatat)>(libc___fxstatat))(ver, dirfd, path, buf, flags);
}

int __fxstatat64(int ver, int dirfd, const char * path, struct stat64 * buf, int flags) {
    init_passthrough_if_needed();
    if(CTX->initialized()) {
        CTX->log()->trace("{}() called with path '{}'", __func__, path);
        std::string rel_path(path);
        if (CTX->relativize_path(rel_path)) {
            return adafs_stat64(rel_path, buf);
        }
    }
    return (reinterpret_cast<decltype(&__fxstatat64)>(libc___fxstatat64))(ver, dirfd, path, buf, flags);

}

int __fxstat64(int ver, int fd, struct stat64* buf) __THROW {
    init_passthrough_if_needed();
    if(CTX->initialized()) {
+4 −0
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ void* libc___xstat;
void* libc___xstat64;
void* libc___fxstat;
void* libc___fxstat64;
void* libc___fxstatat;
void* libc___fxstatat64;
void* libc___lxstat;
void* libc___lxstat64;

@@ -118,6 +120,8 @@ void init_passthrough_() {
    libc___xstat64 = dlsym(libc, "__xstat64");
    libc___fxstat = dlsym(libc, "__fxstat");
    libc___fxstat64 = dlsym(libc, "__fxstat64");
    libc___fxstatat = dlsym(libc, "__fxstatat");
    libc___fxstatat64 = dlsym(libc, "__fxstatat64");
    libc___lxstat = dlsym(libc, "__lxstat");
    libc___lxstat64 = dlsym(libc, "__lxstat64");