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

intercept openat(), too

parent 8ec2f012
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <pthread.h> #include <pthread.h>
int (*_original_open)(const char *pathname, int flags, mode_t mode); 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); int (*_original_close)(int fd);
void init(void) __attribute__((constructor)); void init(void) __attribute__((constructor));
...@@ -39,6 +40,8 @@ void init(void) ...@@ -39,6 +40,8 @@ void init(void)
int i; int i;
_original_open = (int (*)(const char *, int, mode_t)) _original_open = (int (*)(const char *, int, mode_t))
dlsym(RTLD_NEXT, "open"); 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"); _original_close = (int (*)(int)) dlsym(RTLD_NEXT, "close");
pthread_mutex_init(&lock, NULL); pthread_mutex_init(&lock, NULL);
PAGESIZE = getpagesize(); PAGESIZE = getpagesize();
...@@ -56,6 +59,16 @@ int open(const char *pathname, int flags, mode_t mode) ...@@ -56,6 +59,16 @@ int open(const char *pathname, int flags, mode_t mode)
return fd; 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) int close(int fd)
{ {
free_unclaimed_pages(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