#include #include #include #include #include #define PROLOG(func) \ static typeof(func) *orig_##func = NULL; \ if(!orig_##func) \ orig_##func = dlsym(RTLD_NEXT, #func); int open64(const char *pathname, int flags, ...) { printf("Called open64 on %s (%d)\n", pathname, flags); PROLOG(open64); int fd = orig_open64(pathname, flags); //check_fd(fd, pathname); return fd; } int openat(int dirfd, const char *pathname, int flags, ...) { assert(false && "openat not implemented"); printf("Called openat on %s (%d) (%d)\n", pathname, dirfd, flags); PROLOG(openat); return orig_openat(dirfd, pathname, flags); }