summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common
diff options
context:
space:
mode:
authorMarkos Chandras <markos.chandras@imgtec.com>2012-10-10 14:45:14 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2013-02-20 13:45:11 +0100
commit82fc713658c82cbbc577e6f8fa6cec67b911ba6e (patch)
tree2b38dcc179ae4cc03cdbfdfd85c3c3d8b4b40fc7 /libc/sysdeps/linux/common
parent695e274cf7f24c596258827ee202d29ff735d9b9 (diff)
link: Use linkat if arch does not have the link syscall
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r--libc/sysdeps/linux/common/link.c9
-rw-r--r--libc/sysdeps/linux/common/linkat.c1
2 files changed, 10 insertions, 0 deletions
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 <sys/syscall.h>
#include <unistd.h>
+
+#if defined __NR_linkat && !defined __NR_link
+# include <fcntl.h>
+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