diff options
Diffstat (limited to 'drvemu.c')
-rw-r--r-- | drvemu.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drvemu.c b/drvemu.c new file mode 100644 index 0000000..d16c44f --- /dev/null +++ b/drvemu.c @@ -0,0 +1,25 @@ +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <assert.h> +#include <dlfcn.h> + +#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); +} |