Now About Social Code
summaryrefslogtreecommitdiff
path: root/drvemu.c
diff options
context:
space:
mode:
authorLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-07-07 20:12:12 +0100
committerLucas Fryzek <lucas.fryzek@fryzekconcepts.com>2024-07-07 20:12:12 +0100
commitcfebe5825512d187ce2d4ff98ee74e8da8eb901e (patch)
treebd3c00b2dab45e78a3d80b33493a9c076e21b1a8 /drvemu.c
Initial commit
Diffstat (limited to 'drvemu.c')
-rw-r--r--drvemu.c25
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);
+}