From cfebe5825512d187ce2d4ff98ee74e8da8eb901e Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Sun, 7 Jul 2024 20:12:12 +0100 Subject: Initial commit --- drvemu.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 drvemu.c (limited to 'drvemu.c') 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 +#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); +} -- cgit