>From 3cc98a94d79c2f46f0c0bb70007987f377a65c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Thu, 12 Dec 2013 18:31:48 +0000 Subject: [PATCH] cp: with --link always use linkat() if available * src/copy.c (copy_reg): If linkat() is available it doesn't matter about the gnulib emulation provided, and thus the LINK_FOLLOWS_SYMLINKS should not have significance here. This was noticed on FreeBSD and the consequence is that cp --link will create hardlinks to symlinks there, rather than emulating with symlinks to symlinks. --- src/copy.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/copy.c b/src/copy.c index 0f044d0..3f148f1 100644 --- a/src/copy.c +++ b/src/copy.c @@ -2481,8 +2481,11 @@ copy_internal (char const *src_name, char const *dst_name, timestamps or ownership so we only call it when we know the emulation will not be needed. */ else if (x->hard_link +#if ! defined HAVE_LINKAT && !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode) - && x->dereference == DEREF_NEVER)) + && x->dereference == DEREF_NEVER) +#endif + ) { if (! create_hard_link (src_name, dst_name, false, false, dereference)) goto un_backup; @@ -2621,8 +2624,11 @@ copy_internal (char const *src_name, char const *dst_name, /* If we've just created a hard-link due to cp's --link option, we're done. */ if (x->hard_link && ! S_ISDIR (src_mode) +#if ! defined HAVE_LINKAT && !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode) - && x->dereference == DEREF_NEVER)) + && x->dereference == DEREF_NEVER) +#endif + ) return delayed_ok; if (copied_as_regular) -- 1.7.7.6