Commit 8e6e56b0 authored by Julius Plenz's avatar Julius Plenz

Merge branch 'tar-quirks'

* tar-quirks: Add an alias __openat_2() for openat() intercept creat()
parents eee311d0 36ee5ac3
...@@ -10,11 +10,16 @@ ...@@ -10,11 +10,16 @@
#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_creat)(const char *pathname, int flags, mode_t mode);
int (*_original_openat)(int dirfd, 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));
int open(const char *pathname, int flags, mode_t mode); int open(const char *pathname, int flags, mode_t mode);
int creat(const char *pathname, int flags, mode_t mode);
int openat(int dirfd, const char *pathname, int flags, mode_t mode);
int __openat_2(int dirfd, const char *pathname, int flags, mode_t mode)
__attribute__ ((alias ("openat")));
int close(int fd); int close(int fd);
static void store_pageinfo(int fd); static void store_pageinfo(int fd);
...@@ -40,6 +45,8 @@ void init(void) ...@@ -40,6 +45,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_creat = (int (*)(const char *, int, mode_t))
dlsym(RTLD_NEXT, "creat");
_original_openat = (int (*)(int, const char *, int, mode_t)) _original_openat = (int (*)(int, const char *, int, mode_t))
dlsym(RTLD_NEXT, "openat"); dlsym(RTLD_NEXT, "openat");
_original_close = (int (*)(int)) dlsym(RTLD_NEXT, "close"); _original_close = (int (*)(int)) dlsym(RTLD_NEXT, "close");
...@@ -59,6 +66,16 @@ int open(const char *pathname, int flags, mode_t mode) ...@@ -59,6 +66,16 @@ int open(const char *pathname, int flags, mode_t mode)
return fd; return fd;
} }
int creat(const char *pathname, int flags, mode_t mode)
{
int fd;
if((fd = _original_creat(pathname, flags, mode)) != -1) {
store_pageinfo(fd);
fadv_noreuse(fd, 0, 0);
}
return fd;
}
int openat(int dirfd, const char *pathname, int flags, mode_t mode) int openat(int dirfd, const char *pathname, int flags, mode_t mode)
{ {
int fd; int 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