Commit 5b1132e7 authored by Julius Plenz's avatar Julius Plenz

intercept openat(), too

parent 8ec2f012
......@@ -10,6 +10,7 @@
#include <pthread.h>
int (*_original_open)(const char *pathname, int flags, mode_t mode);
int (*_original_openat)(int dirfd, const char *pathname, int flags, mode_t mode);
int (*_original_close)(int fd);
void init(void) __attribute__((constructor));
......@@ -39,6 +40,8 @@ void init(void)
int i;
_original_open = (int (*)(const char *, int, mode_t))
dlsym(RTLD_NEXT, "open");
_original_openat = (int (*)(int, const char *, int, mode_t))
dlsym(RTLD_NEXT, "openat");
_original_close = (int (*)(int)) dlsym(RTLD_NEXT, "close");
pthread_mutex_init(&lock, NULL);
PAGESIZE = getpagesize();
......@@ -56,6 +59,16 @@ int open(const char *pathname, int flags, mode_t mode)
return fd;
}
int openat(int dirfd, const char *pathname, int flags, mode_t mode)
{
int fd;
if((fd = _original_openat(dirfd, pathname, flags, mode)) != -1) {
store_pageinfo(fd);
fadv_noreuse(fd, 0, 0);
}
return fd;
}
int close(int fd)
{
free_unclaimed_pages(fd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment