From 864f96cd7fd732b9339494b2890ebe0685b43a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Wed, 6 Oct 2021 19:31:23 +0200 Subject: [PATCH] libredirect: handle mkdir(2) + mkdirat(2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/NixOS/nixpkgs/issues/140735. Co-authored-by: Jörg Thalheim --- pkgs/build-support/libredirect/libredirect.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkgs/build-support/libredirect/libredirect.c b/pkgs/build-support/libredirect/libredirect.c index 5b0ef4856708..c7058ce123c5 100644 --- a/pkgs/build-support/libredirect/libredirect.c +++ b/pkgs/build-support/libredirect/libredirect.c @@ -279,3 +279,17 @@ int system(const char *command) rewriteSystemCall(command, newCommand); return _system(newCommand); } + +int mkdir(const char *path, mode_t mode) +{ + int (*mkdir_real) (const char *path, mode_t mode) = dlsym(RTLD_NEXT, "mkdir"); + char buf[PATH_MAX]; + return mkdir_real(rewrite(path, buf), mode); +} + +int mkdirat(int dirfd, const char *path, mode_t mode) +{ + int (*mkdirat_real) (int dirfd, const char *path, mode_t mode) = dlsym(RTLD_NEXT, "mkdirat"); + char buf[PATH_MAX]; + return mkdirat_real(dirfd, rewrite(path, buf), mode); +}