Commit 1003d442 authored by Ramon Nou's avatar Ramon Nou Committed by Ramon Nou
Browse files

Adding pthread_atfork to syscall

parent 94ac8860
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -63,4 +63,11 @@ void
at_child();
void
at_parent();

void
at_fork_syscall();
void
at_child_syscall();
void
at_parent_syscall();
#endif // IOINTERCEPT_PRELOAD_HPP
+1 −8
Original line number Diff line number Diff line
@@ -1274,7 +1274,6 @@ lseek(int fd, off_t offset, int whence) {
    initializeGekko();
    // Is fd from GekkoFS?
    if(CTX->file_map()->exist(fd)) {
        debug_info("[xLSEEK GEKKO]....%ld %d\n", offset, whence);
        return gkfs::syscall::gkfs_lseek(fd, offset, whence);
    }

@@ -1289,7 +1288,6 @@ lseek64(int fd, off64_t offset, int whence) {
    // Is fd from GekkoFS?
    initializeGekko();
    if(CTX->file_map()->exist(fd)) {
        debug_info("[LSEEK64 GEKKO]... %d.%ld %d\n", fd, offset, whence);
        return gkfs::syscall::gkfs_lseek(fd, offset, whence);
    }

@@ -2095,8 +2093,6 @@ opendir(const char* dirname) {
                struct stat st;
                if(gkfs::syscall::gkfs_stat(resolved, &st) != 0 or
                   S_ISREG(st.st_mode)) {
                    debug_info("[BYPASS] >> opendir GKFS NOT A DIR.... %s\n",
                               dirname);
                    errno = ENOTDIR;
                    return NULL;
                }
@@ -2133,8 +2129,6 @@ opendir64(const char* dirname) {
        auto rstatus = CTX->relativize_fd_path(AT_FDCWD, dirname, resolved);
        switch(rstatus) {
            case gkfs::preload::RelativizeStatus::fd_not_a_dir:
                debug_info("[BYPASS] >> opendir64 GKFS NOT A DIR.... %s\n",
                           dirname);
                errno = ENOTDIR;
                return NULL;

@@ -2146,8 +2140,7 @@ opendir64(const char* dirname) {
                struct stat st;
                if(gkfs::syscall::gkfs_stat(resolved, &st) != 0 or
                   S_ISREG(st.st_mode)) {
                    debug_info("[BYPASS] >> opendir64 GKFS NOT A DIR.... %s\n",
                               dirname);

                    errno = ENOTDIR;
                    return NULL;
                }
+23 −1
Original line number Diff line number Diff line
@@ -346,7 +346,7 @@ init_preload() {
    // The original errno value will be restored after initialization to not
    // leak internal error codes
    auto oerrno = errno;

    pthread_atfork(&at_fork_syscall, &at_parent_syscall, &at_child_syscall);
    CTX->enable_interception();
    gkfs::preload::start_self_interception();

@@ -513,3 +513,25 @@ at_child() {
    init_libc();
    printf("%d -> x At fork child %d\n", gettid(), CTX->interception_enabled());
}


void
at_fork_syscall() {
    printf("%d ->At fork, %d\n", gettid(), CTX->interception_enabled());
    destroy_preload();
}
void
at_parent_syscall() {
    printf("%d ->At fork parent %d\n", gettid(), CTX->interception_enabled());
    init_preload();
    printf("%d -> x At fork parent %d\n", gettid(),
           CTX->interception_enabled());
}

void
at_child_syscall() {

    printf("%d ->At fork child %d\n", gettid(), CTX->interception_enabled());
    init_preload();
    printf("%d -> x At fork child %d\n", gettid(), CTX->interception_enabled());
}