From 82fc713658c82cbbc577e6f8fa6cec67b911ba6e Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 10 Oct 2012 14:45:14 +0100 Subject: link: Use linkat if arch does not have the link syscall Signed-off-by: Markos Chandras Signed-off-by: Bernhard Reutner-Fischer --- include/unistd.h | 1 + libc/sysdeps/linux/common/link.c | 9 +++++++++ libc/sysdeps/linux/common/linkat.c | 1 + 3 files changed, 11 insertions(+) diff --git a/include/unistd.h b/include/unistd.h index 137b0db0a..90d345972 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -887,6 +887,7 @@ extern int link (const char *__from, const char *__to) extern int linkat (int __fromfd, const char *__from, int __tofd, const char *__to, int __flags) __THROW __nonnull ((2, 4)) __wur; +libc_hidden_proto(linkat) #endif #if defined __USE_BSD || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K diff --git a/libc/sysdeps/linux/common/link.c b/libc/sysdeps/linux/common/link.c index b5e5536d5..86d4cfabc 100644 --- a/libc/sysdeps/linux/common/link.c +++ b/libc/sysdeps/linux/common/link.c @@ -9,4 +9,13 @@ #include #include + +#if defined __NR_linkat && !defined __NR_link +# include +int link(const char *oldpath, const char *newpath) +{ + return linkat(AT_FDCWD, oldpath, AT_FDCWD, newpath, 0); +} +#else _syscall2(int, link, const char *, oldpath, const char *, newpath) +#endif diff --git a/libc/sysdeps/linux/common/linkat.c b/libc/sysdeps/linux/common/linkat.c index 9abe9ec71..26a3d08e0 100644 --- a/libc/sysdeps/linux/common/linkat.c +++ b/libc/sysdeps/linux/common/linkat.c @@ -11,6 +11,7 @@ #ifdef __NR_linkat _syscall5(int, linkat, int, fromfd, const char *, from, int, tofd, const char *, to, int, flags) +libc_hidden_def(linkat) #else /* should add emulation with link() and /proc/self/fd/ ... */ #endif -- cgit v1.2.3