From bf6bf52dce37832b03ecfbe1b3a3b104f532df42 Mon Sep 17 00:00:00 2001 From: Gian Piero Carrubba Date: Thu, 7 Nov 2013 23:35:52 +0100 Subject: cp: fix --link regarding the dereferencing of symbolic links * src/copy.c (create_hard_link): Add a bool 'dereference' parameter, and pass AT_SYMLINK_FOLLOW as 'flags' to linkat() when dereference is true. (should_dereference): Add new 'bool' function to determine if a file should be dereferenced or not. (copy_internal): Use the above new should_dereference() and remember its return value in a new local bool 'dereference' variable. Use that in all three calls to create_hard_link(). * src/cp.c (main): after parsing the options, if x.dereference is still DEFEF_UNDEFINED and the x.recursive is true, then only set x.dereference to DEREF_NEVER iff --link was not specified. * doc/coreutils.texi (cp invocation): Mention that cp(1) does not follow symbolic links in the source when --link is specified. Likewise in the description of the -R option when used together with that option. * tests/cp/same-file.sh: Adapt the expected results for the -fl, the -bl and the -bfl tests. * tests/cp/link-deref.sh: Add a new test. * tests/local.mk (all_tests): Reference the above new test. * NEWS (Changes in behavior): Mention the change. This fixes http://bugs.gnu.org/15173 Co-authored-by: Bernhard Voelker --- tests/local.mk | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/local.mk') diff --git a/tests/local.mk b/tests/local.mk index e18deacc7..3c924255f 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -427,6 +427,7 @@ all_tests = \ tests/cp/file-perm-race.sh \ tests/cp/into-self.sh \ tests/cp/link.sh \ + tests/cp/link-deref.sh \ tests/cp/link-no-deref.sh \ tests/cp/link-preserve.sh \ tests/cp/link-symlink.sh \ -- cgit v1.2.3-70-g09d2