summaryrefslogtreecommitdiff
path: root/syscall.c
diff options
context:
space:
mode:
authorWayne Davison <wayne@opencoder.net>2020-07-27 16:36:55 -0700
committerWayne Davison <wayne@opencoder.net>2020-07-27 16:36:55 -0700
commit5db7e4b1eefb3fab6a5e5808d718bfe74ee79bc0 (patch)
tree1a04f3d5a6bb5640c433dcebb510f7bbed97a210 /syscall.c
parent54693fa992f6c8f66a6caee164117d752ab89cad (diff)
downloadrsync-5db7e4b1eefb3fab6a5e5808d718bfe74ee79bc0.tar.gz
Use linkat() if available
Some OSes have a more capable linkat() function that can hard-link syslinks, so use linkat() when it is available.
Diffstat (limited to 'syscall.c')
-rw-r--r--syscall.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/syscall.c b/syscall.c
index 80cac204..b9c3b4ef 100644
--- a/syscall.c
+++ b/syscall.c
@@ -129,12 +129,16 @@ ssize_t do_readlink(const char *path, char *buf, size_t bufsiz)
#endif
#endif
-#ifdef HAVE_LINK
+#if defined HAVE_LINK || defined HAVE_LINKAT
int do_link(const char *old_path, const char *new_path)
{
if (dry_run) return 0;
RETURN_ERROR_IF_RO_OR_LO;
+#ifdef HAVE_LINKAT
+ return linkat(AT_FDCWD, old_path, AT_FDCWD, new_path, 0);
+#else
return link(old_path, new_path);
+#endif
}
#endif