libredirect: handle mkdir(2) + mkdirat(2)

Fixes https://github.com/NixOS/nixpkgs/issues/140735.

Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
This commit is contained in:
Bjørn Forsman 2021-10-06 19:31:23 +02:00
parent 40f95ae12a
commit 864f96cd7f

View File

@ -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);
}