diff options
author | Wayne Davison <wayne@opencoder.net> | 2020-07-27 16:36:55 -0700 |
---|---|---|
committer | Wayne Davison <wayne@opencoder.net> | 2020-07-27 16:36:55 -0700 |
commit | 5db7e4b1eefb3fab6a5e5808d718bfe74ee79bc0 (patch) | |
tree | 1a04f3d5a6bb5640c433dcebb510f7bbed97a210 /syscall.c | |
parent | 54693fa992f6c8f66a6caee164117d752ab89cad (diff) | |
download | rsync-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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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 |