Skip to content

Commit

Permalink
libredirect: Add preload wrapper for stat()
Browse files Browse the repository at this point in the history
Pull request NixOS#50246 was merged a bit too quickly and it was supposed to
fix libredirect on Darwin. However it still fails on Darwin because I
was using ofborg to check Darwin builds as I don't have Apple hardware.

Providing a symbol for stat shouldn't hurt on GNU/Linux but might work
on Darwin, because it probably doesn't have __xstat*() but might have a
stat() symbol.

Signed-off-by: aszlig <aszlig@nix.build>
  • Loading branch information
aszlig committed Nov 12, 2018
1 parent 22a8025 commit 488cb85
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkgs/build-support/libredirect/libredirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ int __xstat64(int ver, const char * path, struct stat64 * st)
return __xstat64_real(ver, rewrite(path, buf), st);
}

int stat(const char * path, struct stat * st)
{
int (*__stat_real) (const char *, struct stat *) = dlsym(RTLD_NEXT, "stat");
char buf[PATH_MAX];
return __stat_real(rewrite(path, buf), st);
}

int * access(const char * path, int mode)
{
int * (*access_real) (const char *, int mode) = dlsym(RTLD_NEXT, "access");
Expand Down

0 comments on commit 488cb85

Please sign in to comment.