1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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);
}
|