From e07db64b78c3905baf3aaeb582899f78ab306781 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 10 Oct 2012 15:50:28 +0100 Subject: readlink: Use readlinkat if arch does not have the readlink syscall Signed-off-by: Markos Chandras Signed-off-by: Bernhard Reutner-Fischer --- libc/sysdeps/linux/common/readlink.c | 8 ++++++++ libc/sysdeps/linux/common/readlinkat.c | 1 + 2 files changed, 9 insertions(+) (limited to 'libc') diff --git a/libc/sysdeps/linux/common/readlink.c b/libc/sysdeps/linux/common/readlink.c index ef9e83539..f64aeb947 100644 --- a/libc/sysdeps/linux/common/readlink.c +++ b/libc/sysdeps/linux/common/readlink.c @@ -10,5 +10,13 @@ #include #include +#if defined(__NR_readlinkat) && !defined(__NR_readlink) +# include +ssize_t readlink (const char *path, char *buf, size_t len) +{ + return readlinkat(AT_FDCWD, path, buf, len); +} +#else _syscall3(ssize_t, readlink, const char *, path, char *, buf, size_t, bufsiz) +#endif libc_hidden_def(readlink) diff --git a/libc/sysdeps/linux/common/readlinkat.c b/libc/sysdeps/linux/common/readlinkat.c index d0a98e115..995b9e2c1 100644 --- a/libc/sysdeps/linux/common/readlinkat.c +++ b/libc/sysdeps/linux/common/readlinkat.c @@ -11,6 +11,7 @@ #ifdef __NR_readlinkat _syscall4(ssize_t, readlinkat, int, fd, const char *, path, char *, buf, size_t, len) +libc_hidden_def(readlinkat) #else /* should add emulation with readlink() and /proc/self/fd/ ... */ #endif -- cgit v1.2.3