OSDN Git Service

link: Use linkat if arch does not have the link syscall
authorMarkos Chandras <markos.chandras@imgtec.com>
Wed, 10 Oct 2012 13:45:14 +0000 (14:45 +0100)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Wed, 20 Feb 2013 12:45:11 +0000 (13:45 +0100)
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
include/unistd.h
libc/sysdeps/linux/common/link.c
libc/sysdeps/linux/common/linkat.c

index 137b0db..90d3459 100644 (file)
@@ -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
index b5e5536..86d4cfa 100644 (file)
@@ -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
index 9abe9ec..26a3d08 100644 (file)
@@ -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