Loading include/client/passthrough.hpp +107 −109 Original line number Diff line number Diff line Loading @@ -2,119 +2,117 @@ #define IFS_PASSTHROUGH_HPP #define LIBC_FUNC_NAME(FNAME) libc_##FNAME #define LIBC_FUNC(FNAME, ...) \ ((reinterpret_cast<decltype(&FNAME)>(libc_##FNAME))(__VA_ARGS__)) // function pointer for preloading extern void* libc; extern void* libc_open; extern void* libc_openat; extern void* libc_fopen; extern void* libc_fopen64; extern void* libc_fread; extern void* libc_fwrite; extern void* libc_fclose; extern void* libc_clearerr; extern void* libc_feof; extern void* libc_ferror; extern void* libc_fileno; extern void* libc_fflush; extern void* libc_fpurge; extern void* libc___fpurge; extern void* libc_setbuf; extern void* libc_setbuffer; extern void* libc_setlinebuf; extern void* libc_setvbuf; extern void* libc_putc; extern void* libc_fputc; extern void* libc_fputs; extern void* libc_getc; extern void* libc_fgetc; extern void* libc_fgets; extern void* libc_ungetc; extern void* libc_fseek; extern void* libc_mkdir; extern void* libc_mkdirat; extern void* libc_unlink; extern void* libc_unlinkat; extern void* libc_rmdir; extern void* libc_close; extern void* libc_access; extern void* libc_faccessat; extern void* libc_stat; extern void* libc_fstat; extern void* libc_lstat; 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; extern void* libc_statfs; extern void* libc_fstatfs; extern void* libc_statvfs; extern void* libc_fstatvfs; extern void* libc_write; extern void* libc_pwrite; extern void* libc_pwrite64; extern void* libc_writev; extern void* libc_read; extern void* libc_pread; extern void* libc_pread64; extern void* libc_readv; extern void* libc_lseek; extern void* libc_lseek64; extern void* libc_fsync; extern void* libc_fdatasync; extern void* libc_truncate; extern void* libc_ftruncate; extern void* libc_fcntl; extern void* libc_dup; extern void* libc_dup2; extern void* libc_dup3; extern void* libc_dirfd; extern void* libc_opendir; extern void* libc_fdopendir; extern void* libc_readdir; extern void* libc_closedir; extern void* libc_chmod; extern void* libc_fchmod; extern void* libc_fchmodat; extern void* libc_chdir; extern void* libc_fchdir; extern void* libc_getcwd; extern void* libc_get_current_dir_name; extern void* libc_link; extern void* libc_linkat; extern void* libc_symlinkat; extern void* libc_readlinkat; extern void* libc_realpath; extern void* LIBC_FUNC_NAME(open); extern void* LIBC_FUNC_NAME(openat); extern void* LIBC_FUNC_NAME(fopen); extern void* LIBC_FUNC_NAME(fopen64); extern void* LIBC_FUNC_NAME(fread); extern void* LIBC_FUNC_NAME(fwrite); extern void* LIBC_FUNC_NAME(fclose); extern void* LIBC_FUNC_NAME(clearerr); extern void* LIBC_FUNC_NAME(feof); extern void* LIBC_FUNC_NAME(ferror); extern void* LIBC_FUNC_NAME(fileno); extern void* LIBC_FUNC_NAME(fflush); extern void* LIBC_FUNC_NAME(__fpurge); extern void* LIBC_FUNC_NAME(setbuf); extern void* LIBC_FUNC_NAME(setbuffer); extern void* LIBC_FUNC_NAME(setlinebuf); extern void* LIBC_FUNC_NAME(setvbuf); extern void* LIBC_FUNC_NAME(putc); extern void* LIBC_FUNC_NAME(fputc); extern void* LIBC_FUNC_NAME(fputs); extern void* LIBC_FUNC_NAME(getc); extern void* LIBC_FUNC_NAME(fgetc); extern void* LIBC_FUNC_NAME(fgets); extern void* LIBC_FUNC_NAME(ungetc); extern void* LIBC_FUNC_NAME(fseek); extern void* LIBC_FUNC_NAME(mkdir); extern void* LIBC_FUNC_NAME(mkdirat); extern void* LIBC_FUNC_NAME(unlink); extern void* LIBC_FUNC_NAME(unlinkat); extern void* LIBC_FUNC_NAME(rmdir); extern void* LIBC_FUNC_NAME(close); extern void* LIBC_FUNC_NAME(access); extern void* LIBC_FUNC_NAME(faccessat); extern void* LIBC_FUNC_NAME(__xstat); extern void* LIBC_FUNC_NAME(__xstat64); extern void* LIBC_FUNC_NAME(__fxstat); extern void* LIBC_FUNC_NAME(__fxstat64); extern void* LIBC_FUNC_NAME(__fxstatat); extern void* LIBC_FUNC_NAME(__fxstatat64); extern void* LIBC_FUNC_NAME(__lxstat); extern void* LIBC_FUNC_NAME(__lxstat64); extern void* LIBC_FUNC_NAME(statfs); extern void* LIBC_FUNC_NAME(fstatfs); extern void* LIBC_FUNC_NAME(statvfs); extern void* LIBC_FUNC_NAME(fstatvfs); extern void* LIBC_FUNC_NAME(write); extern void* LIBC_FUNC_NAME(pwrite); extern void* LIBC_FUNC_NAME(pwrite64); extern void* LIBC_FUNC_NAME(writev); extern void* LIBC_FUNC_NAME(read); extern void* LIBC_FUNC_NAME(pread); extern void* LIBC_FUNC_NAME(pread64); extern void* LIBC_FUNC_NAME(readv); extern void* LIBC_FUNC_NAME(lseek); extern void* LIBC_FUNC_NAME(lseek64); extern void* LIBC_FUNC_NAME(fsync); extern void* LIBC_FUNC_NAME(fdatasync); extern void* LIBC_FUNC_NAME(truncate); extern void* LIBC_FUNC_NAME(ftruncate); extern void* LIBC_FUNC_NAME(fcntl); extern void* LIBC_FUNC_NAME(dup); extern void* LIBC_FUNC_NAME(dup2); extern void* LIBC_FUNC_NAME(dup3); extern void* LIBC_FUNC_NAME(dirfd); extern void* LIBC_FUNC_NAME(opendir); extern void* LIBC_FUNC_NAME(fdopendir); extern void* LIBC_FUNC_NAME(readdir); extern void* LIBC_FUNC_NAME(closedir); extern void* LIBC_FUNC_NAME(chmod); extern void* LIBC_FUNC_NAME(fchmod); extern void* LIBC_FUNC_NAME(fchmodat); extern void* LIBC_FUNC_NAME(chdir); extern void* LIBC_FUNC_NAME(fchdir); extern void* LIBC_FUNC_NAME(getcwd); extern void* LIBC_FUNC_NAME(get_current_dir_name); extern void* LIBC_FUNC_NAME(link); extern void* LIBC_FUNC_NAME(linkat); extern void* LIBC_FUNC_NAME(symlinkat); extern void* LIBC_FUNC_NAME(readlinkat); extern void* LIBC_FUNC_NAME(realpath); void init_passthrough_if_needed(); #endif //IFS_PASSTHROUGH_HPP src/client/intcp_functions.cpp +0 −50 Original line number Diff line number Diff line Loading @@ -288,18 +288,6 @@ int fflush(FILE *stream) { return (reinterpret_cast<decltype(&fflush)>(libc_fflush))(stream); } int fpurge(FILE *stream) { init_passthrough_if_needed(); if(CTX->interception_enabled() && (stream != nullptr)) { auto fd = file_to_fd(stream); if(CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called on fd {}", __func__, fd); return 0; } } return (reinterpret_cast<decltype(&fpurge)>(libc_fpurge))(stream); } void __fpurge(FILE *stream) { init_passthrough_if_needed(); if(CTX->interception_enabled() && (stream != nullptr)) { Loading Loading @@ -665,44 +653,6 @@ int faccessat(int dirfd, const char* cpath, int mode, int flags) noexcept { } int stat(const char* path, struct stat* buf) noexcept { init_passthrough_if_needed(); if(!CTX->interception_enabled()) { return LIBC_FUNC(stat, path, buf); } CTX->log()->trace("{}() called with path '{}'", __func__, path); std::string rel_path; if (!CTX->relativize_path(path, rel_path)) { return LIBC_FUNC(stat, rel_path.c_str(), buf); } return adafs_stat(rel_path, buf); } int fstat(int fd, struct stat* buf) noexcept { init_passthrough_if_needed(); if(CTX->interception_enabled()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { auto path = CTX->file_map()->get(fd)->path(); return adafs_stat(path, buf); } } return LIBC_FUNC(fstat, fd, buf); } int lstat(const char* path, struct stat* buf) noexcept { init_passthrough_if_needed(); if(!CTX->interception_enabled()) { return LIBC_FUNC(lstat, path, buf); } CTX->log()->trace("{}() called with path '{}'", __func__, path); std::string rel_path; if (!CTX->relativize_path(path, rel_path, false)) { return LIBC_FUNC(lstat, rel_path.c_str(), buf); } return adafs_stat(rel_path, buf, false); } int __xstat(int ver, const char* path, struct stat* buf) noexcept { init_passthrough_if_needed(); if(!CTX->interception_enabled()) { Loading src/client/passthrough.cpp +235 −226 Original line number Diff line number Diff line /** * All intercepted functions are mapped to a different function pointer prefixing <libc_> */ #include <client/passthrough.hpp> #include "client/passthrough.hpp" #include <iostream> #include <stdlib.h> #include <pthread.h> #include <dlfcn.h> #include <unistd.h> #include <sys/syscall.h> /* We cannot use any fprintf here because it will call the write function internally * that we are also intercepting, and this will lead to a deadlock. * * Instead the write syscall needs to be called directly. */ #define WRITE_STDERR(str) \ do { \ syscall(SYS_write, 2, str, sizeof(str)); \ } while (0) #define LIBC_FUNC_LOAD(FNAME) \ do { \ LIBC_FUNC_NAME(FNAME) = dlsym(glibc, #FNAME); \ if (LIBC_FUNC_NAME(FNAME) == nullptr) { \ WRITE_STDERR("GekkoFS ERROR: failed to load glibc func symbol: '" #FNAME "'\n"); \ exit(EXIT_FAILURE); \ } \ } while (0) static pthread_once_t init_lib_thread = PTHREAD_ONCE_INIT; // function pointer for preloading void* libc; void* libc_open; void* libc_openat; void* libc_fopen; void* libc_fopen64; void* libc_fread; void* libc_fwrite; void* libc_fclose; void* libc_clearerr; void* libc_feof; void* libc_ferror; void* libc_fileno; void* libc_fflush; void* libc_fpurge; void* libc___fpurge; void* libc_setbuf; void* libc_setbuffer; void* libc_setlinebuf; void* libc_setvbuf; void* libc_putc; void* libc_fputc; void* libc_fputs; void* libc_getc; void* libc_fgetc; void* libc_fgets; void* libc_ungetc; void* libc_fseek; void* libc_mkdir; void* libc_mkdirat; void* libc_unlink; void* libc_unlinkat; void* libc_rmdir; void* libc_close; void* libc_access; void* libc_faccessat; void* libc_stat; void* libc_fstat; void* libc_lstat; void* libc___xstat; void* libc___xstat64; void* libc___fxstat; void* libc___fxstat64; void* libc___fxstatat; void* libc___fxstatat64; void* libc___lxstat; void* libc___lxstat64; void* libc_statfs; void* libc_fstatfs; void* libc_statvfs; void* libc_fstatvfs; void* libc_write; void* libc_pwrite; void* libc_pwrite64; void* libc_writev; void* libc_read; void* libc_pread; void* libc_pread64; void* libc_readv; void* libc_lseek; void* libc_lseek64; void* libc_fsync; void* libc_fdatasync; void* libc_truncate; void* libc_ftruncate; void* libc_fcntl; void* libc_dup; void* libc_dup2; void* libc_dup3; void* libc_dirfd; void* libc_opendir; void* libc_fdopendir; void* libc_readdir; void* libc_closedir; void* libc_chmod; void* libc_fchmod; void* libc_fchmodat; void* libc_chdir; void* libc_fchdir; void* libc_getcwd; void* libc_get_current_dir_name; void* libc_link; void* libc_linkat; void* libc_symlinkat; void* libc_readlinkat; void* libc_realpath; void* LIBC_FUNC_NAME(open); void* LIBC_FUNC_NAME(openat); void* LIBC_FUNC_NAME(fopen); void* LIBC_FUNC_NAME(fopen64); void* LIBC_FUNC_NAME(fread); void* LIBC_FUNC_NAME(fwrite); void* LIBC_FUNC_NAME(fclose); void* LIBC_FUNC_NAME(clearerr); void* LIBC_FUNC_NAME(feof); void* LIBC_FUNC_NAME(ferror); void* LIBC_FUNC_NAME(fileno); void* LIBC_FUNC_NAME(fflush); void* LIBC_FUNC_NAME(__fpurge); void* LIBC_FUNC_NAME(setbuf); void* LIBC_FUNC_NAME(setbuffer); void* LIBC_FUNC_NAME(setlinebuf); void* LIBC_FUNC_NAME(setvbuf); void* LIBC_FUNC_NAME(putc); void* LIBC_FUNC_NAME(fputc); void* LIBC_FUNC_NAME(fputs); void* LIBC_FUNC_NAME(getc); void* LIBC_FUNC_NAME(fgetc); void* LIBC_FUNC_NAME(fgets); void* LIBC_FUNC_NAME(ungetc); void* LIBC_FUNC_NAME(fseek); void* LIBC_FUNC_NAME(mkdir); void* LIBC_FUNC_NAME(mkdirat); void* LIBC_FUNC_NAME(unlink); void* LIBC_FUNC_NAME(unlinkat); void* LIBC_FUNC_NAME(rmdir); void* LIBC_FUNC_NAME(close); void* LIBC_FUNC_NAME(access); void* LIBC_FUNC_NAME(faccessat); void* LIBC_FUNC_NAME(__xstat); void* LIBC_FUNC_NAME(__xstat64); void* LIBC_FUNC_NAME(__fxstat); void* LIBC_FUNC_NAME(__fxstat64); void* LIBC_FUNC_NAME(__fxstatat); void* LIBC_FUNC_NAME(__fxstatat64); void* LIBC_FUNC_NAME(__lxstat); void* LIBC_FUNC_NAME(__lxstat64); void* LIBC_FUNC_NAME(statfs); void* LIBC_FUNC_NAME(fstatfs); void* LIBC_FUNC_NAME(statvfs); void* LIBC_FUNC_NAME(fstatvfs); void* LIBC_FUNC_NAME(write); void* LIBC_FUNC_NAME(pwrite); void* LIBC_FUNC_NAME(pwrite64); void* LIBC_FUNC_NAME(writev); void* LIBC_FUNC_NAME(read); void* LIBC_FUNC_NAME(pread); void* LIBC_FUNC_NAME(pread64); void* LIBC_FUNC_NAME(readv); void* LIBC_FUNC_NAME(lseek); void* LIBC_FUNC_NAME(lseek64); void* LIBC_FUNC_NAME(fsync); void* LIBC_FUNC_NAME(fdatasync); void* LIBC_FUNC_NAME(truncate); void* LIBC_FUNC_NAME(ftruncate); void* LIBC_FUNC_NAME(fcntl); void* LIBC_FUNC_NAME(dup); void* LIBC_FUNC_NAME(dup2); void* LIBC_FUNC_NAME(dup3); void* LIBC_FUNC_NAME(dirfd); void* LIBC_FUNC_NAME(opendir); void* LIBC_FUNC_NAME(fdopendir); void* LIBC_FUNC_NAME(readdir); void* LIBC_FUNC_NAME(closedir); void* LIBC_FUNC_NAME(chmod); void* LIBC_FUNC_NAME(fchmod); void* LIBC_FUNC_NAME(fchmodat); void* LIBC_FUNC_NAME(chdir); void* LIBC_FUNC_NAME(fchdir); void* LIBC_FUNC_NAME(getcwd); void* LIBC_FUNC_NAME(get_current_dir_name); void* LIBC_FUNC_NAME(link); void* LIBC_FUNC_NAME(linkat); void* LIBC_FUNC_NAME(symlinkat); void* LIBC_FUNC_NAME(readlinkat); void* LIBC_FUNC_NAME(realpath); void init_passthrough_() { libc = dlopen("libc.so.6", RTLD_LAZY); if(libc == nullptr){ std::cerr << "ERROR: failed opening glibc shared object: " << dlerror() << std::endl; auto glibc = dlopen("libc.so.6", RTLD_LAZY); if(glibc == nullptr) { WRITE_STDERR("GekkoFS ERROR: failed to load glibc\n"); \ exit(EXIT_FAILURE); } libc_open = dlsym(libc, "open"); libc_openat = dlsym(libc, "openat"); libc_fopen = dlsym(libc, "fopen"); libc_fopen64 = dlsym(libc, "fopen64"); libc_fread = dlsym(libc, "fread"); libc_fwrite = dlsym(libc, "fwrite"); libc_fclose = dlsym(libc, "fclose"); libc_clearerr = dlsym(libc, "clearerr"); libc_feof = dlsym(libc, "feof"); libc_ferror = dlsym(libc, "ferror"); libc_fileno = dlsym(libc, "fileno"); libc_fflush = dlsym(libc, "fflush"); libc_fpurge = dlsym(libc, "fpurge"); libc___fpurge = dlsym(libc, "__fpurge"); libc_setbuf = dlsym(libc, "setbuf"); libc_setbuffer = dlsym(libc, "setbuffer"); libc_setlinebuf = dlsym(libc, "setlinebuf"); libc_setvbuf = dlsym(libc, "setvbuf"); libc_putc = dlsym(libc, "putc"); libc_fputc = dlsym(libc, "fputc"); libc_fputs = dlsym(libc, "fputs"); libc_getc = dlsym(libc, "getc"); libc_fgetc = dlsym(libc, "fgetc"); libc_fgets = dlsym(libc, "fgets"); libc_ungetc = dlsym(libc, "ungetc"); libc_fseek = dlsym(libc, "fseek"); libc_mkdir = dlsym(libc, "mkdir"); libc_mkdirat = dlsym(libc, "mkdirat"); libc_unlink = dlsym(libc, "unlink"); libc_unlinkat = dlsym(libc, "unlinkat"); libc_rmdir = dlsym(libc, "rmdir"); libc_close = dlsym(libc, "close"); libc_access = dlsym(libc, "access"); libc_faccessat = dlsym(libc, "faccessat"); libc_stat = dlsym(libc, "stat"); libc_fstat = dlsym(libc, "fstat"); libc_lstat = dlsym(libc, "lstat"); libc___xstat = dlsym(libc, "__xstat"); 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"); libc_statfs = dlsym(libc, "statfs"); libc_fstatfs = dlsym(libc, "fstatfs"); libc_statvfs = dlsym(libc, "statvfs"); libc_fstatvfs = dlsym(libc, "fstatvfs"); libc_write = dlsym(libc, "write"); libc_pwrite = dlsym(libc, "pwrite"); libc_pwrite64 = dlsym(libc, "pwrite64"); libc_writev = dlsym(libc, "writev"); libc_read = dlsym(libc, "read"); libc_pread = dlsym(libc, "pread"); libc_pread64 = dlsym(libc, "pread64"); libc_readv = dlsym(libc, "readv"); libc_lseek = dlsym(libc, "lseek"); libc_lseek64 = dlsym(libc, "lseek64"); libc_fsync = dlsym(libc, "fsync"); libc_fdatasync = dlsym(libc, "fdatasync"); libc_truncate = dlsym(libc, "truncate"); libc_ftruncate = dlsym(libc, "ftruncate"); libc_fcntl = dlsym(libc, "fcntl"); libc_dup = dlsym(libc, "dup"); libc_dup2 = dlsym(libc, "dup2"); libc_dup3 = dlsym(libc, "dup3"); libc_dirfd = dlsym(libc, "dirfd"); libc_opendir = dlsym(libc, "opendir"); libc_fdopendir = dlsym(libc, "fdopendir"); libc_readdir = dlsym(libc, "readdir"); libc_closedir = dlsym(libc, "closedir"); libc_chmod = dlsym(libc, "chmod"); libc_fchmod = dlsym(libc, "fchmod"); libc_fchmodat = dlsym(libc, "fchmodat"); libc_chdir = dlsym(libc, "chdir"); libc_fchdir = dlsym(libc, "fchdir"); libc_getcwd = dlsym(libc, "getcwd"); libc_get_current_dir_name = dlsym(libc, "get_current_dir_name"); libc_link = dlsym(libc, "link"); libc_linkat = dlsym(libc, "linkat"); libc_symlinkat = dlsym(libc, "symlinkat"); libc_readlinkat = dlsym(libc, "readlinkat"); libc_realpath = dlsym(libc, "realpath"); LIBC_FUNC_LOAD(open); LIBC_FUNC_LOAD(openat); LIBC_FUNC_LOAD(fopen); LIBC_FUNC_LOAD(fopen64); LIBC_FUNC_LOAD(fread); LIBC_FUNC_LOAD(fwrite); LIBC_FUNC_LOAD(fclose); LIBC_FUNC_LOAD(clearerr); LIBC_FUNC_LOAD(feof); LIBC_FUNC_LOAD(ferror); LIBC_FUNC_LOAD(fileno); LIBC_FUNC_LOAD(fflush); LIBC_FUNC_LOAD(__fpurge); LIBC_FUNC_LOAD(setbuf); LIBC_FUNC_LOAD(setbuffer); LIBC_FUNC_LOAD(setlinebuf); LIBC_FUNC_LOAD(setvbuf); LIBC_FUNC_LOAD(putc); LIBC_FUNC_LOAD(fputc); LIBC_FUNC_LOAD(fputs); LIBC_FUNC_LOAD(getc); LIBC_FUNC_LOAD(fgetc); LIBC_FUNC_LOAD(fgets); LIBC_FUNC_LOAD(ungetc); LIBC_FUNC_LOAD(fseek); LIBC_FUNC_LOAD(mkdir); LIBC_FUNC_LOAD(mkdirat); LIBC_FUNC_LOAD(unlink); LIBC_FUNC_LOAD(unlinkat); LIBC_FUNC_LOAD(rmdir); LIBC_FUNC_LOAD(close); LIBC_FUNC_LOAD(access); LIBC_FUNC_LOAD(faccessat); LIBC_FUNC_LOAD(__xstat); LIBC_FUNC_LOAD(__xstat64); LIBC_FUNC_LOAD(__fxstat); LIBC_FUNC_LOAD(__fxstat64); LIBC_FUNC_LOAD(__fxstatat); LIBC_FUNC_LOAD(__fxstatat64); LIBC_FUNC_LOAD(__lxstat); LIBC_FUNC_LOAD(__lxstat64); LIBC_FUNC_LOAD(statfs); LIBC_FUNC_LOAD(fstatfs); LIBC_FUNC_LOAD(statvfs); LIBC_FUNC_LOAD(fstatvfs); LIBC_FUNC_LOAD(write); LIBC_FUNC_LOAD(pwrite); LIBC_FUNC_LOAD(pwrite64); LIBC_FUNC_LOAD(writev); LIBC_FUNC_LOAD(read); LIBC_FUNC_LOAD(pread); LIBC_FUNC_LOAD(pread64); LIBC_FUNC_LOAD(readv); LIBC_FUNC_LOAD(lseek); LIBC_FUNC_LOAD(lseek64); LIBC_FUNC_LOAD(fsync); LIBC_FUNC_LOAD(fdatasync); LIBC_FUNC_LOAD(truncate); LIBC_FUNC_LOAD(ftruncate); LIBC_FUNC_LOAD(fcntl); LIBC_FUNC_LOAD(dup); LIBC_FUNC_LOAD(dup2); LIBC_FUNC_LOAD(dup3); LIBC_FUNC_LOAD(dirfd); LIBC_FUNC_LOAD(opendir); LIBC_FUNC_LOAD(fdopendir); LIBC_FUNC_LOAD(readdir); LIBC_FUNC_LOAD(closedir); LIBC_FUNC_LOAD(chmod); LIBC_FUNC_LOAD(fchmod); LIBC_FUNC_LOAD(fchmodat); LIBC_FUNC_LOAD(chdir); LIBC_FUNC_LOAD(fchdir); LIBC_FUNC_LOAD(getcwd); LIBC_FUNC_LOAD(get_current_dir_name); LIBC_FUNC_LOAD(link); LIBC_FUNC_LOAD(linkat); LIBC_FUNC_LOAD(symlinkat); LIBC_FUNC_LOAD(readlinkat); LIBC_FUNC_LOAD(realpath); } void init_passthrough_if_needed() { Loading Loading
include/client/passthrough.hpp +107 −109 Original line number Diff line number Diff line Loading @@ -2,119 +2,117 @@ #define IFS_PASSTHROUGH_HPP #define LIBC_FUNC_NAME(FNAME) libc_##FNAME #define LIBC_FUNC(FNAME, ...) \ ((reinterpret_cast<decltype(&FNAME)>(libc_##FNAME))(__VA_ARGS__)) // function pointer for preloading extern void* libc; extern void* libc_open; extern void* libc_openat; extern void* libc_fopen; extern void* libc_fopen64; extern void* libc_fread; extern void* libc_fwrite; extern void* libc_fclose; extern void* libc_clearerr; extern void* libc_feof; extern void* libc_ferror; extern void* libc_fileno; extern void* libc_fflush; extern void* libc_fpurge; extern void* libc___fpurge; extern void* libc_setbuf; extern void* libc_setbuffer; extern void* libc_setlinebuf; extern void* libc_setvbuf; extern void* libc_putc; extern void* libc_fputc; extern void* libc_fputs; extern void* libc_getc; extern void* libc_fgetc; extern void* libc_fgets; extern void* libc_ungetc; extern void* libc_fseek; extern void* libc_mkdir; extern void* libc_mkdirat; extern void* libc_unlink; extern void* libc_unlinkat; extern void* libc_rmdir; extern void* libc_close; extern void* libc_access; extern void* libc_faccessat; extern void* libc_stat; extern void* libc_fstat; extern void* libc_lstat; 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; extern void* libc_statfs; extern void* libc_fstatfs; extern void* libc_statvfs; extern void* libc_fstatvfs; extern void* libc_write; extern void* libc_pwrite; extern void* libc_pwrite64; extern void* libc_writev; extern void* libc_read; extern void* libc_pread; extern void* libc_pread64; extern void* libc_readv; extern void* libc_lseek; extern void* libc_lseek64; extern void* libc_fsync; extern void* libc_fdatasync; extern void* libc_truncate; extern void* libc_ftruncate; extern void* libc_fcntl; extern void* libc_dup; extern void* libc_dup2; extern void* libc_dup3; extern void* libc_dirfd; extern void* libc_opendir; extern void* libc_fdopendir; extern void* libc_readdir; extern void* libc_closedir; extern void* libc_chmod; extern void* libc_fchmod; extern void* libc_fchmodat; extern void* libc_chdir; extern void* libc_fchdir; extern void* libc_getcwd; extern void* libc_get_current_dir_name; extern void* libc_link; extern void* libc_linkat; extern void* libc_symlinkat; extern void* libc_readlinkat; extern void* libc_realpath; extern void* LIBC_FUNC_NAME(open); extern void* LIBC_FUNC_NAME(openat); extern void* LIBC_FUNC_NAME(fopen); extern void* LIBC_FUNC_NAME(fopen64); extern void* LIBC_FUNC_NAME(fread); extern void* LIBC_FUNC_NAME(fwrite); extern void* LIBC_FUNC_NAME(fclose); extern void* LIBC_FUNC_NAME(clearerr); extern void* LIBC_FUNC_NAME(feof); extern void* LIBC_FUNC_NAME(ferror); extern void* LIBC_FUNC_NAME(fileno); extern void* LIBC_FUNC_NAME(fflush); extern void* LIBC_FUNC_NAME(__fpurge); extern void* LIBC_FUNC_NAME(setbuf); extern void* LIBC_FUNC_NAME(setbuffer); extern void* LIBC_FUNC_NAME(setlinebuf); extern void* LIBC_FUNC_NAME(setvbuf); extern void* LIBC_FUNC_NAME(putc); extern void* LIBC_FUNC_NAME(fputc); extern void* LIBC_FUNC_NAME(fputs); extern void* LIBC_FUNC_NAME(getc); extern void* LIBC_FUNC_NAME(fgetc); extern void* LIBC_FUNC_NAME(fgets); extern void* LIBC_FUNC_NAME(ungetc); extern void* LIBC_FUNC_NAME(fseek); extern void* LIBC_FUNC_NAME(mkdir); extern void* LIBC_FUNC_NAME(mkdirat); extern void* LIBC_FUNC_NAME(unlink); extern void* LIBC_FUNC_NAME(unlinkat); extern void* LIBC_FUNC_NAME(rmdir); extern void* LIBC_FUNC_NAME(close); extern void* LIBC_FUNC_NAME(access); extern void* LIBC_FUNC_NAME(faccessat); extern void* LIBC_FUNC_NAME(__xstat); extern void* LIBC_FUNC_NAME(__xstat64); extern void* LIBC_FUNC_NAME(__fxstat); extern void* LIBC_FUNC_NAME(__fxstat64); extern void* LIBC_FUNC_NAME(__fxstatat); extern void* LIBC_FUNC_NAME(__fxstatat64); extern void* LIBC_FUNC_NAME(__lxstat); extern void* LIBC_FUNC_NAME(__lxstat64); extern void* LIBC_FUNC_NAME(statfs); extern void* LIBC_FUNC_NAME(fstatfs); extern void* LIBC_FUNC_NAME(statvfs); extern void* LIBC_FUNC_NAME(fstatvfs); extern void* LIBC_FUNC_NAME(write); extern void* LIBC_FUNC_NAME(pwrite); extern void* LIBC_FUNC_NAME(pwrite64); extern void* LIBC_FUNC_NAME(writev); extern void* LIBC_FUNC_NAME(read); extern void* LIBC_FUNC_NAME(pread); extern void* LIBC_FUNC_NAME(pread64); extern void* LIBC_FUNC_NAME(readv); extern void* LIBC_FUNC_NAME(lseek); extern void* LIBC_FUNC_NAME(lseek64); extern void* LIBC_FUNC_NAME(fsync); extern void* LIBC_FUNC_NAME(fdatasync); extern void* LIBC_FUNC_NAME(truncate); extern void* LIBC_FUNC_NAME(ftruncate); extern void* LIBC_FUNC_NAME(fcntl); extern void* LIBC_FUNC_NAME(dup); extern void* LIBC_FUNC_NAME(dup2); extern void* LIBC_FUNC_NAME(dup3); extern void* LIBC_FUNC_NAME(dirfd); extern void* LIBC_FUNC_NAME(opendir); extern void* LIBC_FUNC_NAME(fdopendir); extern void* LIBC_FUNC_NAME(readdir); extern void* LIBC_FUNC_NAME(closedir); extern void* LIBC_FUNC_NAME(chmod); extern void* LIBC_FUNC_NAME(fchmod); extern void* LIBC_FUNC_NAME(fchmodat); extern void* LIBC_FUNC_NAME(chdir); extern void* LIBC_FUNC_NAME(fchdir); extern void* LIBC_FUNC_NAME(getcwd); extern void* LIBC_FUNC_NAME(get_current_dir_name); extern void* LIBC_FUNC_NAME(link); extern void* LIBC_FUNC_NAME(linkat); extern void* LIBC_FUNC_NAME(symlinkat); extern void* LIBC_FUNC_NAME(readlinkat); extern void* LIBC_FUNC_NAME(realpath); void init_passthrough_if_needed(); #endif //IFS_PASSTHROUGH_HPP
src/client/intcp_functions.cpp +0 −50 Original line number Diff line number Diff line Loading @@ -288,18 +288,6 @@ int fflush(FILE *stream) { return (reinterpret_cast<decltype(&fflush)>(libc_fflush))(stream); } int fpurge(FILE *stream) { init_passthrough_if_needed(); if(CTX->interception_enabled() && (stream != nullptr)) { auto fd = file_to_fd(stream); if(CTX->file_map()->exist(fd)) { CTX->log()->trace("{}() called on fd {}", __func__, fd); return 0; } } return (reinterpret_cast<decltype(&fpurge)>(libc_fpurge))(stream); } void __fpurge(FILE *stream) { init_passthrough_if_needed(); if(CTX->interception_enabled() && (stream != nullptr)) { Loading Loading @@ -665,44 +653,6 @@ int faccessat(int dirfd, const char* cpath, int mode, int flags) noexcept { } int stat(const char* path, struct stat* buf) noexcept { init_passthrough_if_needed(); if(!CTX->interception_enabled()) { return LIBC_FUNC(stat, path, buf); } CTX->log()->trace("{}() called with path '{}'", __func__, path); std::string rel_path; if (!CTX->relativize_path(path, rel_path)) { return LIBC_FUNC(stat, rel_path.c_str(), buf); } return adafs_stat(rel_path, buf); } int fstat(int fd, struct stat* buf) noexcept { init_passthrough_if_needed(); if(CTX->interception_enabled()) { CTX->log()->trace("{}() called with fd {}", __func__, fd); if (CTX->file_map()->exist(fd)) { auto path = CTX->file_map()->get(fd)->path(); return adafs_stat(path, buf); } } return LIBC_FUNC(fstat, fd, buf); } int lstat(const char* path, struct stat* buf) noexcept { init_passthrough_if_needed(); if(!CTX->interception_enabled()) { return LIBC_FUNC(lstat, path, buf); } CTX->log()->trace("{}() called with path '{}'", __func__, path); std::string rel_path; if (!CTX->relativize_path(path, rel_path, false)) { return LIBC_FUNC(lstat, rel_path.c_str(), buf); } return adafs_stat(rel_path, buf, false); } int __xstat(int ver, const char* path, struct stat* buf) noexcept { init_passthrough_if_needed(); if(!CTX->interception_enabled()) { Loading
src/client/passthrough.cpp +235 −226 Original line number Diff line number Diff line /** * All intercepted functions are mapped to a different function pointer prefixing <libc_> */ #include <client/passthrough.hpp> #include "client/passthrough.hpp" #include <iostream> #include <stdlib.h> #include <pthread.h> #include <dlfcn.h> #include <unistd.h> #include <sys/syscall.h> /* We cannot use any fprintf here because it will call the write function internally * that we are also intercepting, and this will lead to a deadlock. * * Instead the write syscall needs to be called directly. */ #define WRITE_STDERR(str) \ do { \ syscall(SYS_write, 2, str, sizeof(str)); \ } while (0) #define LIBC_FUNC_LOAD(FNAME) \ do { \ LIBC_FUNC_NAME(FNAME) = dlsym(glibc, #FNAME); \ if (LIBC_FUNC_NAME(FNAME) == nullptr) { \ WRITE_STDERR("GekkoFS ERROR: failed to load glibc func symbol: '" #FNAME "'\n"); \ exit(EXIT_FAILURE); \ } \ } while (0) static pthread_once_t init_lib_thread = PTHREAD_ONCE_INIT; // function pointer for preloading void* libc; void* libc_open; void* libc_openat; void* libc_fopen; void* libc_fopen64; void* libc_fread; void* libc_fwrite; void* libc_fclose; void* libc_clearerr; void* libc_feof; void* libc_ferror; void* libc_fileno; void* libc_fflush; void* libc_fpurge; void* libc___fpurge; void* libc_setbuf; void* libc_setbuffer; void* libc_setlinebuf; void* libc_setvbuf; void* libc_putc; void* libc_fputc; void* libc_fputs; void* libc_getc; void* libc_fgetc; void* libc_fgets; void* libc_ungetc; void* libc_fseek; void* libc_mkdir; void* libc_mkdirat; void* libc_unlink; void* libc_unlinkat; void* libc_rmdir; void* libc_close; void* libc_access; void* libc_faccessat; void* libc_stat; void* libc_fstat; void* libc_lstat; void* libc___xstat; void* libc___xstat64; void* libc___fxstat; void* libc___fxstat64; void* libc___fxstatat; void* libc___fxstatat64; void* libc___lxstat; void* libc___lxstat64; void* libc_statfs; void* libc_fstatfs; void* libc_statvfs; void* libc_fstatvfs; void* libc_write; void* libc_pwrite; void* libc_pwrite64; void* libc_writev; void* libc_read; void* libc_pread; void* libc_pread64; void* libc_readv; void* libc_lseek; void* libc_lseek64; void* libc_fsync; void* libc_fdatasync; void* libc_truncate; void* libc_ftruncate; void* libc_fcntl; void* libc_dup; void* libc_dup2; void* libc_dup3; void* libc_dirfd; void* libc_opendir; void* libc_fdopendir; void* libc_readdir; void* libc_closedir; void* libc_chmod; void* libc_fchmod; void* libc_fchmodat; void* libc_chdir; void* libc_fchdir; void* libc_getcwd; void* libc_get_current_dir_name; void* libc_link; void* libc_linkat; void* libc_symlinkat; void* libc_readlinkat; void* libc_realpath; void* LIBC_FUNC_NAME(open); void* LIBC_FUNC_NAME(openat); void* LIBC_FUNC_NAME(fopen); void* LIBC_FUNC_NAME(fopen64); void* LIBC_FUNC_NAME(fread); void* LIBC_FUNC_NAME(fwrite); void* LIBC_FUNC_NAME(fclose); void* LIBC_FUNC_NAME(clearerr); void* LIBC_FUNC_NAME(feof); void* LIBC_FUNC_NAME(ferror); void* LIBC_FUNC_NAME(fileno); void* LIBC_FUNC_NAME(fflush); void* LIBC_FUNC_NAME(__fpurge); void* LIBC_FUNC_NAME(setbuf); void* LIBC_FUNC_NAME(setbuffer); void* LIBC_FUNC_NAME(setlinebuf); void* LIBC_FUNC_NAME(setvbuf); void* LIBC_FUNC_NAME(putc); void* LIBC_FUNC_NAME(fputc); void* LIBC_FUNC_NAME(fputs); void* LIBC_FUNC_NAME(getc); void* LIBC_FUNC_NAME(fgetc); void* LIBC_FUNC_NAME(fgets); void* LIBC_FUNC_NAME(ungetc); void* LIBC_FUNC_NAME(fseek); void* LIBC_FUNC_NAME(mkdir); void* LIBC_FUNC_NAME(mkdirat); void* LIBC_FUNC_NAME(unlink); void* LIBC_FUNC_NAME(unlinkat); void* LIBC_FUNC_NAME(rmdir); void* LIBC_FUNC_NAME(close); void* LIBC_FUNC_NAME(access); void* LIBC_FUNC_NAME(faccessat); void* LIBC_FUNC_NAME(__xstat); void* LIBC_FUNC_NAME(__xstat64); void* LIBC_FUNC_NAME(__fxstat); void* LIBC_FUNC_NAME(__fxstat64); void* LIBC_FUNC_NAME(__fxstatat); void* LIBC_FUNC_NAME(__fxstatat64); void* LIBC_FUNC_NAME(__lxstat); void* LIBC_FUNC_NAME(__lxstat64); void* LIBC_FUNC_NAME(statfs); void* LIBC_FUNC_NAME(fstatfs); void* LIBC_FUNC_NAME(statvfs); void* LIBC_FUNC_NAME(fstatvfs); void* LIBC_FUNC_NAME(write); void* LIBC_FUNC_NAME(pwrite); void* LIBC_FUNC_NAME(pwrite64); void* LIBC_FUNC_NAME(writev); void* LIBC_FUNC_NAME(read); void* LIBC_FUNC_NAME(pread); void* LIBC_FUNC_NAME(pread64); void* LIBC_FUNC_NAME(readv); void* LIBC_FUNC_NAME(lseek); void* LIBC_FUNC_NAME(lseek64); void* LIBC_FUNC_NAME(fsync); void* LIBC_FUNC_NAME(fdatasync); void* LIBC_FUNC_NAME(truncate); void* LIBC_FUNC_NAME(ftruncate); void* LIBC_FUNC_NAME(fcntl); void* LIBC_FUNC_NAME(dup); void* LIBC_FUNC_NAME(dup2); void* LIBC_FUNC_NAME(dup3); void* LIBC_FUNC_NAME(dirfd); void* LIBC_FUNC_NAME(opendir); void* LIBC_FUNC_NAME(fdopendir); void* LIBC_FUNC_NAME(readdir); void* LIBC_FUNC_NAME(closedir); void* LIBC_FUNC_NAME(chmod); void* LIBC_FUNC_NAME(fchmod); void* LIBC_FUNC_NAME(fchmodat); void* LIBC_FUNC_NAME(chdir); void* LIBC_FUNC_NAME(fchdir); void* LIBC_FUNC_NAME(getcwd); void* LIBC_FUNC_NAME(get_current_dir_name); void* LIBC_FUNC_NAME(link); void* LIBC_FUNC_NAME(linkat); void* LIBC_FUNC_NAME(symlinkat); void* LIBC_FUNC_NAME(readlinkat); void* LIBC_FUNC_NAME(realpath); void init_passthrough_() { libc = dlopen("libc.so.6", RTLD_LAZY); if(libc == nullptr){ std::cerr << "ERROR: failed opening glibc shared object: " << dlerror() << std::endl; auto glibc = dlopen("libc.so.6", RTLD_LAZY); if(glibc == nullptr) { WRITE_STDERR("GekkoFS ERROR: failed to load glibc\n"); \ exit(EXIT_FAILURE); } libc_open = dlsym(libc, "open"); libc_openat = dlsym(libc, "openat"); libc_fopen = dlsym(libc, "fopen"); libc_fopen64 = dlsym(libc, "fopen64"); libc_fread = dlsym(libc, "fread"); libc_fwrite = dlsym(libc, "fwrite"); libc_fclose = dlsym(libc, "fclose"); libc_clearerr = dlsym(libc, "clearerr"); libc_feof = dlsym(libc, "feof"); libc_ferror = dlsym(libc, "ferror"); libc_fileno = dlsym(libc, "fileno"); libc_fflush = dlsym(libc, "fflush"); libc_fpurge = dlsym(libc, "fpurge"); libc___fpurge = dlsym(libc, "__fpurge"); libc_setbuf = dlsym(libc, "setbuf"); libc_setbuffer = dlsym(libc, "setbuffer"); libc_setlinebuf = dlsym(libc, "setlinebuf"); libc_setvbuf = dlsym(libc, "setvbuf"); libc_putc = dlsym(libc, "putc"); libc_fputc = dlsym(libc, "fputc"); libc_fputs = dlsym(libc, "fputs"); libc_getc = dlsym(libc, "getc"); libc_fgetc = dlsym(libc, "fgetc"); libc_fgets = dlsym(libc, "fgets"); libc_ungetc = dlsym(libc, "ungetc"); libc_fseek = dlsym(libc, "fseek"); libc_mkdir = dlsym(libc, "mkdir"); libc_mkdirat = dlsym(libc, "mkdirat"); libc_unlink = dlsym(libc, "unlink"); libc_unlinkat = dlsym(libc, "unlinkat"); libc_rmdir = dlsym(libc, "rmdir"); libc_close = dlsym(libc, "close"); libc_access = dlsym(libc, "access"); libc_faccessat = dlsym(libc, "faccessat"); libc_stat = dlsym(libc, "stat"); libc_fstat = dlsym(libc, "fstat"); libc_lstat = dlsym(libc, "lstat"); libc___xstat = dlsym(libc, "__xstat"); 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"); libc_statfs = dlsym(libc, "statfs"); libc_fstatfs = dlsym(libc, "fstatfs"); libc_statvfs = dlsym(libc, "statvfs"); libc_fstatvfs = dlsym(libc, "fstatvfs"); libc_write = dlsym(libc, "write"); libc_pwrite = dlsym(libc, "pwrite"); libc_pwrite64 = dlsym(libc, "pwrite64"); libc_writev = dlsym(libc, "writev"); libc_read = dlsym(libc, "read"); libc_pread = dlsym(libc, "pread"); libc_pread64 = dlsym(libc, "pread64"); libc_readv = dlsym(libc, "readv"); libc_lseek = dlsym(libc, "lseek"); libc_lseek64 = dlsym(libc, "lseek64"); libc_fsync = dlsym(libc, "fsync"); libc_fdatasync = dlsym(libc, "fdatasync"); libc_truncate = dlsym(libc, "truncate"); libc_ftruncate = dlsym(libc, "ftruncate"); libc_fcntl = dlsym(libc, "fcntl"); libc_dup = dlsym(libc, "dup"); libc_dup2 = dlsym(libc, "dup2"); libc_dup3 = dlsym(libc, "dup3"); libc_dirfd = dlsym(libc, "dirfd"); libc_opendir = dlsym(libc, "opendir"); libc_fdopendir = dlsym(libc, "fdopendir"); libc_readdir = dlsym(libc, "readdir"); libc_closedir = dlsym(libc, "closedir"); libc_chmod = dlsym(libc, "chmod"); libc_fchmod = dlsym(libc, "fchmod"); libc_fchmodat = dlsym(libc, "fchmodat"); libc_chdir = dlsym(libc, "chdir"); libc_fchdir = dlsym(libc, "fchdir"); libc_getcwd = dlsym(libc, "getcwd"); libc_get_current_dir_name = dlsym(libc, "get_current_dir_name"); libc_link = dlsym(libc, "link"); libc_linkat = dlsym(libc, "linkat"); libc_symlinkat = dlsym(libc, "symlinkat"); libc_readlinkat = dlsym(libc, "readlinkat"); libc_realpath = dlsym(libc, "realpath"); LIBC_FUNC_LOAD(open); LIBC_FUNC_LOAD(openat); LIBC_FUNC_LOAD(fopen); LIBC_FUNC_LOAD(fopen64); LIBC_FUNC_LOAD(fread); LIBC_FUNC_LOAD(fwrite); LIBC_FUNC_LOAD(fclose); LIBC_FUNC_LOAD(clearerr); LIBC_FUNC_LOAD(feof); LIBC_FUNC_LOAD(ferror); LIBC_FUNC_LOAD(fileno); LIBC_FUNC_LOAD(fflush); LIBC_FUNC_LOAD(__fpurge); LIBC_FUNC_LOAD(setbuf); LIBC_FUNC_LOAD(setbuffer); LIBC_FUNC_LOAD(setlinebuf); LIBC_FUNC_LOAD(setvbuf); LIBC_FUNC_LOAD(putc); LIBC_FUNC_LOAD(fputc); LIBC_FUNC_LOAD(fputs); LIBC_FUNC_LOAD(getc); LIBC_FUNC_LOAD(fgetc); LIBC_FUNC_LOAD(fgets); LIBC_FUNC_LOAD(ungetc); LIBC_FUNC_LOAD(fseek); LIBC_FUNC_LOAD(mkdir); LIBC_FUNC_LOAD(mkdirat); LIBC_FUNC_LOAD(unlink); LIBC_FUNC_LOAD(unlinkat); LIBC_FUNC_LOAD(rmdir); LIBC_FUNC_LOAD(close); LIBC_FUNC_LOAD(access); LIBC_FUNC_LOAD(faccessat); LIBC_FUNC_LOAD(__xstat); LIBC_FUNC_LOAD(__xstat64); LIBC_FUNC_LOAD(__fxstat); LIBC_FUNC_LOAD(__fxstat64); LIBC_FUNC_LOAD(__fxstatat); LIBC_FUNC_LOAD(__fxstatat64); LIBC_FUNC_LOAD(__lxstat); LIBC_FUNC_LOAD(__lxstat64); LIBC_FUNC_LOAD(statfs); LIBC_FUNC_LOAD(fstatfs); LIBC_FUNC_LOAD(statvfs); LIBC_FUNC_LOAD(fstatvfs); LIBC_FUNC_LOAD(write); LIBC_FUNC_LOAD(pwrite); LIBC_FUNC_LOAD(pwrite64); LIBC_FUNC_LOAD(writev); LIBC_FUNC_LOAD(read); LIBC_FUNC_LOAD(pread); LIBC_FUNC_LOAD(pread64); LIBC_FUNC_LOAD(readv); LIBC_FUNC_LOAD(lseek); LIBC_FUNC_LOAD(lseek64); LIBC_FUNC_LOAD(fsync); LIBC_FUNC_LOAD(fdatasync); LIBC_FUNC_LOAD(truncate); LIBC_FUNC_LOAD(ftruncate); LIBC_FUNC_LOAD(fcntl); LIBC_FUNC_LOAD(dup); LIBC_FUNC_LOAD(dup2); LIBC_FUNC_LOAD(dup3); LIBC_FUNC_LOAD(dirfd); LIBC_FUNC_LOAD(opendir); LIBC_FUNC_LOAD(fdopendir); LIBC_FUNC_LOAD(readdir); LIBC_FUNC_LOAD(closedir); LIBC_FUNC_LOAD(chmod); LIBC_FUNC_LOAD(fchmod); LIBC_FUNC_LOAD(fchmodat); LIBC_FUNC_LOAD(chdir); LIBC_FUNC_LOAD(fchdir); LIBC_FUNC_LOAD(getcwd); LIBC_FUNC_LOAD(get_current_dir_name); LIBC_FUNC_LOAD(link); LIBC_FUNC_LOAD(linkat); LIBC_FUNC_LOAD(symlinkat); LIBC_FUNC_LOAD(readlinkat); LIBC_FUNC_LOAD(realpath); } void init_passthrough_if_needed() { Loading