diff options
author | Jan Tojnar <jtojnar@gmail.com> | 2019-04-20 03:02:44 +0200 |
---|---|---|
committer | Jan Tojnar <jtojnar@gmail.com> | 2019-04-20 03:09:17 +0200 |
commit | 90f3a237eb51d7e3173f1502d468e99ff777d1b9 (patch) | |
tree | 20f818b0c51b8821384bdfe556f21b44ba45c3f6 /pkgs/build-support/libredirect | |
parent | cd8697da9fe25604a5379274f347ce37526670c5 (diff) |
libredirect: add support for openat and dlopen
gobject-introspection uses glib’s g_module_open function, which in turn relies on dlopen. I also implemented openat, since I initially thought this function was used but turns out dlopen uses the openat signal directly. We might as well keep it, even thought I do not need it at the moment.
Diffstat (limited to 'pkgs/build-support/libredirect')
-rw-r--r-- | pkgs/build-support/libredirect/libredirect.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/pkgs/build-support/libredirect/libredirect.c b/pkgs/build-support/libredirect/libredirect.c index ba1e6c57e12ef..dcf3a2016bc25 100644 --- a/pkgs/build-support/libredirect/libredirect.c +++ b/pkgs/build-support/libredirect/libredirect.c @@ -91,6 +91,20 @@ int open64(const char * path, int flags, ...) return open64_real(rewrite(path, buf), flags, mode); } +int openat(int dirfd, const char * path, int flags, ...) +{ + int (*openat_real) (int, const char *, int, mode_t) = dlsym(RTLD_NEXT, "openat"); + mode_t mode = 0; + if (flags & O_CREAT) { + va_list ap; + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); + } + char buf[PATH_MAX]; + return openat_real(dirfd, rewrite(path, buf), flags, mode); +} + FILE * fopen(const char * path, const char * mode) { FILE * (*fopen_real) (const char *, const char *) = dlsym(RTLD_NEXT, "fopen"); @@ -152,3 +166,10 @@ int execv(const char *path, char *const argv[]) char buf[PATH_MAX]; return execv_real(rewrite(path, buf), argv); } + +void *dlopen(const char *filename, int flag) +{ + void * (*__dlopen_real) (const char *, int) = dlsym(RTLD_NEXT, "dlopen"); + char buf[PATH_MAX]; + return __dlopen_real(rewrite(filename, buf), flag); +} |