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

numa error solved

parent f75b8bd8
Loading
Loading
Loading
Loading
+72 −8
Original line number Diff line number Diff line
@@ -252,7 +252,38 @@ DLSYM_WRAPPER(struct dirent64*, readdir64, (DIR * dirp), (dirp), "readdir64")
DLSYM_WRAPPER(int, closedir, (DIR * dirp), (dirp), "closedir")
DLSYM_WRAPPER(void, seekdir, (DIR * dirp, long loc), (dirp, loc), "seekdir")
DLSYM_WRAPPER(long, telldir, (DIR * dirp), (dirp), "telldir")
// DLSYM_WRAPPER(int, fork, (void), (), "fork")

static int (*real_fork)(void) = nullptr;
int
dlsym_fork(void) {
    if(!real_fork) {
        real_fork =
                reinterpret_cast<int (*)(void)>(dlsym(((void*) -1l), "fork"));
        if(!real_fork) {
            fprintf(stderr, "dlsym failed for %s: %s\n", "fork", dlerror());
            (*__errno_location()) = 38;
            return (int) -1;
        }
    }
    log_arguments("fork");
    return real_fork();
}
static int (*real_vfork)(void) = nullptr;
int
dlsym_vfork(void) {
    if(!real_vfork) {
        real_vfork =
                reinterpret_cast<int (*)(void)>(dlsym(((void*) -1l), "vfork"));
        if(!real_vfork) {
            fprintf(stderr, "dlsym failed for %s: %s\n", "vfork", dlerror());
            (*__errno_location()) = 38;
            return (int) -1;
        }
    }
    log_arguments("vfork");
    return real_vfork();
}

DLSYM_WRAPPER(int, pipe, (int pipefd[2]), (pipefd), "pipe")
DLSYM_WRAPPER(int, dup, (int fd), (fd), "dup")
DLSYM_WRAPPER(int, dup2, (int fd, int fd2), (fd, fd2), "dup2")
@@ -303,8 +334,8 @@ DLSYM_WRAPPER(int, fputs, (const char* str, FILE* stream), (str, stream),
DLSYM_WRAPPER(char*, fgets, (char* str, int n, FILE* stream), (str, n, stream),
              "fgets")
DLSYM_WRAPPER(int, fflush, (FILE * stream), (stream), "fflush")
CDLSYM_WRAPPER(ssize_t, readlink, (const char* path, char* buf, size_t bufsize),
               (path, buf, bufsize), "readlink")
/*CDLSYM_WRAPPER(ssize_t, readlink, (const char* path, char* buf, size_t
bufsize), (path, buf, bufsize), "readlink")

CDLSYM_WRAPPER(ssize_t, readlinkat,
               (int dfd, const char* path, char* buf, size_t bufsize),
@@ -329,6 +360,14 @@ CDLSYM_WRAPPER(int, execv, (const char* filename, char* const argv[]),
CDLSYM_WRAPPER(int, fexecve, (int fd, const char* filename, char* const argv[]),
               (fd, filename, argv), "fexecve")

CDLSYM_WRAPPER(int, execvpe, (const char* filename, char* const argv[], char*
const envp[]), (filename, argv, envp), "execvpe")

               CDLSYM_WRAPPER(int, execvp, (const char* filename, char* const
argv[]), (filename, argv), "execvp")



DLSYM_WRAPPER(long, syscall, (long number, char* cmd, void* arg, void* env),
              (number, cmd, arg, env), "syscall")

@@ -346,6 +385,7 @@ syscall(long number, ...) {
    va_end(myargs);
    return res;
}
    */
/* not used */
/*static void
convert(struct stat64* src, struct stat* dest) {
@@ -1028,12 +1068,13 @@ rename(const char* oldpath, const char* newpath) {
/*
pid_t
fork(void) {
    // DEBUG_INFO("[BYPASS] >> Begin fork() %p\n", (void*) &activated);

    printf("[BYPASS] >> Begin fork() %p\n", (void*) &activated);
    pid_t ret = dlsym_fork();
    if(0 == ret) {
        // We want the children to be initialized
        // DEBUG_INFO("%d -> %d I am the child %p\n", ret, getpid(),
        //           (void*) &activated);
        printf("%d -> %d I am the child %p\n", ret, getpid(),
                   (void*) &activated);

        // DEBUG_INFO("[BYPASS] >> ACTIVATED GEKKOFS (child).... \n");
        //  initializing = false;
@@ -1042,11 +1083,34 @@ fork(void) {
        // getpid());
        return ret;
    }

    // initializing = false;
    // init_libc();

    // DEBUG_INFO("%d -> %d [BYPASS] << After fork() %p\n", ret, getpid(),
    //           (void*) &activated);
    printf("%d -> %d [BYPASS] << After fork() %p\n", ret, getpid(),
               (void*) &activated);

    return ret;
}
*/
/*
pid_t
vfork(void) {

    printf("[BYPASS] >> Begin vfork() %p\n", (void*) &activated);
    pid_t ret = dlsym_vfork();
    if(0 == ret) {
        // We want the children to be initialized


        // DEBUG_INFO("[BYPASS] >> ACTIVATED GEKKOFS (child).... \n");
        //  initializing = false;
        //at_child();
        printf("%d -> %d I am the child vfork\n", ret, getpid());
        return ret;
    }

    // initializing = false;

    return ret;
}