From unknown Fri Jun 20 07:15:39 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#15173 <15173@debbugs.gnu.org> To: bug#15173 <15173@debbugs.gnu.org> Subject: Status: [cp] --link overrides dereference settings Reply-To: bug#15173 <15173@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:15:39 +0000 retitle 15173 [cp] --link overrides dereference settings reassign 15173 coreutils submitter 15173 Gian Piero Carrubba severity 15173 normal tag 15173 fixed thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 23 17:54:38 2013 Received: (at submit) by debbugs.gnu.org; 23 Aug 2013 21:54:38 +0000 Received: from localhost ([127.0.0.1]:50959 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VCzJV-0001Nf-Hc for submit@debbugs.gnu.org; Fri, 23 Aug 2013 17:54:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:47035) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VCz6l-00012v-2q for submit@debbugs.gnu.org; Fri, 23 Aug 2013 17:41:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VCz6e-0000Ca-Qk for submit@debbugs.gnu.org; Fri, 23 Aug 2013 17:41:26 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,UNPARSEABLE_RELAY autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:53152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCz6e-0000CS-Ne for submit@debbugs.gnu.org; Fri, 23 Aug 2013 17:41:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCz6Z-0001wR-L1 for bug-coreutils@gnu.org; Fri, 23 Aug 2013 17:41:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VCz6T-0000AB-Hl for bug-coreutils@gnu.org; Fri, 23 Aug 2013 17:41:15 -0400 Received: from ramona.rm-rf.it ([149.154.157.136]:50445) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCz6T-000090-8X for bug-coreutils@gnu.org; Fri, 23 Aug 2013 17:41:09 -0400 Received: from valentina.fdc.rm-rf.it (valentina.fdc.rm-rf.it [192.168.192.1]) by ramona.rm-rf.it (Postfix) with ESMTP id AB7952AD for ; Fri, 23 Aug 2013 23:41:05 +0200 (CEST) Received: from caimano.fdc.rm-rf.it (caimano.fdc.rm-rf.it [192.168.192.17]) by valentina.fdc.rm-rf.it (Postfix) with ESMTP id B3A132199F for ; Fri, 23 Aug 2013 23:40:34 +0200 (CEST) Received: from gpiero (uid 1000) (envelope-from gpiero@rm-rf.it) id 3c09b by caimano.fdc.rm-rf.it (DragonFly Mail Agent v0.9); Fri, 23 Aug 2013 23:40:34 +0200 Date: Fri, 23 Aug 2013 23:40:34 +0200 From: Gian Piero Carrubba To: bug-coreutils@gnu.org Subject: [cp] --link overrides dereference settings Message-ID: <20130823214034.GA9000@caimano.fdc.rm-rf.it> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ZPt4rx8FFjLCG7dd" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.4 (---) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 23 Aug 2013 17:54:36 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.4 (---) --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Please keep me in Cc: as I'm not subscribed. I failed to find references to discussions about this (intended?) behaviour, so I'm filing this report. Please forgive me if I've missed something elementary. $ echo testfile > file; ln -s file link; opts="-l -Ll -Hl"; for o in $opts; do cp $o link cp${o}; done; ls -li total 4 3358742 lrwxrwxrwx 4 gpiero gpiero 4 Aug 23 22:27 cp-Hl -> file 3358742 lrwxrwxrwx 4 gpiero gpiero 4 Aug 23 22:27 cp-Ll -> file 3358742 lrwxrwxrwx 4 gpiero gpiero 4 Aug 23 22:27 cp-l -> file 3358741 -rw-r--r-- 1 gpiero gpiero 9 Aug 23 22:27 file 3358742 lrwxrwxrwx 4 gpiero gpiero 4 Aug 23 22:27 link -> file I would have expected both 'cp-Hl' and 'cp-Ll' to be hardlinked to 'file', not to 'link'. $ cp --version | head -n1 cp (GNU coreutils) 8.21 $ uname -a Linux caimano 3.10-2-amd64 #1 SMP Debian 3.10.5-1 (2013-08-07) x86_64 GNU/Linux $ readlink -f /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/libc-2.17.so A tentative draft patch is attached. It still lacks unit tests and a way to determine if the implementation of linkat() supports flags. But most of all, please note that I'm not fully aware of the implications (including portability issues) of such a change. AFAICS, at least in one case the patch changes the behaviour of cp: $ echo testfile > file; ln -s file link; cp -l link cp-l.old; ../src/cp -l link cp-l.new; ls -li total 8 8912975 -rw-r--r-- 2 gpiero gpiero 9 Aug 23 22:58 cp-l.new 8913010 lrwxrwxrwx 2 gpiero gpiero 4 Aug 23 22:58 cp-l.old -> file 8912975 -rw-r--r-- 2 gpiero gpiero 9 Aug 23 22:58 file 8913010 lrwxrwxrwx 2 gpiero gpiero 4 Aug 23 22:58 link -> file This is caused by the following code: $ tail -n+1135 src/cp.c | head -n8 if (x.dereference == DEREF_UNDEFINED) { if (x.recursive) /* This is compatible with FreeBSD. */ x.dereference = DEREF_NEVER; else x.dereference = DEREF_ALWAYS; } Not sure why this snippet is there[0], but it seems to me that it leads to inconsistent behaviour: $ echo testfile > file; ln -s file link; cp link cp; cp -r link cp-r; ls -li total 8 3358743 -rw-r--r-- 1 gpiero gpiero 9 Aug 23 23:06 cp 3358744 lrwxrwxrwx 1 gpiero gpiero 4 Aug 23 23:06 cp-r -> file 3358741 -rw-r--r-- 1 gpiero gpiero 9 Aug 23 23:06 file 3358742 lrwxrwxrwx 1 gpiero gpiero 4 Aug 23 23:06 link -> file I think it is counterintuitive that '--recursive' had effects on the referentiation of the link.[1] Anyway, given that x.dereference is set to DEREF_ALWAYS, I think the modified behaviour of `cp -l` could be considered correct. Thanks, Gian Piero. [0] I suspect this is for backward compatibility. In principle, I think DEREF_UNDEF should always set DEREF_NEVER, but this change would modify a common, and well spread, behaviour. [1] The same stands for '--link', as demonstrated in the first example, when 'cp-l' has been created as a hardlink to the symlink (even if for different reasons: in that case DEREF_ALWAYS was in place, but linkat() didn't follow the symlink). --ZPt4rx8FFjLCG7dd Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="draft.patch" Fri Aug 23 20:29:12 CEST 2013 Gian Piero Carrubba * DRAFT diff -rN -u old-coreutils/src/copy.c new-coreutils/src/copy.c --- old-coreutils/src/copy.c 2013-08-23 22:16:15.938940800 +0200 +++ new-coreutils/src/copy.c 2013-08-23 22:16:15.942940823 +0200 @@ -1566,10 +1566,15 @@ be created as a symbolic link to SRC_NAME. */ static bool create_hard_link (char const *src_name, char const *dst_name, - bool replace, bool verbose) + bool replace, bool verbose, bool dereference) { - /* We want to guarantee that symlinks are not followed. */ - bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); + int flags; + if (dereference) + flags = AT_SYMLINK_FOLLOW; + else + flags = 0; /* We want to guarantee that symlinks are not followed. */ + + bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) != 0); /* If the link failed because of an existing destination, remove that file and then call link again. */ @@ -1582,7 +1587,7 @@ } if (verbose) printf (_("removed %s\n"), quote (dst_name)); - link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); + link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) != 0); } if (link_failed) @@ -1748,7 +1753,10 @@ /* Note we currently replace DST_NAME unconditionally, even if it was a newer separate file. */ if (! create_hard_link (earlier_file, dst_name, true, - x->verbose)) + x->verbose, + x->dereference == DEREF_ALWAYS + || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS + && command_line_arg))) { goto un_backup; } @@ -2078,7 +2086,10 @@ } else { - if (! create_hard_link (earlier_file, dst_name, true, x->verbose)) + if (! create_hard_link (earlier_file, dst_name, true, x->verbose, + x->dereference == DEREF_ALWAYS + || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS + && command_line_arg))) goto un_backup; return true; @@ -2389,7 +2400,10 @@ && !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode) && x->dereference == DEREF_NEVER)) { - if (! create_hard_link (src_name, dst_name, false, false)) + if (! create_hard_link (src_name, dst_name, false, false, + x->dereference == DEREF_ALWAYS + || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS + && command_line_arg))) goto un_backup; } else if (S_ISREG (src_mode) --ZPt4rx8FFjLCG7dd-- From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 19 21:11:16 2013 Received: (at 15173) by debbugs.gnu.org; 20 Oct 2013 01:11:16 +0000 Received: from localhost ([127.0.0.1]:58407 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXhY3-0006zE-Ku for submit@debbugs.gnu.org; Sat, 19 Oct 2013 21:11:16 -0400 Received: from moutng.kundenserver.de ([212.227.17.10]:63150) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VXhY0-0006z1-DP for 15173@debbugs.gnu.org; Sat, 19 Oct 2013 21:11:13 -0400 Received: from [192.168.1.11] (p5499C931.dip0.t-ipconnect.de [84.153.201.49]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0LhNMu-1W2cRd3OUa-00mZwq; Sun, 20 Oct 2013 03:11:06 +0200 Message-ID: <52632DA8.6080405@bernhard-voelker.de> Date: Sun, 20 Oct 2013 03:11:04 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Gian Piero Carrubba Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> In-Reply-To: <20130823214034.GA9000@caimano.fdc.rm-rf.it> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:yjD7eqEAj+RA2Z7HSj1EC6Vutc8xVqRMcnKeGglmSL7 ECymfBJzOyAOvzlExFoKSabSjjRdudUbmsU9f4iM/H+YgCKl6S ZIypmD1UKn5UCbX9CNyqJpxelTA+AYVM2gCFKwiq/w+5MavR8E qHBZFlBIuwnwGvbG4XGRbk1EYz3PJ98fPN+K+2gry7qsXX8UKP F9qgyUUww0HoRGSqjXcgkc5+MnzygkWETtRhMEZs1uyM/WoEOE or0Ts3FW97s5vLW1aoOk0kl3WfBvg14pq2xzrOLgGLNofHwXNs 6ZkAUhUa+rJIe89g8w646XjZnekKWddxWungSjGlpSsUnHwBPD R2PVs6p76NsuAfPv4jL8NtAl4xpSAax3LAZ7Cx2Id X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Hello Gian, On 08/23/2013 11:40 PM, Gian Piero Carrubba wrote: > Please keep me in Cc: as I'm not subscribed. > > I failed to find references to discussions about this (intended?) > behaviour, so I'm filing this report. Please forgive me if I've missed > something elementary. thanks for your bug report, the thorough thoughts about it and the patch proposal. > $ echo testfile > file; ln -s file link; opts="-l -Ll -Hl"; > for o in $opts; do cp $o link cp${o}; done; > ls -li > > total 4 > 3358742 lrwxrwxrwx 4 gpiero gpiero 4 Aug 23 22:27 cp-Hl -> file > 3358742 lrwxrwxrwx 4 gpiero gpiero 4 Aug 23 22:27 cp-Ll -> file > 3358742 lrwxrwxrwx 4 gpiero gpiero 4 Aug 23 22:27 cp-l -> file > 3358741 -rw-r--r-- 1 gpiero gpiero 9 Aug 23 22:27 file > 3358742 lrwxrwxrwx 4 gpiero gpiero 4 Aug 23 22:27 link -> file > > I would have expected both 'cp-Hl' and 'cp-Ll' to be hardlinked to > 'file', not to 'link'. I'd also say that the above is an error ... or at least contradicts to what is documented in the code (copy.c, line 2377): Yet cp, invoked with '--link --no-dereference', should not follow the link. > --- old-coreutils/src/copy.c 2013-08-23 22:16:15.938940800 +0200 > +++ new-coreutils/src/copy.c 2013-08-23 22:16:15.942940823 +0200 > @@ -1566,10 +1566,15 @@ > be created as a symbolic link to SRC_NAME. */ > static bool > create_hard_link (char const *src_name, char const *dst_name, > - bool replace, bool verbose) > + bool replace, bool verbose, bool dereference) > { > - /* We want to guarantee that symlinks are not followed. */ > - bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); > + int flags; > + if (dereference) > + flags = AT_SYMLINK_FOLLOW; > + else > + flags = 0; /* We want to guarantee that symlinks are not followed. */ > + > + bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) != 0); > > /* If the link failed because of an existing destination, > remove that file and then call link again. */ Instead of passing 'flags' to linkat (of which I don't know if it works on all platforms), I'd rather dereference the symlink manually: char *src_name_new = canonicalize_filename_mode (src_name, CAN_EXISTING); > AFAICS, at least in one case the patch changes the behaviour of cp: > > $ echo testfile > file; ln -s file link; > cp -l link cp-l.old; ../src/cp -l link cp-l.new; > ls -li > > total 8 > 8912975 -rw-r--r-- 2 gpiero gpiero 9 Aug 23 22:58 cp-l.new > 8913010 lrwxrwxrwx 2 gpiero gpiero 4 Aug 23 22:58 cp-l.old -> file > 8912975 -rw-r--r-- 2 gpiero gpiero 9 Aug 23 22:58 file > 8913010 lrwxrwxrwx 2 gpiero gpiero 4 Aug 23 22:58 link -> file Not ideal ... > This is caused by the following code: > > $ tail -n+1135 src/cp.c | head -n8 > if (x.dereference == DEREF_UNDEFINED) > { > if (x.recursive) > /* This is compatible with FreeBSD. */ > x.dereference = DEREF_NEVER; > else > x.dereference = DEREF_ALWAYS; > } Good analysis! My guess is that this because POSIX [1] allows either behavior: If source_file is a file of type symbolic link: [...] If the -R option was specified: If none of the options -H, -L, nor -P were specified, it is unspecified which of -H, -L, or -P will be used as a default. [1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html This means that coreutils has chosen in between what makes most sense and compatibility to other implementations. > Not sure why this snippet is there[0], but it seems to me that it leads > to inconsistent behaviour: > > $ echo testfile > file; ln -s file link; > cp link cp; cp -r link cp-r; > ls -li > > total 8 > 3358743 -rw-r--r-- 1 gpiero gpiero 9 Aug 23 23:06 cp > 3358744 lrwxrwxrwx 1 gpiero gpiero 4 Aug 23 23:06 cp-r -> file > 3358741 -rw-r--r-- 1 gpiero gpiero 9 Aug 23 23:06 file > 3358742 lrwxrwxrwx 1 gpiero gpiero 4 Aug 23 23:06 link -> file > > I think it is counterintuitive that '--recursive' had effects on the > referentiation of the link.[1] I think that is correct as POSIX requires this (see also in [1] above). Instead, I'd change the above initialization of x.dereference in the case the --link option is specified. I have wrapped it for you into a Git patch (below), yet without a test case. This is the result: $ : > file; ln -s file link $ for opt in "" -l -lH -lL -lP -r ; do cp $opt link cp$opt ; done $ ls -ldogi link file cp* 15335993 -rw-r--r-- 1 0 Oct 20 03:09 cp 15335992 lrwxrwxrwx 3 4 Oct 20 03:08 cp-l -> file 15335991 -rw-r--r-- 3 0 Oct 20 03:08 cp-lH 15335991 -rw-r--r-- 3 0 Oct 20 03:08 cp-lL 15335992 lrwxrwxrwx 3 4 Oct 20 03:08 cp-lP -> file 15335994 lrwxrwxrwx 1 4 Oct 20 03:09 cp-r -> file 15335991 -rw-r--r-- 3 0 Oct 20 03:08 file 15335992 lrwxrwxrwx 3 4 Oct 20 03:08 link -> file WDYT? BTW: tests/cp/same-file.sh now fails with the patch. Have a nice day, Berny >From fca06077e11d6338b35029bc61fbee5dbfb5ab66 Mon Sep 17 00:00:00 2001 From: Gian Piero Carrubba Date: Sun, 20 Oct 2013 03:04:41 +0200 Subject: [PATCH] cp: fix --link --dereference [DRAFT] * src/copy.c (create_hard_link): Add a bool 'dereference' parameter, and canonicalize the given src_name when dereference is true. (copy_internal): Add a value for the above new parameter in all three calls to create_hard_link: true if the src_name should be dereferenced before creating the hard link, false otherwise. * src/cp.c (main): after parsing the options, if x.dereference is still DEFEF_UNDEFINED and the --links option was specified, initialize x.dereference to DEREF_NEVER. * NEWS (Changes in behavior): Mention the change. This fixes http://bugs.gnu.org/15173 --- NEWS | 4 ++++ src/copy.c | 42 ++++++++++++++++++++++++++++++------------ src/cp.c | 2 +- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index 39dd3d6..c1d637c 100644 --- a/NEWS +++ b/NEWS @@ -70,6 +70,10 @@ GNU coreutils NEWS -*- outline -*- ** Changes in behavior + cp --link --dereference now dereferences a symbolic link as source files + before creating the hard link in the destination. + Previously, it would create a hard link of the symbolic link. + dd status=none now suppresses all non fatal diagnostic messages, not just the transfer counts. diff --git a/src/copy.c b/src/copy.c index f66ab46..fa4d734 100644 --- a/src/copy.c +++ b/src/copy.c @@ -1558,18 +1558,23 @@ restore_default_fscreatecon_or_die (void) _("failed to restore the default file creation context")); } -/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE and - VERBOSE settings. Return true upon success. Otherwise, diagnose - the failure and return false. - If SRC_NAME is a symbolic link it will not be followed. If the system - doesn't support hard links to symbolic links, then DST_NAME will - be created as a symbolic link to SRC_NAME. */ +/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE, + VERBOSE and DEREFERENCE settings. Return true upon success. + Otherwise, diagnose the failure and return false. + If SRC_NAME is a symbolic link it will not be followed unless DEREFERENCE + is true. If the system doesn't support hard links to symbolic links, + then DST_NAME will be created as a symbolic link to SRC_NAME. */ static bool create_hard_link (char const *src_name, char const *dst_name, - bool replace, bool verbose) + bool replace, bool verbose, bool dereference) { + char *src_deref = NULL; + if (dereference) + src_deref = canonicalize_filename_mode (src_name, CAN_EXISTING); + /* We want to guarantee that symlinks are not followed. */ - bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); + bool link_failed = (linkat (AT_FDCWD, dereference ? src_deref : src_name, + AT_FDCWD, dst_name, 0) != 0); /* If the link failed because of an existing destination, remove that file and then call link again. */ @@ -1578,13 +1583,17 @@ create_hard_link (char const *src_name, char const *dst_name, if (unlink (dst_name) != 0) { error (0, errno, _("cannot remove %s"), quote (dst_name)); + free (src_deref); return false; } if (verbose) printf (_("removed %s\n"), quote (dst_name)); - link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); + link_failed = (linkat (AT_FDCWD, dereference ? src_deref : src_name, + AT_FDCWD, dst_name, 0) != 0); } + free (src_deref); + if (link_failed) { error (0, errno, _("cannot create hard link %s to %s"), @@ -1748,7 +1757,10 @@ copy_internal (char const *src_name, char const *dst_name, /* Note we currently replace DST_NAME unconditionally, even if it was a newer separate file. */ if (! create_hard_link (earlier_file, dst_name, true, - x->verbose)) + x->verbose, + x->dereference == DEREF_ALWAYS + || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS + && command_line_arg))) { goto un_backup; } @@ -2078,7 +2090,10 @@ copy_internal (char const *src_name, char const *dst_name, } else { - if (! create_hard_link (earlier_file, dst_name, true, x->verbose)) + if (! create_hard_link (earlier_file, dst_name, true, x->verbose, + x->dereference == DEREF_ALWAYS + || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS + && command_line_arg))) goto un_backup; return true; @@ -2389,7 +2404,10 @@ copy_internal (char const *src_name, char const *dst_name, && !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode) && x->dereference == DEREF_NEVER)) { - if (! create_hard_link (src_name, dst_name, false, false)) + if (! create_hard_link (src_name, dst_name, false, false, + x->dereference == DEREF_ALWAYS + || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS + && command_line_arg))) goto un_backup; } else if (S_ISREG (src_mode) diff --git a/src/cp.c b/src/cp.c index 7bc8630..6efb152 100644 --- a/src/cp.c +++ b/src/cp.c @@ -1135,7 +1135,7 @@ main (int argc, char **argv) if (x.dereference == DEREF_UNDEFINED) { - if (x.recursive) + if (x.recursive || x.hard_link) /* This is compatible with FreeBSD. */ x.dereference = DEREF_NEVER; else -- 1.8.3.1 From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 23 17:12:48 2013 Received: (at 15173) by debbugs.gnu.org; 23 Oct 2013 21:12:48 +0000 Received: from localhost ([127.0.0.1]:38914 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VZ5jT-0003TU-KX for submit@debbugs.gnu.org; Wed, 23 Oct 2013 17:12:48 -0400 Received: from ramona.rm-rf.it ([149.154.157.136]:35045) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VZ5jP-0003TB-V8 for 15173@debbugs.gnu.org; Wed, 23 Oct 2013 17:12:45 -0400 Received: from valentina.fdc.rm-rf.it (valentina.fdc.rm-rf.it [192.168.192.1]) by ramona.rm-rf.it (Postfix) with ESMTP id B4105134 for <15173@debbugs.gnu.org>; Wed, 23 Oct 2013 23:12:36 +0200 (CEST) Received: from caimano.fdc.rm-rf.it (caimano.fdc.rm-rf.it [192.168.192.17]) by valentina.fdc.rm-rf.it (Postfix) with ESMTP id CBCC320916 for <15173@debbugs.gnu.org>; Wed, 23 Oct 2013 23:12:04 +0200 (CEST) Received: from gpiero (uid 1000) (envelope-from gpiero@rm-rf.it) id 3c014 by caimano.fdc.rm-rf.it (DragonFly Mail Agent v0.9); Wed, 23 Oct 2013 23:12:03 +0200 Date: Wed, 23 Oct 2013 23:12:03 +0200 From: Gian Piero Carrubba To: Bernhard Voelker Subject: Re: bug#15173: [cp] --link overrides dereference settings Message-ID: <20131023211203.GA8284@caimano.fdc.rm-rf.it> References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <52632DA8.6080405@bernhard-voelker.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -0.4 (/) X-Debbugs-Envelope-To: 15173 Cc: 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) * [Sun, Oct 20, 2013 at 03:11:04AM +0200] Bernhard Voelker: >Hello Gian, Hi Bernhard, thank you for your answer and the fixed patch. [...] >Instead of passing 'flags' to linkat (of which I don't know if it works >on all platforms), I'd rather dereference the symlink manually: > > char *src_name_new =3D canonicalize_filename_mode (src_name, CAN_EXISTIN= G); Good idea. It sounds sensible and should avoid portability issues (I=20 have to admit I didn't investigate further about those). >> AFAICS, at least in one case the patch changes the behaviour of cp: >> >> $ echo testfile > file; ln -s file link; >> cp -l link cp-l.old; ../src/cp -l link cp-l.new; >> ls -li >> >> total 8 >> 8912975 -rw-r--r-- 2 gpiero gpiero 9 Aug 23 22:58 cp-l.new >> 8913010 lrwxrwxrwx 2 gpiero gpiero 4 Aug 23 22:58 cp-l.old -> file >> 8912975 -rw-r--r-- 2 gpiero gpiero 9 Aug 23 22:58 file >> 8913010 lrwxrwxrwx 2 gpiero gpiero 4 Aug 23 22:58 link -> file > >Not ideal ... Surely not, but I think the 'new' behaviour is the "right" one. Being my turn for quoting the SUS :) If source_file is a file of type symbolic link: If the -R option was not specified, cp shall take actions based on=20 the type and contents of the file referenced by the symbolic link,=20 and not by the symbolic link itself This is also consistent with: $ echo testfile > file; ln -s file link; cp link cp ; ls -li total 8 5678474 -rw-r--r-- 1 gpiero gpiero 9 Oct 23 22:45 cp 5678472 -rw-r--r-- 1 gpiero gpiero 9 Oct 23 22:45 file 5678473 lrwxrwxrwx 1 gpiero gpiero 4 Oct 23 22:45 link -> file where 'cp' is a copy of 'file', not of 'link'. >My guess is that this because POSIX [1] allows either behavior: > > If source_file is a file of type symbolic link: > [...] > If the -R option was specified: > If none of the options -H, -L, nor -P were specified, it is > unspecified which of -H, -L, or -P will be used as a default. > >[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html > >This means that coreutils has chosen in between what makes most sense >and compatibility to other implementations. > >> Not sure why this snippet is there[0], but it seems to me that it leads >> to inconsistent behaviour: >> >> $ echo testfile > file; ln -s file link; >> cp link cp; cp -r link cp-r; >> ls -li >> >> total 8 >> 3358743 -rw-r--r-- 1 gpiero gpiero 9 Aug 23 23:06 cp >> 3358744 lrwxrwxrwx 1 gpiero gpiero 4 Aug 23 23:06 cp-r -> file >> 3358741 -rw-r--r-- 1 gpiero gpiero 9 Aug 23 23:06 file >> 3358742 lrwxrwxrwx 1 gpiero gpiero 4 Aug 23 23:06 link -> file >> >> I think it is counterintuitive that '--recursive' had effects on the >> referentiation of the link.[1] > >I think that is correct as POSIX requires this (see also in [1] above). Not sure. Probably I failed to clearly explain what I think the problem=20 is, but I miss to see how POSIX mandates it (from the quote you posted,=20 being '-r' the only option, the behaviour is unspecified, so I don't=20 think we could contradict POSIX modifying how it behaves). What I mean is that currently, if the source is a symlink: - `cp` copies the file referenced by the symlink - `cp -r` copies the symlink itself This is inconsistent, as '--recursive' should not have effect on the=20 dereferencing setting, being them two orthogonal features. It seems like=20 a side-(not-expected/desired)-effect. If I wanted to copy the symlink, I=20 should have used `cp -P`. What I propose is: - if the symlink points to a regular file, `cp -r` should copy the file=20 referenced by the symlink (acts like a plain `cp`, that in turn acts=20 the same as `cp -H` in this case) - if the symlink points to a directory, ditto but taking care of not=20 dereferencing the symlinks inside the dir (acts like if '-H' was used,= =20 and again like a plain `cp`, with the only obvious difference that a=20 plain `cp` would fail in this case) I don't think this would be "prohibited" by POSIX (and as a bonus it's a=20 singe line patch :) ). Anyway, all this probably=17 belongs to another bug report (and though I=20 think it's the "right thing", I'm also afraid of the possible impact of=20 such a change). >Instead, I'd change the above initialization of x.dereference in the >case the --link option is specified. > >I have wrapped it for you into a Git patch (below), yet without a test >case. > >This is the result: > > $ : > file; ln -s file link > $ for opt in "" -l -lH -lL -lP -r ; do cp $opt link cp$opt ; done > $ ls -ldogi link file cp* > 15335993 -rw-r--r-- 1 0 Oct 20 03:09 cp > 15335992 lrwxrwxrwx 3 4 Oct 20 03:08 cp-l -> file > 15335991 -rw-r--r-- 3 0 Oct 20 03:08 cp-lH > 15335991 -rw-r--r-- 3 0 Oct 20 03:08 cp-lL > 15335992 lrwxrwxrwx 3 4 Oct 20 03:08 cp-lP -> file > 15335994 lrwxrwxrwx 1 4 Oct 20 03:09 cp-r -> file > 15335991 -rw-r--r-- 3 0 Oct 20 03:08 file > 15335992 lrwxrwxrwx 3 4 Oct 20 03:08 link -> file As said above, I think `cp -l` should dereference the symlink, so I=20 would omit the change in the initialization of x.dereference. >BTW: tests/cp/same-file.sh now fails with the patch. I hope I can double check and submit a patch for that test during the=20 next days. As for the test case, what do you suggest ? The test you=20 posted above (for opt in "" -l -lH -lL -lP -r ...) would be sufficient ? Ciao, Gian Piero. From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 29 14:28:05 2013 Received: (at 15173) by debbugs.gnu.org; 29 Oct 2013 18:28:05 +0000 Received: from localhost ([127.0.0.1]:51480 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VbE1L-0007ov-MU for submit@debbugs.gnu.org; Tue, 29 Oct 2013 14:28:04 -0400 Received: from mail5.vodafone.ie ([213.233.128.176]:49245) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VbE1G-0007oK-7r for 15173@debbugs.gnu.org; Tue, 29 Oct 2013 14:28:00 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApUBAIv9b1JtTblQ/2dsb2JhbAANTIM/ToMZu1ZLgUKDGQEBAQMBIwQLAUYFCwsNAQMDAQIBAgIFFgsCAgkDAgECAT0IBgoDAQUCAQEWh2cLAwWmU3aSZIEpjh4HgmqBQgOZOYU0hXGIWg Received: from unknown (HELO [192.168.1.79]) ([109.77.185.80]) by mail3.vodafone.ie with ESMTP; 29 Oct 2013 18:27:51 +0000 Message-ID: <526FFE26.9020704@draigBrady.com> Date: Tue, 29 Oct 2013 18:27:50 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> In-Reply-To: <52632DA8.6080405@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 10/20/2013 02:11 AM, Bernhard Voelker wrote: > Hello Gian, > > On 08/23/2013 11:40 PM, Gian Piero Carrubba wrote: >> Please keep me in Cc: as I'm not subscribed. >> >> I failed to find references to discussions about this (intended?) >> behaviour, so I'm filing this report. Please forgive me if I've missed >> something elementary. > > thanks for your bug report, the thorough thoughts about it and the > patch proposal. This looks like a valid issue... >> $ echo testfile > file; ln -s file link; opts="-l -Ll -Hl"; >> for o in $opts; do cp $o link cp${o}; done; >> ls -li >> >> total 4 >> 3358742 lrwxrwxrwx 4 gpiero gpiero 4 Aug 23 22:27 cp-Hl -> file >> 3358742 lrwxrwxrwx 4 gpiero gpiero 4 Aug 23 22:27 cp-Ll -> file >> 3358742 lrwxrwxrwx 4 gpiero gpiero 4 Aug 23 22:27 cp-l -> file >> 3358741 -rw-r--r-- 1 gpiero gpiero 9 Aug 23 22:27 file >> 3358742 lrwxrwxrwx 4 gpiero gpiero 4 Aug 23 22:27 link -> file >> >> I would have expected both 'cp-Hl' and 'cp-Ll' to be hardlinked to >> 'file', not to 'link'. > > I'd also say that the above is an error ... or at least contradicts > to what is documented in the code (copy.c, line 2377): > > Yet cp, invoked with '--link --no-dereference', > should not follow the link. Yes I would think that `ln -L` and `cp --link -L` should be equivalent in this regard. >> --- old-coreutils/src/copy.c 2013-08-23 22:16:15.938940800 +0200 >> +++ new-coreutils/src/copy.c 2013-08-23 22:16:15.942940823 +0200 >> @@ -1566,10 +1566,15 @@ >> be created as a symbolic link to SRC_NAME. */ >> static bool >> create_hard_link (char const *src_name, char const *dst_name, >> - bool replace, bool verbose) >> + bool replace, bool verbose, bool dereference) >> { >> - /* We want to guarantee that symlinks are not followed. */ >> - bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); >> + int flags; >> + if (dereference) >> + flags = AT_SYMLINK_FOLLOW; >> + else >> + flags = 0; /* We want to guarantee that symlinks are not followed. */ >> + >> + bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) != 0); >> >> /* If the link failed because of an existing destination, >> remove that file and then call link again. */ > > Instead of passing 'flags' to linkat (of which I don't know if it works > on all platforms), I'd rather dereference the symlink manually: > > char *src_name_new = canonicalize_filename_mode (src_name, CAN_EXISTING); Actually since linkat() has defined semantics, _and thanks to gnulib, guaranteed semantics_ we should just leverage the gnulib magic here, and use linkat with flags. >> AFAICS, at least in one case the patch changes the behaviour of cp: >> >> $ echo testfile > file; ln -s file link; >> cp -l link cp-l.old; ../src/cp -l link cp-l.new; >> ls -li >> >> total 8 >> 8912975 -rw-r--r-- 2 gpiero gpiero 9 Aug 23 22:58 cp-l.new >> 8913010 lrwxrwxrwx 2 gpiero gpiero 4 Aug 23 22:58 cp-l.old -> file >> 8912975 -rw-r--r-- 2 gpiero gpiero 9 Aug 23 22:58 file >> 8913010 lrwxrwxrwx 2 gpiero gpiero 4 Aug 23 22:58 link -> file > > Not ideal ... > >> This is caused by the following code: >> >> $ tail -n+1135 src/cp.c | head -n8 >> if (x.dereference == DEREF_UNDEFINED) >> { >> if (x.recursive) >> /* This is compatible with FreeBSD. */ >> x.dereference = DEREF_NEVER; >> else >> x.dereference = DEREF_ALWAYS; >> } Interesting. You'd nearly think it should be the other way around, given linking to symlinks when copying to other directories, may give invalid symlinks if they link outside the copied hierarchy. > Good analysis! > My guess is that this because POSIX [1] allows either behavior: > > If source_file is a file of type symbolic link: > [...] > If the -R option was specified: > If none of the options -H, -L, nor -P were specified, it is > unspecified which of -H, -L, or -P will be used as a default. > > [1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html > > This means that coreutils has chosen in between what makes most sense > and compatibility to other implementations. > >> Not sure why this snippet is there[0], but it seems to me that it leads >> to inconsistent behaviour: >> >> $ echo testfile > file; ln -s file link; >> cp link cp; cp -r link cp-r; >> ls -li >> >> total 8 >> 3358743 -rw-r--r-- 1 gpiero gpiero 9 Aug 23 23:06 cp >> 3358744 lrwxrwxrwx 1 gpiero gpiero 4 Aug 23 23:06 cp-r -> file >> 3358741 -rw-r--r-- 1 gpiero gpiero 9 Aug 23 23:06 file >> 3358742 lrwxrwxrwx 1 gpiero gpiero 4 Aug 23 23:06 link -> file >> >> I think it is counterintuitive that '--recursive' had effects on the >> referentiation of the link.[1] > > I think that is correct as POSIX requires this (see also in [1] above). > > Instead, I'd change the above initialization of x.dereference in the > case the --link option is specified. > > I have wrapped it for you into a Git patch (below), yet without a test > case. > > This is the result: > > $ : > file; ln -s file link > $ for opt in "" -l -lH -lL -lP -r ; do cp $opt link cp$opt ; done > $ ls -ldogi link file cp* Nice basis for a test. > 15335993 -rw-r--r-- 1 0 Oct 20 03:09 cp > 15335992 lrwxrwxrwx 3 4 Oct 20 03:08 cp-l -> file > 15335991 -rw-r--r-- 3 0 Oct 20 03:08 cp-lH > 15335991 -rw-r--r-- 3 0 Oct 20 03:08 cp-lL > 15335992 lrwxrwxrwx 3 4 Oct 20 03:08 cp-lP -> file > 15335994 lrwxrwxrwx 1 4 Oct 20 03:09 cp-r -> file > 15335991 -rw-r--r-- 3 0 Oct 20 03:08 file > 15335992 lrwxrwxrwx 3 4 Oct 20 03:08 link -> file The above look correct. For comparison on FreeBSD 9.1 1755429 -rw-r--r-- 1 pbrady pbrady - 0 Oct 29 12:16 cp 1755427 -rw-r--r-- 5 pbrady pbrady - 0 Oct 29 12:16 cp-l 1755427 -rw-r--r-- 5 pbrady pbrady - 0 Oct 29 12:16 cp-lH 1755427 -rw-r--r-- 5 pbrady pbrady - 0 Oct 29 12:16 cp-lL 1755427 -rw-r--r-- 5 pbrady pbrady - 0 Oct 29 12:16 cp-lP 1755430 -rw-r--r-- 1 pbrady pbrady - 0 Oct 29 12:16 cp-r 1755427 -rw-r--r-- 5 pbrady pbrady - 0 Oct 29 12:16 file 1755428 lrwxr-xr-x 1 pbrady pbrady - 4 Oct 29 12:16 link -> file And from older 8.10 GNU cp we have: 2368286 -rw-rw-r--. 1 0 Oct 29 18:19 cp 2368262 lrwxrwxrwx. 4 4 Oct 29 18:19 cp-l -> file 2368262 lrwxrwxrwx. 4 4 Oct 29 18:19 cp-lH -> file 2368262 lrwxrwxrwx. 4 4 Oct 29 18:19 cp-lL -> file 2368298 lrwxrwxrwx. 1 4 Oct 29 18:19 cp-lP -> file 2368299 lrwxrwxrwx. 1 4 Oct 29 18:19 cp-r -> file 2368218 -rw-rw-r--. 1 0 Oct 29 18:19 file 2368262 lrwxrwxrwx. 4 4 Oct 29 18:19 link -> file In both the above we seem to be just getting the default dereferencing behavior of link(1). > WDYT? > > BTW: tests/cp/same-file.sh now fails with the patch. Yes better to consolidate the functionality, before doing the tests to avoid awkward test churn. > Have a nice day, > Berny > > >>>From fca06077e11d6338b35029bc61fbee5dbfb5ab66 Mon Sep 17 00:00:00 2001 > From: Gian Piero Carrubba > Date: Sun, 20 Oct 2013 03:04:41 +0200 > Subject: [PATCH] cp: fix --link --dereference [DRAFT] > > * src/copy.c (create_hard_link): Add a bool 'dereference' parameter, > and canonicalize the given src_name when dereference is true. > (copy_internal): Add a value for the above new parameter in all > three calls to create_hard_link: true if the src_name should be > dereferenced before creating the hard link, false otherwise. > * src/cp.c (main): after parsing the options, if x.dereference is > still DEFEF_UNDEFINED and the --links option was specified, initialize s/--links/--link/ > x.dereference to DEREF_NEVER. > * NEWS (Changes in behavior): Mention the change. > > This fixes http://bugs.gnu.org/15173 > --- > NEWS | 4 ++++ > src/copy.c | 42 ++++++++++++++++++++++++++++++------------ > src/cp.c | 2 +- > 3 files changed, 35 insertions(+), 13 deletions(-) > > diff --git a/NEWS b/NEWS > index 39dd3d6..c1d637c 100644 > --- a/NEWS > +++ b/NEWS > @@ -70,6 +70,10 @@ GNU coreutils NEWS -*- outline -*- > > ** Changes in behavior > > + cp --link --dereference now dereferences a symbolic link as source files > + before creating the hard link in the destination. > + Previously, it would create a hard link of the symbolic link. > + > dd status=none now suppresses all non fatal diagnostic messages, > not just the transfer counts. > > diff --git a/src/copy.c b/src/copy.c > index f66ab46..fa4d734 100644 > --- a/src/copy.c > +++ b/src/copy.c > @@ -1558,18 +1558,23 @@ restore_default_fscreatecon_or_die (void) > _("failed to restore the default file creation context")); > } > > -/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE and > - VERBOSE settings. Return true upon success. Otherwise, diagnose > - the failure and return false. > - If SRC_NAME is a symbolic link it will not be followed. If the system > - doesn't support hard links to symbolic links, then DST_NAME will > - be created as a symbolic link to SRC_NAME. */ > +/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE, > + VERBOSE and DEREFERENCE settings. Return true upon success. > + Otherwise, diagnose the failure and return false. > + If SRC_NAME is a symbolic link it will not be followed unless DEREFERENCE > + is true. If the system doesn't support hard links to symbolic links, > + then DST_NAME will be created as a symbolic link to SRC_NAME. */ > static bool > create_hard_link (char const *src_name, char const *dst_name, > - bool replace, bool verbose) > + bool replace, bool verbose, bool dereference) > { > + char *src_deref = NULL; > + if (dereference) > + src_deref = canonicalize_filename_mode (src_name, CAN_EXISTING); Probably best avoided as mentioned above. > /* We want to guarantee that symlinks are not followed. */ > - bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); > + bool link_failed = (linkat (AT_FDCWD, dereference ? src_deref : src_name, > + AT_FDCWD, dst_name, 0) != 0); > > /* If the link failed because of an existing destination, > remove that file and then call link again. */ > @@ -1578,13 +1583,17 @@ create_hard_link (char const *src_name, char const *dst_name, > if (unlink (dst_name) != 0) > { > error (0, errno, _("cannot remove %s"), quote (dst_name)); > + free (src_deref); > return false; > } > if (verbose) > printf (_("removed %s\n"), quote (dst_name)); > - link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); > + link_failed = (linkat (AT_FDCWD, dereference ? src_deref : src_name, > + AT_FDCWD, dst_name, 0) != 0); > } > > + free (src_deref); > + > if (link_failed) > { > error (0, errno, _("cannot create hard link %s to %s"), > @@ -1748,7 +1757,10 @@ copy_internal (char const *src_name, char const *dst_name, > /* Note we currently replace DST_NAME unconditionally, > even if it was a newer separate file. */ > if (! create_hard_link (earlier_file, dst_name, true, > - x->verbose)) > + x->verbose, > + x->dereference == DEREF_ALWAYS > + || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS > + && command_line_arg))) > { > goto un_backup; > } > @@ -2078,7 +2090,10 @@ copy_internal (char const *src_name, char const *dst_name, > } > else > { > - if (! create_hard_link (earlier_file, dst_name, true, x->verbose)) > + if (! create_hard_link (earlier_file, dst_name, true, x->verbose, > + x->dereference == DEREF_ALWAYS > + || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS > + && command_line_arg))) > goto un_backup; > > return true; > @@ -2389,7 +2404,10 @@ copy_internal (char const *src_name, char const *dst_name, > && !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode) > && x->dereference == DEREF_NEVER)) > { > - if (! create_hard_link (src_name, dst_name, false, false)) > + if (! create_hard_link (src_name, dst_name, false, false, > + x->dereference == DEREF_ALWAYS > + || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS > + && command_line_arg))) Lots and copy and paste there. Maybe use a helper like: static inline bool _GL_ATTRIBUTE_PURE should_dereference (const struct cp_options *x, bool cli_arg) { return x->dereference == DEREF_ALWAYS || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS && cli_arg); } > goto un_backup; > } > else if (S_ISREG (src_mode) > diff --git a/src/cp.c b/src/cp.c > index 7bc8630..6efb152 100644 > --- a/src/cp.c > +++ b/src/cp.c > @@ -1135,7 +1135,7 @@ main (int argc, char **argv) > > if (x.dereference == DEREF_UNDEFINED) > { > - if (x.recursive) > + if (x.recursive || x.hard_link) > /* This is compatible with FreeBSD. */ > x.dereference = DEREF_NEVER; > else > Thanks to both of you for looking into this awkward issue. Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 30 08:14:09 2013 Received: (at 15173) by debbugs.gnu.org; 30 Oct 2013 12:14:09 +0000 Received: from localhost ([127.0.0.1]:52348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VbUf2-0007iS-PC for submit@debbugs.gnu.org; Wed, 30 Oct 2013 08:14:09 -0400 Received: from moutng.kundenserver.de ([212.227.17.8]:61683) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VbUf0-0007hq-JQ for 15173@debbugs.gnu.org; Wed, 30 Oct 2013 08:14:07 -0400 Received: from oxbaltgw13.schlund.de (oxbaltgw13.schlund.de [172.19.246.19]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0LyQ8Q-1VhIDA31Gg-0165au; Wed, 30 Oct 2013 13:13:58 +0100 Date: Wed, 30 Oct 2013 13:13:58 +0100 (CET) From: Bernhard Voelker To: =?UTF-8?Q?P=C3=A1draig_Brady?= Message-ID: <737687497.219518.1383135238736.open-xchange@email.1und1.de> In-Reply-To: <526FFE26.9020704@draigBrady.com> References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> Subject: Re: bug#15173: [cp] --link overrides dereference settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.2.2-Rev25 X-Provags-ID: V02:K0:oBgJJSoFiKjTrjmT2fMNZI6/NRg3ArT+PeaLkAXGdqp n11ZIDizfPWweoVD/lEeElKi34tFQpOiLVprOk025+YL94338F Ii7P8GrDtVvP0WzYRXMvQiInkBiNaKAEJc6LAoUMrePwCybexz n94P3jmjSgQ5dvtZ/+QPO3D20AVSGP7f9RQZMbC9B40iWU6itK VH+IEI2rYyq+BSj7DbQYYI+oySFJRqC7uAMpKro6Fk4ysj7qk5 3lpPFoPkj7AjAsrrw1mh+IiWfNeIkd2bkMFOlshEOe/3dLoxKk NM0YfAm4EyRXw4jsiw5PZcMONkaFoOLdEVABrDmlze1k6QQQAq Xspi2s68D8Q221SxJ4M+Bm4+0k4LIC3A8eOSsCKLFxIQT2l4PJ dv+PUqqn90xE30z4YhHygoEGM00AcQUCPI= X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Bernhard Voelker List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) > On October 29, 2013 at 7:27 PM P=C3=A1draig Brady wrot= e: > On 10/20/2013 02:11 AM, Bernhard Voelker wrote: > >> I would have expected both 'cp-Hl' and 'cp-Ll' to be hardlinked to > >> 'file', not to 'link'. > > > > I'd also say that the above is an error ... or at least contradicts > > to what is documented in the code (copy.c, line 2377): > > > >=C2=A0 =C2=A0 Yet cp, invoked with '--link --no-dereference', > >=C2=A0 =C2=A0 should not follow the link. > > Yes I would think that `ln -L` and `cp --link -L` should > be equivalent in this regard. s/ln -L/ln -n/,=C2=A0 I guess. =C2=A0 > > Instead of passing 'flags' to linkat (of which I don't know if it works > > on all platforms), I'd rather dereference the symlink manually: > > > >=C2=A0 =C2=A0char *src_name_new =3D canonicalize_filename_mode (src_name= , CAN_EXISTING); > > Actually since linkat() has defined semantics, > _and thanks to gnulib, guaranteed semantics_ > we should just leverage the gnulib magic here, > and use linkat with flags. Thanks for the clarification. I changed it back to Gian's version. > > This is the result: > > > >=C2=A0 =C2=A0$ : > file; ln -s file link > >=C2=A0 =C2=A0$ for opt in "" -l -lH -lL -lP -r ; do cp $opt link cp$opt = ; done > >=C2=A0 =C2=A0$ ls -ldogi link file cp* > > Nice basis for a test. Yes, but it's not enough: I exercised also some combinations with -lrP -lrH -lrL, and the whole stuff again for a symlink pointing to a directory. It got a bit late yesterday, and I couldn't get the things sorted to present here. All Ican say now is that there are still corner cases where cp now behaves differently (e.g. "cp -l link2dir dst"). I hope I can get back here with the results this evening. > >=C2=A0 =C2=A015335993 -rw-r--r-- 1 0 Oct 20 03:09 cp > >=C2=A0 =C2=A015335992 lrwxrwxrwx 3 4 Oct 20 03:08 cp-l -> file > >=C2=A0 =C2=A015335991 -rw-r--r-- 3 0 Oct 20 03:08 cp-lH > >=C2=A0 =C2=A015335991 -rw-r--r-- 3 0 Oct 20 03:08 cp-lL > >=C2=A0 =C2=A015335992 lrwxrwxrwx 3 4 Oct 20 03:08 cp-lP -> file > >=C2=A0 =C2=A015335994 lrwxrwxrwx 1 4 Oct 20 03:09 cp-r -> file > >=C2=A0 =C2=A015335991 -rw-r--r-- 3 0 Oct 20 03:08 file > >=C2=A0 =C2=A015335992 lrwxrwxrwx 3 4 Oct 20 03:08 link -> file > > The above look correct. Great, thanks. > For comparison on FreeBSD 9.1 > > 1755429 -rw-r--r--=C2=A0 1 pbrady=C2=A0 pbrady=C2=A0 - 0 Oct 29 12:16 cp > 1755427 -rw-r--r--=C2=A0 5 pbrady=C2=A0 pbrady=C2=A0 - 0 Oct 29 12:16 cp-= l > 1755427 -rw-r--r--=C2=A0 5 pbrady=C2=A0 pbrady=C2=A0 - 0 Oct 29 12:16 cp-= lH > 1755427 -rw-r--r--=C2=A0 5 pbrady=C2=A0 pbrady=C2=A0 - 0 Oct 29 12:16 cp-= lL > 1755427 -rw-r--r--=C2=A0 5 pbrady=C2=A0 pbrady=C2=A0 - 0 Oct 29 12:16 cp-= lP > 1755430 -rw-r--r--=C2=A0 1 pbrady=C2=A0 pbrady=C2=A0 - 0 Oct 29 12:16 cp-= r > 1755427 -rw-r--r--=C2=A0 5 pbrady=C2=A0 pbrady=C2=A0 - 0 Oct 29 12:16 fil= e > 1755428 lrwxr-xr-x=C2=A0 1 pbrady=C2=A0 pbrady=C2=A0 - 4 Oct 29 12:16 lin= k -> file Interesting. =C2=A0 > > BTW: tests/cp/same-file.sh now fails with the patch. > > Yes better to consolidate the functionality, > before doing the tests to avoid awkward test churn. yes, regarding from what I got with the tests mentioned above, I'm still not convinced we're at that point. > >>From fca06077e11d6338b35029bc61fbee5dbfb5ab66 Mon Sep 17 00:00:00 2001 > > From: Gian Piero Carrubba > > Date: Sun, 20 Oct 2013 03:04:41 +0200 > > Subject: [PATCH] cp: fix --link --dereference [DRAFT] > > > > * src/copy.c (create_hard_link): Add a bool 'dereference' parameter, > > and canonicalize the given src_name when dereference is true. > > (copy_internal): Add a value for the above new parameter in all > > three calls to create_hard_link: true if the src_name should be > > dereferenced before creating the hard link, false otherwise. > > * src/cp.c (main): after parsing the options, if x.dereference is > > still DEFEF_UNDEFINED and the --links option was specified, initialize > > s/--links/--link/ Fixed, thanks. =C2=A0 > > diff --git a/src/copy.c b/src/copy.c > > index f66ab46..fa4d734 100644 > > --- a/src/copy.c > > +++ b/src/copy.c [...] > > @@ -1748,7 +1757,10 @@ copy_internal (char const *src_name, char const > > *dst_name, > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 /* Note we currently replace DST_NAME > >unconditionally, > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0even if it was a newer separate file.=C2=A0 */ > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 if (! create_hard_link (earlier_file, dst_name, true, > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 x->verbose)) > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 x->verbose, > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 x->dereference =3D=3D > > DEREF_ALWAYS > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 || (x->dereference =3D=3D > > DEREF_COMMAND_LINE_ARGUMENTS > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 && command_line_arg))) > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 { > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto un_backup; > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 } > > @@ -2078,7 +2090,10 @@ copy_internal (char const *src_name, char const > > *dst_name, > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 else > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 { > > -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (! create_hard_link (earlier_fil= e, dst_name, true, > > x->verbose)) > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (! create_hard_link (earlier_fil= e, dst_name, true, x->verbose, > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 x->dereference =3D=3D DERE= F_ALWAYS > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 || (x->dereference =3D=3D > > DEREF_COMMAND_LINE_ARGUMENTS > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 && command_l= ine_arg))) > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 goto un_backup; > > > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return true; > > @@ -2389,7 +2404,10 @@ copy_internal (char const *src_name, char const > > *dst_name, > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&& !(LINK_FOLLOWS_SYMLIN= KS && S_ISLNK (src_mode) > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 && x->der= eference =3D=3D DEREF_NEVER)) > >=C2=A0 =C2=A0 =C2=A0 { > > -=C2=A0 =C2=A0 =C2=A0 if (! create_hard_link (src_name, dst_name, false= , false)) > > +=C2=A0 =C2=A0 =C2=A0 if (! create_hard_link (src_name, dst_name, false= , false, > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 x->dereference =3D=3D DEREF_ALWAYS > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 || (x->dereference =3D=3D > > DEREF_COMMAND_LINE_ARGUMENTS > > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 && command_line_arg))) > > Lots and copy and paste there. > Maybe use a helper like: > > static inline bool _GL_ATTRIBUTE_PURE > should_dereference (const struct cp_options *x, bool cli_arg) > { >=C2=A0 =C2=A0return x->dereference =3D=3D DEREF_ALWAYS >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 || (x->dereference =3D=3D DEREF_COMMAND= _LINE_ARGUMENTS >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 && cli_arg); > } Good idea! =C2=A0 Thanks again for looking into this.=C2=A0 It's really quite complex. I'll come up with the test (old vs. new) cases soon. Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Wed Oct 30 22:07:46 2013 Received: (at 15173) by debbugs.gnu.org; 31 Oct 2013 02:07:46 +0000 Received: from localhost ([127.0.0.1]:53802 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vbhfl-0006KC-D4 for submit@debbugs.gnu.org; Wed, 30 Oct 2013 22:07:46 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:62728) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vbhfi-0006Jv-NJ for 15173@debbugs.gnu.org; Wed, 30 Oct 2013 22:07:44 -0400 Received: from [192.168.1.11] (p5499C6C3.dip0.t-ipconnect.de [84.153.198.195]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0LfHuC-1Vzhkc35Ng-00pIQg; Thu, 31 Oct 2013 03:07:34 +0100 Message-ID: <5271BB65.5030007@bernhard-voelker.de> Date: Thu, 31 Oct 2013 03:07:33 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> In-Reply-To: <737687497.219518.1383135238736.open-xchange@email.1und1.de> Content-Type: multipart/mixed; boundary="------------020706060401080307070908" X-Provags-ID: V02:K0:EgGpqBADPeKrPSNtAjRVEpKEqL1Dk++9/ChdX9/Oacv KqA6/ry3WqC4/ojmV7qSRAw7SrARNI/l6N78UlHX0DeCwhILK4 CdTVA8yAHMvcdbueaSVQj0XC1iu0h4q/gWNpQYj83XmjQVMTkS lzl3nJRlfE7mK8AwknybGFC0aXlEh/H1+6WeVKh/5cAGi7bWHV jcb13yBiQr9Lg/qhxgS/9sxuw/1dj9/lcplMK2eY1391krAZHW GEhPLsYs1p0hx6P47o1GsuER3SoakPtLJu1TlYkG4OOptjxBfV AN9Z623cU//xlkGAHoBXgy8BxJ1y/w72F8JMFSVDDluM7DOLXe 6G69vLX/p71hRXFyKM/0OQbKxnvp+5gu1gICoUJiB X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) This is a multi-part message in MIME format. --------------020706060401080307070908 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 10/30/2013 01:13 PM, Bernhard Voelker wrote: > Thanks again for looking into this. It's really quite complex. > I'll come up with the test (old vs. new) cases soon. Okay, here we go: the attached patch is updated regarding the issues you mentioned. I furthermore tweaked the NEWS entry: * instead of just mentioning the --dereference option, mention both the -L and -H options explicitly. * add a note that "cp -l dangling" and "cp -l symlink-to-dir" now create hard links as expected - cp doesn't try to dereference the src anymore which would lead to different error diagnostics in the two cases [*]. Then, I created a few test cases to check the changes in behaviour of cp-8.21 against the changed cp. It runs various combinations of the options -l, -s, -R, -H, -L, -P and --preserve=links on symlinks to a file ('filelink'), to a directory ('dirlink') and on a dangling symlink ('danglink'). The script is already ugly enough, so I omitted checking the files, dir and links in the subdirectory for changes. The changes so far - 12 out of 144 - are: $ grep "DIFFERENCE in Test: " testit.log | sed 's/^.*: //' cp -L -l filelink ... cp -L -l --preserve=links filelink ... cp -L -l -R filelink ... cp -L -l -R --preserve=links filelink ... cp -H -l filelink ... cp -H -l --preserve=links filelink ... cp -H -l -R filelink ... cp -H -l -R --preserve=links filelink ... cp -l dirlink ... cp -l --preserve=links dirlink ... cp -l danglink ... cp -l --preserve=links danglink ... I think these are all okay. [*] IMO even the 4 latter changes are okay and don't contradict to POSIX: --link is not specified by POSIX. BTW: The failures "can make relative symbolic links only in current directory" for e.g. "cp -L -s -R dirlink" are interesting but a different case, i.e., cp's behavior didn't change. WDYT? Finally, the testsuite is still broken (tests/cp/same-file), and new tests for "cp -l[LH]" are also still missing. Have a nice day, Berny --------------020706060401080307070908 Content-Type: text/x-patch; name="cp--link--deref-v2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cp--link--deref-v2.patch" >From 49d2687d0f961f7df3d8e32995ff054c72fbf1d9 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Thu, 31 Oct 2013 02:24:03 +0100 Subject: [PATCH] cp: fix --link with dereferencing options -L or -H [DRAFT] * 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 pass its return value as the new parameter 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 --link option was specified, initialize x.dereference to DEREF_NEVER. * NEWS (Changes in behavior): Mention the change. This fixes http://bugs.gnu.org/15173 --- NEWS | 7 +++++++ src/copy.c | 47 ++++++++++++++++++++++++++++++++++------------- src/cp.c | 2 +- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/NEWS b/NEWS index 39dd3d6..cbd837d 100644 --- a/NEWS +++ b/NEWS @@ -70,6 +70,13 @@ GNU coreutils NEWS -*- outline -*- ** Changes in behavior + cp --link together with -H or -L now dereferences a symbolic link as source + before creating the hard link in the destination. Previously, it would create + a hard link of the symbolic link. + Similarly, cp --link for a dangling symbolic link or for a symbolic link to a + directory is now hard linked correctly. Previously, cp would fail with an + error diagnostic. + dd status=none now suppresses all non fatal diagnostic messages, not just the transfer counts. diff --git a/src/copy.c b/src/copy.c index f66ab46..e19fb34 100644 --- a/src/copy.c +++ b/src/copy.c @@ -1558,18 +1558,24 @@ restore_default_fscreatecon_or_die (void) _("failed to restore the default file creation context")); } -/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE and - VERBOSE settings. Return true upon success. Otherwise, diagnose - the failure and return false. - If SRC_NAME is a symbolic link it will not be followed. If the system - doesn't support hard links to symbolic links, then DST_NAME will - be created as a symbolic link to SRC_NAME. */ +/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE, + VERBOSE and DEREFERENCE settings. Return true upon success. + Otherwise, diagnose the failure and return false. + If SRC_NAME is a symbolic link it will not be followed unless DEREFERENCE + is true. If the system doesn't support hard links to symbolic links, + then DST_NAME will be created as a symbolic link to SRC_NAME. */ static bool create_hard_link (char const *src_name, char const *dst_name, - bool replace, bool verbose) + bool replace, bool verbose, bool dereference) { - /* We want to guarantee that symlinks are not followed. */ - bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); + int flags; + if (dereference) + flags = AT_SYMLINK_FOLLOW; + else + flags = 0; /* We want to guarantee that symlinks are not followed. */ + + bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) + != 0); /* If the link failed because of an existing destination, remove that file and then call link again. */ @@ -1582,7 +1588,8 @@ create_hard_link (char const *src_name, char const *dst_name, } if (verbose) printf (_("removed %s\n"), quote (dst_name)); - link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); + link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) + != 0); } if (link_failed) @@ -1595,6 +1602,17 @@ create_hard_link (char const *src_name, char const *dst_name, return true; } +/* Return true if the current file should be (tried to be) dereferenced: + either for DEREF_ALWAYS or for DEREF_COMMAND_LINE_ARGUMENTS in the case + where the current file is a CLI_ARG; otherwise return false. */ +static inline bool _GL_ATTRIBUTE_PURE +should_dereference (const struct cp_options *x, bool cli_arg) +{ + return x->dereference == DEREF_ALWAYS + || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS + && cli_arg); +} + /* Copy the file SRC_NAME to the file DST_NAME. The files may be of any type. NEW_DST should be true if the file DST_NAME cannot exist because its parent directory was just created; NEW_DST should @@ -1747,8 +1765,9 @@ copy_internal (char const *src_name, char const *dst_name, { /* Note we currently replace DST_NAME unconditionally, even if it was a newer separate file. */ + bool deref = should_dereference (x, command_line_arg); if (! create_hard_link (earlier_file, dst_name, true, - x->verbose)) + x->verbose, deref)) { goto un_backup; } @@ -2078,7 +2097,8 @@ copy_internal (char const *src_name, char const *dst_name, } else { - if (! create_hard_link (earlier_file, dst_name, true, x->verbose)) + if (! create_hard_link (earlier_file, dst_name, true, x->verbose, + should_dereference (x, command_line_arg))) goto un_backup; return true; @@ -2389,7 +2409,8 @@ copy_internal (char const *src_name, char const *dst_name, && !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode) && x->dereference == DEREF_NEVER)) { - if (! create_hard_link (src_name, dst_name, false, false)) + if (! create_hard_link (src_name, dst_name, false, false, + should_dereference (x, command_line_arg))) goto un_backup; } else if (S_ISREG (src_mode) diff --git a/src/cp.c b/src/cp.c index 7bc8630..6efb152 100644 --- a/src/cp.c +++ b/src/cp.c @@ -1135,7 +1135,7 @@ main (int argc, char **argv) if (x.dereference == DEREF_UNDEFINED) { - if (x.recursive) + if (x.recursive || x.hard_link) /* This is compatible with FreeBSD. */ x.dereference = DEREF_NEVER; else -- 1.8.3.1 --------------020706060401080307070908 Content-Type: application/x-xz; name="testit.log.xz" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="testit.log.xz" /Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj4R5rCfddACgciKczaUHouSdYKENK1feCL6hq2rdu MZ3l9HVnmKVOFssYrx1j5TPzdxLupIREYS+GNcNIzWlSnNnzL2y7K95GpfVVkHY9TZYU2kR1 8vfFOYTUlIoB8zg4EIo5/sF44X/ArNJiiKVh1pCCTuYteRIFKZfCSuoxfAaPC2Dvev3SiwF/ h3odbANpMI4PNyFsxwKvIG6EbDLY3r3NJc/qJV8n5bmmJHk6lbMRw/d19myqRpedo7ufKzdq 6ffpDrbLAb9V7NPvu6PChlYJpzIAtAzB2JzHMOTF0Oi+iug1l07JtiZ/dUgzG7S+bVxz5X8M rK4eGxcHSZ2MYSVHIfDmkG1dNoGdSyvEbtqkImA1VTXb1iKe80915mhDGKyXNTq8ceMlnh5I wfh6GmPLAVK65PTo/HCTwl++WHYCIRIe4lxG2xhuTANNTRQFzSUCv9+W10tF3+1EVMh5VDuZ iXK38PnsajCD9JG43+dZaQj9lCARqAUdHdoEKuY92BbEp+CuN6opxLgvP/P2pIcvxE0LOhXl 9T5LiWQL4QxDv8ISjHTJuFBGHgm3ruy48oFxR+UtcVB3K5nzFyK5M+XbYuqAd+ypxSFIquS+ RlaP14dVWxjtodYXbulHaKf0e99zNLLeeP0Q/hWiFWDQpTdLH9zwZRqk2S82fVqIwj6U9oEK fQBu9ziRaBOgUYQ13EyOv3890a3WO0VhYHIRQwKfsBKSBJ/xpUKoAKrUJbgaX44NOloCxi4z VkApN7uJua7RiWkL9+uQJv6G+RafyV7n+FAPxNHFMTplKjBB/NkUJJTGePi4h5MXHLdzoDTz eafczpmcZvD7wttaUcqnAqED9tiOAZz/DKM1eTUcfJa5Z+F5UhKzohzI4Y3DX6Qjss6Lkje3 Yw8E39CEvDAs3INlwbWJZRC1uGPvHmYCLtbIhx7bTemt7VwPoG3Y6nMqSIzvWi4Dtm2N28SV zXz6cOej7J4hf85GrrJS10kyM/EWV5zsTElFJO5IH1Aq6On3ult3GzNQwTCwcIZ80tuJ7akc IvUeYrqy5jyDV8pXLpsGHbWAX7RZdd8ebSFHDrq8dyeeLIqFF4y3eprUD/KnD6/mP4NYX8Ep ZpIKyUKc6uZV2nj7p34/qzYrWf5FmMl5gn+emYB4/wCLuQwTQudZzatrQtvZeMLCixkVvKrN KWjBdLeWmOVzR50Fi2DCCzWgBLwAQnvLYcq97NFOIX+/9Lz0WjyQ6dIZJHnLDg6J7Jdz+zPr Lni/fZHnWUxr+llk2thefKQr7cYsQrXrJ3eV61u4EEScB7GOhZ20xdbqIco9YrJ9mshxfbcv zGTTbS/5r7O1KdNuwCA6XpbRXeYpbyf3mQBa2cQ3O2ydWDsIY20OYsmillUt6d18DfsjIpcK aIrCbyOgoUnoWxmalJULQ3EAcyzqs5WP4IoIhwh5lsdyuvVD5JavYEsGMKa81rOf4tVcQuaZ UQHVufq4ZYgdKXLHXTR0r6Cpp7oB2wjV+aJPg4kb5Y8s+ZRvDzZfqSTc8OawifZ97vWUnTI5 ERmq9cKH2cNf62plLFmGqlcpBbZvZp/juKFYRMyslt+Uplzk+VtjZ9e+XQJu9c4XnDpnxhlm vWyGNxoHRF3J9Bm30WLP1teTj71FWqGP+LHyJSgBrIo2EAtr0N0qgSehAXbN/uzffsjqbT4k e+TEpeX7mlQKWMhPCUMTTQxOewDx2QsRyLF/0Tg4e47WejsNKG0YQ5yEuXrfKOtX1raN6tc+ e1H/6LO3/SCxI0EjkoVHyVZw3jTDPxfzMrTSYQ8DN70wEkFpjXGoA6hPnJ9B69DdGJJnllCa KZRd0OP92iYcLmgDDiHCtzjfRGMjz5QhaU6BmPYX26O4j3rP1nhegyEHXisbmU/KLmRW9UI1 VCkQpDMFFzqZg1pijzwmucYs+xuy3P4Ll7Q8QyFEI6Oeov0pIAJ6ScEnJIBHDETjTfpCpbXR Cl/YU0d8iykPHp4pE/xhQswGUHFXVa82GEYDIaS72QKF/eDG8f3Zudw3zRB8XaWET23LZ7zh lct1T2mBQn/FA5lE9Xj6xLHEgt8Udit4QnHxf6aPkzt1kKxRvmRFD4v/LaYJBmQk/G+33DeU JGJrbwOm6NDcgAXkx2dipdmTWgE5lgirz4hntTr2gq5Ig9CV4QsPVUxw4vRXFdiGtOpWz3ze DKa7CDWJYww0ViFGo6XFwvv0BMf+ArvOEKZScp27+GTGx1mn0igSWBXTducxuo2ZrcLaU2ZQ AJAUH5+ME3FXh0+VUQPm/AlLC1oqvILVACfZ/ZJwAXth9epgvfFevj+JdF74hWcA4VC/uGB2 SA+G5aDsagLfwRmv2n8m4HRMQ16NzDNEt1wZN1qO4rE/irNle3TBQa1q9qsTbtfD7p6UgZrO Mo3RTkGNOpDJe6bnXT+Qq64TqHtw0VYq3cOsnL9qhnv8j0ZGe9hlo5nAZfu1GN6oPxpphK9m EsOhkd15OwNk1lTjbzOKIYZ7Z2AtFv5vPvON+LTbjq0zBJ0RMbD5puR32oJIbLs5zUFNtgLy BXktI2lCvLRbknhJVX9fg1NlcMLuCukFoNRZDTe6exZa3gKVrtlnrqpQkUgJgPiYc1va2BVS /9SRC2IaLeRhoQ2Yft6BrJzN5tmPWEj3+Szd7B/S1v0lTWnTeHdNEliot/CBmVbAD2o/PMCi V+k4y7TOG6hiy1LuS5PZXiX70Bqpk4Xr3GUs/DmIoT5PcqZPWSPH4kCWR6gZXsSQ+72OYoED NCqj6LrYUKRBOzd62mADM8DaPBhXX1Q7/6Tn4SLv8K163tRCKXeZN+6pYvNirMAxGqvWdSqH OlDNcAwwMRigwvpQw0JPsENmnAjDhxqgiRJINDjqXknGG2LCEMXWKHcChEzts4LU38EKjkuU TGPgAEDy+Vc+1eENfOSvgjTkdDsNsCnWoN9TnifSneQ2t+U8jBMONZvgyDy90VjRTDRWmFc0 EFkgM9zel9h2RLm6D1IiMVN0snpM1E6xc+/vpJ+lb2rmhkl3KZDEf2tB6wSoT3OOPedUE5VB YMFdXKxur6Q/B/LoL7cDhJf5kJEvznOClGwymKDid/Dnh60ZAWJbJgBfFm09rqeVUrnPWwiy ome5rLtIOSpssXfp/YK66gQs5sdPK38FFCZ+3DEXB6liKub8jucuN98rtGxqoC8+fuOwykJt 44vQ0gkaFF8ja2/7ydcisraBn0WdRkzI3hQ2SeHT8rRNSjVClc9TAcI3JaEAhfblW/sWTg1H aw/OAwQ32QDwCWhOdRI/pJb7+RbureTrloPBLijIfea/oF8lVZ4QvmdW4mTlo8S7xMcuVOG9 4CP62VtObcXt8rSLCUA2M3D08vgafYGTBVI0fACxjM9lhHEoOk7d7NUtZ4AAAPwwGM5IAJV2 AAGTFOy8BACCvUb5scRn+wIAAAAABFla --------------020706060401080307070908 Content-Type: application/x-shellscript; name="testit.sh" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="testit.sh" IyEvYmluL3NoCgpDUE9MRD0iLi9jcC04LjIxIgpDUE5FVz0iLi9jcC1uZXcgIgoKewogIGVj aG8gIlByZXBhcmUgdGVzdHMgLi4uIgogIHNldCAteAogIG1rZGlyIGQgZC9kMgogIHRvdWNo IGYKICB0b3VjaCBkL2YyCiAgdG91Y2ggZC9kMi9mMwoKICBsbiAtcyBkIGRpcmxpbmsKICBs biAtcyBmIGZpbGVsaW5rCiAgbG4gLXMgbm93aGVyZSBkYW5nbGluawogIGxuIC1zIGYyIGQv ZmwKICBsbiAtcyBkMiBkL2RsCiAgZmluZCBmKiBkKiAtZXhlYyBscyAtbGRvZ2kgJ3t9JyAr CiAgc2V0ICt4CgogIGVjaG8gIlN0YXJ0aW5nIHRlc3RzIC4uLiIKICAKICBmb3Igc3JjIGlu IGZpbGVsaW5rIGRpcmxpbmsgZGFuZ2xpbmsgOyBkbwogICAgIyB0YXJnZXQKICAgIHRndD0k KHJlYWRsaW5rICRzcmMpCiAgICAjIHNyYyBhbmQgdGd0IGlub2RlcwogICAgaW5vX3NyYz0i JChzdGF0IC1jICclaScgJHNyYyAyPi9kZXYvbnVsbCkiCiAgICBpbm9fdGd0PSIkKHN0YXQg LWMgJyVpJyAkdGd0IDI+L2Rldi9udWxsKSIKICAgICMgc3JjIGFuZCB0Z3QgZmlsZSB0eXBl CiAgICB0eXBfc3JjPSIkKHN0YXQgLWMgJyVGJyAkc3JjIDI+L2Rldi9udWxsKSIKICAgIHR5 cF90Z3Q9IiQoc3RhdCAtYyAnJUYnICR0Z3QgMj4vZGV2L251bGwpIgogICAgCiAgICBmb3Ig ZGVyZWYgaW4gJycgLVAgLUwgLUggOyBkbwogICAgICBmb3IgbCBpbiAnJyAtbCAtcyA7IGRv CiAgICAgICAgZm9yIHIgaW4gJycgLVIgOyBkbwogICAgICAgICAgZm9yIHAgaW4gJycgLS1w cmVzZXJ2ZT1saW5rcyA7IGRvCiAgICAgICAgICBlY2hvCiAgICAgICAgICBlY2hvICI9PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09IgogICAgICAgICAgZWNobyAi VGVzdDogY3AgJGRlcmVmICRsICRyICRwICRzcmMgLi4uIgogICAgICAgICAgc2V0IC14CiAg ICAgICAgICAkQ1BPTEQgJGRlcmVmICRsICRyICRwICRzcmMgT0xEOyByY19vbGQ9JD8KICAg ICAgICAgICRDUE5FVyAkZGVyZWYgJGwgJHIgJHAgJHNyYyBORVc7IHJjX25ldz0kPwogICAg ICAgICAgc2V0ICt4CgogICAgICAgICAgIyBEb2VzIHRoZSBkZXN0aW5hdGlvbiBleGlzdD8K ICAgICAgICAgIFsgLWUgT0xEIF07IGV4aXN0X29sZD0kPwogICAgICAgICAgWyAtZSBORVcg XTsgZXhpc3RfbmV3PSQ/CgogICAgICAgICAgIyBJcyB0aGUgaW5vZGUgbnVtYmVyIGlkZW50 aWNhbCB0byBzcmMgYW5kL29yIHRndD8KICAgICAgICAgIGlub19vbGQ9IiQoc3RhdCAtYyAn JWknIE9MRCAyPi9kZXYvbnVsbCkiCiAgICAgICAgICBpbm9fbmV3PSIkKHN0YXQgLWMgJyVp JyBORVcgMj4vZGV2L251bGwpIgogICAgICAgICAgWyAiJGlub19vbGQiID0gIiRpbm9fc3Jj IiBdOyBpbm9fb2xkX3NyYz0kPwogICAgICAgICAgWyAiJGlub19vbGQiID0gIiRpbm9fdGd0 IiBdOyBpbm9fb2xkX3RndD0kPwogICAgICAgICAgWyAiJGlub19uZXciID0gIiRpbm9fc3Jj IiBdOyBpbm9fbmV3X3NyYz0kPwogICAgICAgICAgWyAiJGlub19uZXciID0gIiRpbm9fdGd0 IiBdOyBpbm9fbmV3X3RndD0kPwoKICAgICAgICAgICMgV2hhdCdzIHRoZSBmaWxlIHR5cGU/ ICAgICAgICAgIAogICAgICAgICAgdHlwX29sZD0iJChzdGF0IC1jICclRicgT0xEIDI+L2Rl di9udWxsKSIKICAgICAgICAgIHR5cF9uZXc9IiQoc3RhdCAtYyAnJUYnIE5FVyAyPi9kZXYv bnVsbCkiCiAgICAgICAgICBbICIkdHlwX29sZCIgPSAiJHR5cF9zcmMiIF07IHR5cF9vbGRf c3JjPSQ/CiAgICAgICAgICBbICIkdHlwX29sZCIgPSAiJHR5cF90Z3QiIF07IHR5cF9vbGRf dGd0PSQ/CiAgICAgICAgICBbICIkdHlwX25ldyIgPSAiJHR5cF9zcmMiIF07IHR5cF9uZXdf c3JjPSQ/CiAgICAgICAgICBbICIkdHlwX25ldyIgPSAiJHR5cF90Z3QiIF07IHR5cF9uZXdf dGd0PSQ/CgogICAgICAgICAgZmluZCAkc3JjICR0Z3QgT0xEIE5FVyBcCiAgICAgICAgICAg IC1leGVjIGxzIC1sZG9naSAne30nICsgMj4vZGV2L251bGwgXAogICAgICAgICAgICB8IHNv cnQgLWsxbgoKICAgICAgICAgIGlmIFsgIiRleGlzdF9vbGQuJGlub19vbGRfc3JjLiRpbm9f b2xkX3RndC4kdHlwX29sZF9zcmMuJHR5cF9vbGRfdGd0JHJjX29sZCIgXAogICAgICAgICAg ICAgPSAiJGV4aXN0X25ldy4kaW5vX25ld19zcmMuJGlub19uZXdfdGd0LiR0eXBfbmV3X3Ny Yy4kdHlwX25ld190Z3QkcmNfbmV3IiBdCiAgICAgICAgICB0aGVuCiAgICAgICAgICAgIGVj aG8gIj09PSBPSyIKICAgICAgICAgIGVsc2UKICAgICAgICAgICAgZWNobyAiPT09IERJRkZF UkVOQ0UgaW4gVGVzdDogY3AgJGRlcmVmICRsICRyICRwICRzcmMgLi4uIgogICAgICAgICAg ZmkKICAgICAgICAgIAogICAgICAgICAgcm0gLXJmIE9MRCBORVcKICAgICAgICAgIGVjaG8K ICAgICAgICAgIGRvbmUKICAgICAgICBkb25lCiAgICAgIGRvbmUKICAgIGRvbmUKICBkb25l CgogIGVjaG8KICBlY2hvICI9PT0gQ2xlYW51cCIKICBybSAtcmYgZCBmIGZpbGVsaW5rIGRp cmxpbmsgZGFuZ2xpbmsKfSAyPiYxCg== --------------020706060401080307070908-- From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 31 08:13:06 2013 Received: (at 15173) by debbugs.gnu.org; 31 Oct 2013 12:13:06 +0000 Received: from localhost ([127.0.0.1]:54346 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vbr7Z-0006c4-Pr for submit@debbugs.gnu.org; Thu, 31 Oct 2013 08:13:06 -0400 Received: from mail5.vodafone.ie ([213.233.128.176]:55667) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vbr7W-0006bW-Sd for 15173@debbugs.gnu.org; Thu, 31 Oct 2013 08:13:03 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBADFIclJda9XW/2dsb2JhbAANTIcmuVuCfIE6gxkBAQEDASMPAUYFCwsNAQoCAgUWCwICCQMCAQIBRQYNAQcBARaHZwuoMHaSYoEpjiYHgmuBQwOeb45L Received: from unknown (HELO [192.168.1.79]) ([93.107.213.214]) by mail3.vodafone.ie with ESMTP; 31 Oct 2013 12:12:56 +0000 Message-ID: <52724947.6090200@draigBrady.com> Date: Thu, 31 Oct 2013 12:12:55 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> In-Reply-To: <5271BB65.5030007@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , Eric Blake , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 10/31/2013 02:07 AM, Bernhard Voelker wrote: > On 10/30/2013 01:13 PM, Bernhard Voelker wrote: >> Thanks again for looking into this. It's really quite complex. >> I'll come up with the test (old vs. new) cases soon. > > Okay, here we go: > > the attached patch is updated regarding the issues you mentioned. > > I furthermore tweaked the NEWS entry: > > * instead of just mentioning the --dereference option, > mention both the -L and -H options explicitly. > > * add a note that "cp -l dangling" and "cp -l symlink-to-dir" > now create hard links as expected - cp doesn't try to dereference > the src anymore which would lead to different error diagnostics > in the two cases [*]. > > Then, I created a few test cases to check the changes in behaviour > of cp-8.21 against the changed cp. It runs various combinations of > the options -l, -s, -R, -H, -L, -P and --preserve=links on symlinks > to a file ('filelink'), to a directory ('dirlink') and on a dangling > symlink ('danglink'). > The script is already ugly enough, so I omitted checking the > files, dir and links in the subdirectory for changes. > The changes so far - 12 out of 144 - are: > > $ grep "DIFFERENCE in Test: " testit.log | sed 's/^.*: //' > cp -L -l filelink ... > cp -L -l --preserve=links filelink ... > cp -L -l -R filelink ... > cp -L -l -R --preserve=links filelink ... > cp -H -l filelink ... > cp -H -l --preserve=links filelink ... > cp -H -l -R filelink ... > cp -H -l -R --preserve=links filelink ... So -HL are now honored in this regard > cp -l dirlink ... > cp -l --preserve=links dirlink ... > cp -l danglink ... > cp -l --preserve=links danglink ... and by default we don't deref the above. That all seems consistent with expectations and what we previously discussed. But... I've just now read POSIX for cp, and it states: "If the -R option was not specified, cp shall take actions based on the type and contents of the file referenced by the symbolic link, and not by the symbolic link itself, unless the -P option was specified." This suggests that -HL should only be significant with -R ? That is a bit surprising TBH. What do you think Eric? It also suggests that we should hardlink to a symlink only with -P, i.e. that we should AT_SYMLINK_FOLLOW unless -P is specified ? That's also a bit surprising, given that POSIX for ln states that it's implementation defined what's done if neither -P or -L is specified. I wouldn't be inclined to follow POSIX in that regard. Also worth comparing is --symbolic-link, which seems closer to POSIX in this regard. --symbolic-link does need -P to be able to reference dangling links even though the target of the created symlink is the source symlink rather than its target. Should we remove the -P requirement to symlink dangling links as is the case for --link above. thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 31 09:17:41 2013 Received: (at 15173) by debbugs.gnu.org; 31 Oct 2013 13:17:41 +0000 Received: from localhost ([127.0.0.1]:54399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vbs83-00089x-Do for submit@debbugs.gnu.org; Thu, 31 Oct 2013 09:17:40 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:65086) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vbs81-00089g-7u for 15173@debbugs.gnu.org; Thu, 31 Oct 2013 09:17:38 -0400 Received: from oxbaltgw06.schlund.de (oxbaltgw06.schlund.de [172.19.246.12]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0Mb2zL-1VM7jD20p1-00KD52; Thu, 31 Oct 2013 14:17:24 +0100 Date: Thu, 31 Oct 2013 14:17:24 +0100 (CET) From: Bernhard Voelker To: =?UTF-8?Q?P=C3=A1draig_Brady?= Message-ID: <273932314.24270.1383225444529.open-xchange@email.1und1.de> In-Reply-To: <52724947.6090200@draigBrady.com> References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> Subject: Re: bug#15173: [cp] --link overrides dereference settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.2.2-Rev26 X-Provags-ID: V02:K0:+G6WWtAd533OaP9vHcEtZFPLkHXwoqBwrtDH3kHFEZ0 JFAq6XOZ9auzNHw9zk1HRkInZ0U4VBWp443bg2a/DZqTE2WFwz QyPQ2Q5dUSfNZyZ2X3q0eicFngUcyifcZsoKYjjio02AEXD4NC 6Y6t5nNDE6klCC1HwSIS0vjcDrhvxqhm5H9y+w3bDwDANs7YZi k9mV51jh6rhzFFm/xl8BWC8Q/x6tZMFz9mGvrc3IIfd4iC5WfB +wJWzo6nSxJ0HmPOXcrA4QQtkcQa5UIsWnlcYC1ggAbBDJpqSV PrrdISEGhe7zdh7pDUgwa2TunVgRar25kDVFzz3Yza41HBkgJW +Pm3eGzglGLMY7GZfG9bKcxjcQ41oz/aFVLjPKNObxqF0TsnWf YG6Q1eWrW9gqScdm+RPMAS1U7a9AXfv3nY= X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , Eric Blake , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Bernhard Voelker List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) > On October 31, 2013 at 1:12 PM P=C3=A1draig Brady wrot= e: > That all seems consistent with expectations and what we previously discus= sed. > > But... > > I've just now read POSIX for cp, and it states: > >=C2=A0 "If the -R option was not specified, cp shall take actions based on= the type >=C2=A0 =C2=A0and contents of the file referenced by the symbolic link, and= not by the >=C2=A0 =C2=A0symbolic link itself, unless the -P option was specified." > > This suggests that -HL should only be significant with -R ? > That is a bit surprising TBH. What do you think Eric? > > It also suggests that we should hardlink to a symlink only with -P, > i.e. that we should AT_SYMLINK_FOLLOW unless -P is specified ? > That's also a bit surprising, given that POSIX for ln states > that it's implementation defined what's done if neither -P or -L is speci= fied. > I wouldn't be inclined to follow POSIX in that regard. I don't read the POSIX spec that way: there are 2 things to consider: a) POSIX doesn't say a word about hard links, and b) the -l,--link option is a GNU extension to conveniently =C2=A0 =C2=A0copy files or trees by creating hard links (only). I.e. if someone uses -l, then the POSIX semantics does not apply anymore because we do not copy anymore.=C2=A0 Whether the ln(1) specification does apply more here is another question. Therefore, I think GNU cp(1) should do what makes most sense for the user - depending on -LPH or none being used.=C2=A0 With the proposed patch, I think we're getting a bit closer to that. Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 31 09:55:53 2013 Received: (at 15173) by debbugs.gnu.org; 31 Oct 2013 13:55:53 +0000 Received: from localhost ([127.0.0.1]:54539 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vbsiy-0000bU-3x for submit@debbugs.gnu.org; Thu, 31 Oct 2013 09:55:51 -0400 Received: from ramona.rm-rf.it ([149.154.157.136]:35125) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vbsip-0000an-RJ for 15173@debbugs.gnu.org; Thu, 31 Oct 2013 09:55:41 -0400 Received: from valentina.fdc.rm-rf.it (valentina.fdc.rm-rf.it [192.168.192.1]) by ramona.rm-rf.it (Postfix) with ESMTP id EDAD81B0 for <15173@debbugs.gnu.org>; Thu, 31 Oct 2013 14:55:31 +0100 (CET) Received: from caimano.fdc.rm-rf.it (caimano.fdc.rm-rf.it [192.168.192.17]) by valentina.fdc.rm-rf.it (Postfix) with ESMTP id 7EAAD20E32 for <15173@debbugs.gnu.org>; Thu, 31 Oct 2013 14:55:00 +0100 (CET) Received: from gpiero (uid 1000) (envelope-from gpiero@rm-rf.it) id 3c00d by caimano.fdc.rm-rf.it (DragonFly Mail Agent v0.9); Thu, 31 Oct 2013 14:54:59 +0100 Date: Thu, 31 Oct 2013 14:54:59 +0100 From: Gian Piero Carrubba To: =?utf-8?Q?P=C3=A1draig?= Brady Subject: Re: bug#15173: [cp] --link overrides dereference settings Message-ID: <20131031135459.GB30875@caimano.fdc.rm-rf.it> References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="6c2NcOVqGQ03X4Wi" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <52724947.6090200@draigBrady.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 15173 Cc: Bernhard Voelker , Eric Blake , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) --6c2NcOVqGQ03X4Wi Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit * [Thu, Oct 31, 2013 at 12:12:55PM +0000] Pádraig Brady: >> On 10/30/2013 01:13 PM, Bernhard Voelker wrote: >> The changes so far - 12 out of 144 - are: >> >> $ grep "DIFFERENCE in Test: " testit.log | sed 's/^.*: //' >> cp -L -l filelink ... >> cp -L -l --preserve=links filelink ... >> cp -L -l -R filelink ... >> cp -L -l -R --preserve=links filelink ... >> cp -H -l filelink ... >> cp -H -l --preserve=links filelink ... >> cp -H -l -R filelink ... >> cp -H -l -R --preserve=links filelink ... > >So -HL are now honored in this regard > >> cp -l dirlink ... >> cp -l --preserve=links dirlink ... >> cp -l danglink ... >> cp -l --preserve=links danglink ... > >and by default we don't deref the above. > >That all seems consistent with expectations and what we previously >discussed. Not what I would expect, and imho not SUSv3 compliant, either with regard to --preserve=links and -R. More about this later. >I've just now read POSIX for cp, and it states: > > "If the -R option was not specified, cp shall take actions based on the type > and contents of the file referenced by the symbolic link, and not by the > symbolic link itself, unless the -P option was specified." > >This suggests that -HL should only be significant with -R ? >That is a bit surprising TBH. What do you think Eric? Oh well, didn't read it like this. My opinion was, and still is even if not strong as before, that explicitly using -H/L/preserve=links would override that _default_ behaviour. >I wouldn't be inclined to follow POSIX in that regard. Oh... I was tweaking a bit the last patch posted by Bernhard in order to let it be POSIX compliant (but now I have to add: "for my interpretation of POSIX"), but didn't had the time to complete before going to work. Will probably finish it up anyway this evening or tomorrow, at this point at least for comparing how far we're currently are from "POSIX". In the meantime please see attached the results for the tests from Bernhard. There are a lot more differences in behaviour: $ fgrep -c "DIFFERENCE in Test: " testit.log 40 but I suspect (I hadn't the time for double checking them) they are all correct. My points in short: - POSIX (my interpretation): without '-r' the link should be dereferenced, *unless* told otherwise - POSIX (I think, cannot check now): order of options is important. In case of conflicting options, the LAST one should be used - --(no)-preserve=links To be honest, it isn't clear to me what it stands for. I have assumed --preserve=links should set DEREF_NEVER and --no-preserve=links should set DEREF_ALWAYS. Anyway I don't particularly like the implementation, as now dereferencing settings are both in x->preserve_links and in x->dereference, some times even with opposite values. And some times a function checks for x->preserve_links and not for x->dereference, or vice versa. If it has a different meaning from what I've supposed, I can't understand how it should behave. Frankly, dereferencing in cp seems a bit more complicated as I first supposed. Ciao, Gian Piero. --6c2NcOVqGQ03X4Wi Content-Type: application/octet-stream Content-Disposition: attachment; filename="testit.log.gz" Content-Transfer-Encoding: base64 H4sICL8VclICA3Rlc3RpdC5sb2cA7V3dbts4Fr7PU/C+cBJLcZIW6NzMdHAGI7QGd4G9XGRt uTXK2oHpTlssFpjH2H29eZKVbMuxLR7pUBQlWT5FLhqHlOXvfDw/n47J8Sp+flrFYh3rtRbX 19dXr8SXz9P5SkzF9GYaJL+ul18nn8Rs/7/pzSw4+GUa3MzC5He1EAOdzpqv1Hzxef/KTMzm Kj56abH89ilO3nT6tPh4PDZIr65erpb+Pk1/n80X04NLpe+zm5y9oRjE3+OJUFoM1HT5cS7+ /R/x6mr08DAaDR/EdPXt+2qQ/ohQ3N2+vhcfJmsRDsXt6zdh8i67gY+HAwPTwBSTzdjgVgxW 3warQfojhiL5d5sfm2KzHR4IlV5687MdHuSGKzH4SWRvMHxd/gaz7GaG5Vefba6ezrh/DMLX d7kZDyczMoCTWTuL7abmP8rwZGpmkp9SZDdzhmUfZrYbGJZdfM+B9NMk1NDxWrz6fvW39dNq PV98PKDy1Vviv6u/J3PeiMlz+nYvb7BdDsmr+1c+RL8kr6wm/1yq6dvb5L/XN9fXN3o1uTkc 9f7dP7ajFvG3zajdLRqRoMFQiMF2xqjwuumdb8fdF45L7z1BRHz4/aoifoPB8yrW8eqP+G16 i9qAJz6kEGB8WtcRL7pycu/bi6aw//Lbr7++k+/e//xOzBeCDms1Ww2kie3Jq0R7yPYtUDQj ufnDwRZmqMz+BBIK/2XlJSA7uAq6ZYOBMvrw5GUixKoSooHJk1LGGZEPSnAsHnxspiK/kger MuYU3qvKvFdN8j5EiUkZXGSqsNxUDrxH/LmycOnKr1c/Y2SJ/JYuFJfM8jJbaLN3J6PctXj5 aIY1q5mNYfPRbLdsjiu+FKbryjTXXc9gumcRxK9rC7+uu5etdxJnIvelC/0lrwAbywzGZlUm eZ2I+ZhrpDyiFKaPK9N8zHVquQ0Qvz628OtjVmEQZIn8li4UZzWm3BaYHjO2kGTGVVWZ/lZC O2SJLFcuLGfthWQL3JsrO4fOGgyOMJ3v0pHyrMUQbKJR326DNtc/BJyJzNcutGdtpoJlcL+v 7fw+azRUvOlrQTouB9Zq7CwUIVpNRIU94j6aDEcKy6PK/I4uuJ+GAG9VqyHRILIIBVEn4kBH VgHR20curj7qpp9vcjWUwlzRfpj6E1moP9FF9eQYQXNAn7h6lMvqYYWIZAs8Nii78FBZITrj FZEDz8kO9FUhHRcG60gEm2g0StigzbUZAWci87UL7VlHqmAZPDpou+jAOhIVb/pakI7LgXUk OwsBoiMBFXbgCjrDkcJyqMxvuOTKGfzoSIDqSGARCoB1pCM8ietAuiwFeeGrwY+OBKiOBBY6 ElyWjgR16UhA1pHARUcC1pGItsBjg7ILDxemI0F9OhJY6EjgqCMB60hUm2g0Stig3enaLKxQ m4U112ZUHQlcdCQ4Nx2pI5bBo4O2iw5d15G6gzd9LUjH5SB5Rdju55PtRrQ3RfZCivfk+Y1Y fpmvN1sHJX+IJ+vl6of468//7kb99ef/XowyPDFKdqUU+YPXqZdM7TQ8tZPl7kreNriy2n/K cjMsq+2qrLfPqnn/ohx/0BHuhEIvXby2q+zINSqes1+GzDGMYxabNR1yqPpeTXkmyiPuFW0b 1CKRdjFganb+TLzmnJspfTCRqtDDWW1OxbRj2m1kyDzNVJ1xU3Eu1kveENyV8pqQqVp8WmDg zou/oY1nrjnkZKVcctlzzchJamqmKmZnoSWlTONPQmTpeKagX3dHy8+UQ4qm6srSmH59o582 Zmm1BlPNWVoveUNwWtprlqbbrTwfzJXk7igEZpxlrqa95GoaydU0PVfTTStpD2ZJIyMWImww HRt2gLS8TTvkbbp1dY2p2HkqbnfKzBNvTCTZmOVaJpF5c1ATqSq6sjE/JWDaofuhGokm6dTi J51MJnQLWIRc1R0ZP/Fk+uG73hrppujsUizMMpmwjX4RclX3ZYqfCzD9CvY2xggnrSjGzzqZ VAVbLOMkc3Js/MyTaYjvYG0knQXBWIhlYpG27EaIVt21aX4mwFQk7lGOkU9a0Y2ffzLBiJuy 44Rzcnj8HJQpSdmFPk+/qM6Wo4h72XrJG4Ibi7z2skX8LdAedLGVc8nlhAEjJ6mJXOQti2OK 5CiynREeftS73EcNt/uwbYbeFaOyGbrHJRgVf9Zs9MunvadMyD5p8lEoo9VudEi69Wz0HenW 1f7Ww1EZiJtNqNKho9uyO0mG7kEcDcvuZDt6fyejgDIhA3EUkkbvYBndkW49Gz0i3foGRA8H cSBuqGJ6H3XteTrHvo44toDg2GgTFOIJgxJPSByt9n6T5gkrnMpSQwqBNCdENX8nO+KvZfez SCL2I0S+v5sd8deze1MsefmC9svJMRg7LWomde5l052BAIeJKnG0oo4+jJ/lozHajpD7OCQu bYKymHCaXdAm2LxDwdILDAtpm14cLb7SOd3O7yxqxST7opZ+5anXYelXXrLuqq06zv4ih0yX Cqq2ZpezjYmBlSsKLFxRaOsoQltHEbKjqOooKAfIeUkwNFZM1Z3r8u4JvSymNLWY0r6LKd5F oV8llRa+PB5aUuX6iVJWJhTch8mEhMl1nhbiy9PnWKxi9bSe/xEL/ePLv5ZqPhHbu1wu1I/0 40y+rlbxYv1C58PrzYI6L6ZqvNgmvrter2ypSjwcJLexL5Fcb8N0YXfkjVdVPq5any04fJ7n g4RLKjQ1vdAs78Rj3+3Pd3OmxU6q9iJX+ylywdxOCXWWH8DFbe+KW6C1U4LXuha4paQP5Sx4 aacErJ0S6I8GgdspW43D4Tm1UxZ+0tAg3ochZc4xPuFdGT4vVczIqlPy1rZTcmjVKVmKz1Ym OMRnFFLm1BXOaMUVODzCA26CZHfUG3dU4bTwGmI60t8INfc3Avc39rNqIfY3gu/+RuD+xt5U L376GwHvbwSr/kboQX9jaNXfGFq1CYWObUKFHYu19BUVUD00EDefSZfPKWstCq2XFHZnJwlW QLkz2zlNpnHUcuz4+VNBOeYc4MiVjHIrZrgf0V8/YmDrN4IuthcGFdZz0NJ6Lo3xvioajVU0 dSec3GTYy4pGUysa7bui4SbDftU1WvjyeGhdw02G2/jor0sFuMPQpsOQ2wsvWKLvWm2n6bUd twC25lk5CWIvckPJrnxUlJt+vqfFx2OPsH8lW/jJAlgs10Kvn9abDH/3983ieL8U+uvkk5jN VSyWKwr399fPZRMOb2SMmnfHln04MWt2H4lpF8tvn+JV7HQApCkBzoGLD/GENv6GxR7GHjuj lzG7mEO4seNfy+CsZqNNMZG3ijy2Ay5lynbx220zezzl3hbyygw3OiETmsU0L4K3W3xtF+9t A0MeX+Xfa6jeumnzE1gTyM37alUP/YNTDE84SZmCwY6e1q28OOzsubbRPmSvrao67tAeydwU ow8pnuKB80TXrVy8t6rNgfcFd2124A24Et1fB65pDly34MB12/nLo7mk300v9uDajwfXmAfX Fh5cN596P5pPeMigNOaCBPgdaE/04drFh+sOJOHdQn5zEroJ5zEV0/EFFzHIOfImNKtSdsxF o+EAdSPC0gJTySgSeStdqMuSh+nIbCPOygJWdcF1B3pWNIKqA3sV13vGQ5IxpKUdtpLRlBY8 lo5UZvXCdCyuEW0bZC++fqBKFuNy1cL6HNiLRx73x9rOH1+8BlFw8iaOrxudWYswHWmZRzvy r21GfVWUkTP6TCA3ryhHZ9vBQYDV6exDo31kIxaRfV4KRP8elTt3b+if85IohdfpNC+jnVQj ZlE9XhRUOSVqp28kOufWERK8jsc+YZaSTdlG9ntx0GOGai1s1KfvtLZIvMUOjcaOZmyj+7w8 NDl26HZWxhl3rZDwdTzgAjOVbMo4st+rgx48dGvBo4NSlPUq8RM9AFGkwL9doLfrAoiKFLSw GuB8y2/wo0gBqkhBI1EC+hwigKxIQTvRAc5akQLhLS5gihQ0okhBnxUpICtS0I4iBWetSIEv RQoKFCloSpGCnitSYKFIQWuKFJy7IgX+FClAFSloRJGCPitSQFakoB1FCs5bkQJfihQUKFLQ lCIFPVekwEKRgtYUKTh7RQroipT4WcVPi6/PV/8HWfvVRqccAQA= --6c2NcOVqGQ03X4Wi-- From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 31 10:03:13 2013 Received: (at 15173) by debbugs.gnu.org; 31 Oct 2013 14:03:13 +0000 Received: from localhost ([127.0.0.1]:54805 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vbsq6-0000pt-UI for submit@debbugs.gnu.org; Thu, 31 Oct 2013 10:03:12 -0400 Received: from ramona.rm-rf.it ([149.154.157.136]:35129) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vbsq4-0000pe-2o for 15173@debbugs.gnu.org; Thu, 31 Oct 2013 10:03:08 -0400 Received: from valentina.fdc.rm-rf.it (valentina.fdc.rm-rf.it [192.168.192.1]) by ramona.rm-rf.it (Postfix) with ESMTP id 02CAC13E for <15173@debbugs.gnu.org>; Thu, 31 Oct 2013 15:03:02 +0100 (CET) Received: from caimano.fdc.rm-rf.it (caimano.fdc.rm-rf.it [192.168.192.17]) by valentina.fdc.rm-rf.it (Postfix) with ESMTP id 0DC1B20E31 for <15173@debbugs.gnu.org>; Thu, 31 Oct 2013 15:03:00 +0100 (CET) Received: from gpiero (uid 1000) (envelope-from gpiero@rm-rf.it) id 3c00d by caimano.fdc.rm-rf.it (DragonFly Mail Agent v0.9); Thu, 31 Oct 2013 15:03:00 +0100 Date: Thu, 31 Oct 2013 15:03:00 +0100 From: Gian Piero Carrubba To: =?utf-8?Q?P=C3=A1draig?= Brady Subject: Re: bug#15173: [cp] --link overrides dereference settings Message-ID: <20131031140300.GC30875@caimano.fdc.rm-rf.it> References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline In-Reply-To: <20131031135459.GB30875@caimano.fdc.rm-rf.it> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 15173 Cc: Bernhard Voelker , Eric Blake , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) * [Thu, Oct 31, 2013 at 02:54:59PM +0100] Gian Piero Carrubba: >>I've just now read POSIX for cp, and it states: >> >>"If the -R option was not specified, cp shall take actions based on the type >> and contents of the file referenced by the symbolic link, and not by the >> symbolic link itself, unless the -P option was specified." >> >>This suggests that -HL should only be significant with -R ? >>That is a bit surprising TBH. What do you think Eric? > >Oh well, didn't read it like this. My opinion was, and still is even >if not strong as before, that explicitly using -H/L/preserve=links >would override that _default_ behaviour. Sorry, fast reading got me confused. Yes, my opinion is that the default behaviour (i.e.: when not using -P or --preserve=links) should be to dereference the symlink. This does not mean that -HL are not significant without -R, as for what I remember about parameters order: cp -P -L should dereference the symlinks. Ciao, Gian Piero. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 31 12:47:45 2013 Received: (at 15173) by debbugs.gnu.org; 31 Oct 2013 16:47:45 +0000 Received: from localhost ([127.0.0.1]:55168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VbvPM-00056j-Dh for submit@debbugs.gnu.org; Thu, 31 Oct 2013 12:47:44 -0400 Received: from mail4.vodafone.ie ([213.233.128.170]:17333) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VbvPH-00056S-KM for 15173@debbugs.gnu.org; Thu, 31 Oct 2013 12:47:41 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApMBANiIclJda9XW/2dsb2JhbAANTIcmvFaBPIMZAQEBBCMPAUYQCw0BCgICBRYLAgIJAwIBAgFFBg0BBQIBAYgIqQN2klGBKY4mB4JrgUMDnm6OSw Received: from unknown (HELO [192.168.1.79]) ([93.107.213.214]) by mail3.vodafone.ie with ESMTP; 31 Oct 2013 16:47:32 +0000 Message-ID: <527289A4.3020407@draigBrady.com> Date: Thu, 31 Oct 2013 16:47:32 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <273932314.24270.1383225444529.open-xchange@email.1und1.de> In-Reply-To: <273932314.24270.1383225444529.open-xchange@email.1und1.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , Eric Blake , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 10/31/2013 01:17 PM, Bernhard Voelker wrote: >> On October 31, 2013 at 1:12 PM Pádraig Brady wrote: >> That all seems consistent with expectations and what we previously discussed. >> >> But... >> >> I've just now read POSIX for cp, and it states: >> >> "If the -R option was not specified, cp shall take actions based on the type >> and contents of the file referenced by the symbolic link, and not by the >> symbolic link itself, unless the -P option was specified." >> >> This suggests that -HL should only be significant with -R ? >> That is a bit surprising TBH. What do you think Eric? >> >> It also suggests that we should hardlink to a symlink only with -P, >> i.e. that we should AT_SYMLINK_FOLLOW unless -P is specified ? >> That's also a bit surprising, given that POSIX for ln states >> that it's implementation defined what's done if neither -P or -L is specified. >> I wouldn't be inclined to follow POSIX in that regard. > > I don't read the POSIX spec that way: there are 2 things to consider: > a) POSIX doesn't say a word about hard links, and > b) the -l,--link option is a GNU extension to conveniently > copy files or trees by creating hard links (only). > > I.e. if someone uses -l, then the POSIX semantics does not > apply anymore because we do not copy anymore. Whether the > ln(1) specification does apply more here is another question. > > Therefore, I think GNU cp(1) should do what makes most sense > for the user - depending on -LPH or none being used. With the > proposed patch, I think we're getting a bit closer to that. OK cool. With that cp and ln will be more consistent with each other anyway. thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 31 13:27:34 2013 Received: (at 15173) by debbugs.gnu.org; 31 Oct 2013 17:27:34 +0000 Received: from localhost ([127.0.0.1]:55244 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vbw1t-0006BN-Hz for submit@debbugs.gnu.org; Thu, 31 Oct 2013 13:27:33 -0400 Received: from ramona.rm-rf.it ([149.154.157.136]:35146) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vbw1q-0006Av-Nd for 15173@debbugs.gnu.org; Thu, 31 Oct 2013 13:27:31 -0400 Received: from valentina.fdc.rm-rf.it (valentina.fdc.rm-rf.it [192.168.192.1]) by ramona.rm-rf.it (Postfix) with ESMTP id 953BE255 for <15173@debbugs.gnu.org>; Thu, 31 Oct 2013 18:27:23 +0100 (CET) Received: from caimano.fdc.rm-rf.it (caimano.fdc.rm-rf.it [192.168.192.17]) by valentina.fdc.rm-rf.it (Postfix) with ESMTP id 797881FC1D for <15173@debbugs.gnu.org>; Thu, 31 Oct 2013 18:26:51 +0100 (CET) Received: from gpiero (uid 1000) (envelope-from gpiero@rm-rf.it) id 3c00d by caimano.fdc.rm-rf.it (DragonFly Mail Agent v0.9); Thu, 31 Oct 2013 18:26:51 +0100 Date: Thu, 31 Oct 2013 18:26:51 +0100 From: Gian Piero Carrubba To: Bernhard Voelker Subject: Re: bug#15173: [cp] --link overrides dereference settings Message-ID: <20131031172651.GD30875@caimano.fdc.rm-rf.it> References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <273932314.24270.1383225444529.open-xchange@email.1und1.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <273932314.24270.1383225444529.open-xchange@email.1und1.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 15173 Cc: Eric Blake , =?utf-8?Q?P=C3=A1draig?= Brady , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) * [Thu, Oct 31, 2013 at 02:17:24PM +0100] Bernhard Voelker: >> On October 31, 2013 at 1:12 PM Pádraig Brady wrote: >> I've just now read POSIX for cp, and it states: >> >>  "If the -R option was not specified, cp shall take actions based on the type >>   and contents of the file referenced by the symbolic link, and not by the >>   symbolic link itself, unless the -P option was specified." >> >> This suggests that -HL should only be significant with -R ? >> That is a bit surprising TBH. What do you think Eric? [...] >I don't read the POSIX spec that way: there are 2 things to consider: >a) POSIX doesn't say a word about hard links, and >b) the -l,--link option is a GNU extension to conveniently >   copy files or trees by creating hard links (only). > >I.e. if someone uses -l, then the POSIX semantics does not >apply anymore because we do not copy anymore. I don't support this argument. Being it an extension could mean that it couldn't _violate_ POSIX but I don't think it is a good reason for being _inconsistent_ with POSIX. >Therefore, I think GNU cp(1) should do what makes most sense >for the user - depending on -LPH or none being used.  With the >proposed patch, I think we're getting a bit closer to that. I (strongly) disagree, _especially_ from a user perspective. This is the same inconsistence I mentioned before about `cp -r`. Let's say I run: cp symlink new so I get a copy of the _dereferenced_ file. Mmmh, wait a moment... I don't need a copy, a hardlink would be sufficient: cp -l symlink new And now I get a hardlink to the _symlink_. Why ? I just wanted to use link instead of copy, I didn't mention anything about the dereferencing. Why should I have different default behaviours about dereferencing when I use _unrelated_ options ? So now I have to remember that: - a plain `cp` dereferences - `cp -l` doesn't - `cp -r` doesn't - whatever new GNU option (not -yet- covered by POSIX) could possibly dereference, or not, or just for the command line arguments... Really Bernhard, from a user perspective this is terrible. Ciao, Gian Piero. From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 31 17:29:01 2013 Received: (at 15173) by debbugs.gnu.org; 31 Oct 2013 21:29:01 +0000 Received: from localhost ([127.0.0.1]:55659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VbznY-0005M8-3V for submit@debbugs.gnu.org; Thu, 31 Oct 2013 17:29:00 -0400 Received: from ramona.rm-rf.it ([149.154.157.136]:35148) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VbznV-0005Ls-3z for 15173@debbugs.gnu.org; Thu, 31 Oct 2013 17:28:58 -0400 Received: from valentina.fdc.rm-rf.it (valentina.fdc.rm-rf.it [192.168.192.1]) by ramona.rm-rf.it (Postfix) with ESMTP id D2AC4255 for <15173@debbugs.gnu.org>; Thu, 31 Oct 2013 22:28:49 +0100 (CET) Received: from caimano.fdc.rm-rf.it (caimano.fdc.rm-rf.it [192.168.192.17]) by valentina.fdc.rm-rf.it (Postfix) with ESMTP id 059DC20E5E for <15173@debbugs.gnu.org>; Thu, 31 Oct 2013 22:28:47 +0100 (CET) Received: from gpiero (uid 1000) (envelope-from gpiero@rm-rf.it) id 3c00d by caimano.fdc.rm-rf.it (DragonFly Mail Agent v0.9); Thu, 31 Oct 2013 22:28:47 +0100 Date: Thu, 31 Oct 2013 22:28:47 +0100 From: Gian Piero Carrubba To: Bernhard Voelker Subject: Re: bug#15173: [cp] --link overrides dereference settings Message-ID: <20131031212847.GE30875@caimano.fdc.rm-rf.it> References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Pd0ReVV5GZGQvF3a" Content-Disposition: inline In-Reply-To: <20131031135459.GB30875@caimano.fdc.rm-rf.it> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -0.5 (/) X-Debbugs-Envelope-To: 15173 Cc: Eric Blake , =?utf-8?Q?P=C3=A1draig?= Brady , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) --Pd0ReVV5GZGQvF3a Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline * [Thu, Oct 31, 2013 at 02:54:59PM +0100] Gian Piero Carrubba: >Oh... I was tweaking a bit the last patch posted by Bernhard in order >to let it be POSIX compliant (but now I have to add: "for my >interpretation of POSIX"), but didn't had the time to complete before >going to work. Will probably finish it up anyway this evening or >tomorrow, at this point at least for comparing how far we're currently >are from "POSIX". Here it is. First of all, sorry for having generated a lot of noise. I completely misunderstood the meaning of --no-preserve=links. Having get rid of that, the differences in the results of the tests are a lot less. $ fgrep "DIFFERENCE in Test: " testit.log | sed 's/^.*: //' cp -l filelink ... cp -l --preserve=links filelink ... cp -L -l filelink ... cp -L -l --preserve=links filelink ... cp -L -l -R filelink ... cp -L -l -R --preserve=links filelink ... cp -H -l filelink ... cp -H -l --preserve=links filelink ... cp -H -l -R filelink ... cp -H -l -R --preserve=links filelink ... I think they are all legit (full log and differences summary attached). * Changes with regard to the last patch posted by Bernhard. === Minor changes - use 'dereference' instead of 'deref' in order to be consistent with 'x->dereference' and for passing the "grep test"[0] - use 'command_line_arg' instead of 'cli_arg' in order to be consistent with an already used variable and for passing the "grep test" - move up the declaration of bool dereference in order to use it for every invocation of create_hard_link() - clean up the initialization of 'flags' in create_hard_link() [0] i.e.: http://jamie-wong.com/2013/07/12/grep-test/ === Major changes - dereference by default (i.e.: unless --no-dereference is used) the source files. I promise that I will not insist anymore :), but I really think this is important for consistency from a user point of view. Ciao, Gian Piero. --Pd0ReVV5GZGQvF3a Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="bug-15173.patch" Thu Oct 31 21:57:32 CET 2013 Gian Piero Carrubba * bug-15173 http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15173 diff -rN -u old-trunk/NEWS new-trunk/NEWS --- old-trunk/NEWS 2013-10-31 22:24:51.690232614 +0100 +++ new-trunk/NEWS 2013-10-31 22:24:51.694232641 +0100 @@ -70,6 +70,10 @@ ** Changes in behavior + cp --link now dereferences a symbolic link as source files before creating + the hard link in the destination, unless --no-dereference is used too. + Previously, it would create a hard link of the symbolic link. + dd status=none now suppresses all non fatal diagnostic messages, not just the transfer counts. diff -rN -u old-trunk/src/copy.c new-trunk/src/copy.c --- old-trunk/src/copy.c 2013-10-31 22:24:51.690232614 +0100 +++ new-trunk/src/copy.c 2013-10-31 22:24:51.698232676 +0100 @@ -1558,18 +1558,23 @@ _("failed to restore the default file creation context")); } -/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE and - VERBOSE settings. Return true upon success. Otherwise, diagnose - the failure and return false. - If SRC_NAME is a symbolic link it will not be followed. If the system - doesn't support hard links to symbolic links, then DST_NAME will - be created as a symbolic link to SRC_NAME. */ +/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE, VERBOSE and + DEREFERENCE settings. Return true upon success. Otherwise, diagnose the + failure and return false. If SRC_NAME is a symbolic link it will not be + followed unless DEREFERENCE is true. + If the system doesn't support hard links to symbolic links, then DST_NAME + will be created as a symbolic link to SRC_NAME. */ static bool create_hard_link (char const *src_name, char const *dst_name, - bool replace, bool verbose) + bool replace, bool verbose, bool dereference) { - /* We want to guarantee that symlinks are not followed. */ - bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); + /* We want to guarantee that symlinks are not followed, unless requested. */ + int flags = 0; + if (dereference) + flags = AT_SYMLINK_FOLLOW; + + bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) + != 0); /* If the link failed because of an existing destination, remove that file and then call link again. */ @@ -1582,7 +1587,8 @@ } if (verbose) printf (_("removed %s\n"), quote (dst_name)); - link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); + link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) + != 0); } if (link_failed) @@ -1595,6 +1601,17 @@ return true; } +/* Return true if the current file should be (tried to be) dereferenced: + either for DEREF_ALWAYS or for DEREF_COMMAND_LINE_ARGUMENTS in the case + where the current file is a COMMAND_LINE_ARG; otherwise return false. */ +static inline bool _GL_ATTRIBUTE_PURE +should_dereference (const struct cp_options *x, bool command_line_arg) +{ + return x->dereference == DEREF_ALWAYS + || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS + && command_line_arg); +} + /* Copy the file SRC_NAME to the file DST_NAME. The files may be of any type. NEW_DST should be true if the file DST_NAME cannot exist because its parent directory was just created; NEW_DST should @@ -1670,6 +1687,8 @@ record_file (x->src_info, src_name, &src_sb); } + bool dereference = should_dereference (x, command_line_arg); + if (!new_dst) { /* Regular files can be created by writing through symbolic @@ -1748,7 +1767,7 @@ /* Note we currently replace DST_NAME unconditionally, even if it was a newer separate file. */ if (! create_hard_link (earlier_file, dst_name, true, - x->verbose)) + x->verbose, dereference)) { goto un_backup; } @@ -2078,7 +2097,8 @@ } else { - if (! create_hard_link (earlier_file, dst_name, true, x->verbose)) + if (! create_hard_link (earlier_file, dst_name, true, x->verbose, + dereference)) goto un_backup; return true; @@ -2389,7 +2409,7 @@ && !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode) && x->dereference == DEREF_NEVER)) { - if (! create_hard_link (src_name, dst_name, false, false)) + if (! create_hard_link (src_name, dst_name, false, false, dereference)) goto un_backup; } else if (S_ISREG (src_mode) diff -rN -u old-trunk/tests/cp/same-file.sh new-trunk/tests/cp/same-file.sh --- old-trunk/tests/cp/same-file.sh 2013-10-31 22:24:51.690232614 +0100 +++ new-trunk/tests/cp/same-file.sh 2013-10-31 22:24:51.698232676 +0100 @@ -189,9 +189,9 @@ 0 -bf (foo sl1 -> foo sl2 sl2.~1~ -> foo) 0 -bdf (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) 1 -l [cp: cannot create hard link 'sl2' to 'sl1'] (foo sl1 -> foo sl2 -> foo) -0 -fl (foo sl1 -> foo sl2 -> foo) -0 -bl (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) -0 -bfl (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) +0 -fl (foo sl1 -> foo sl2) +0 -bl (foo sl1 -> foo sl2 sl2.~1~ -> foo) +0 -bfl (foo sl1 -> foo sl2 sl2.~1~ -> foo) 1 [cp: 'foo' and 'hardlink' are the same file] (foo hardlink) 1 -d [cp: 'foo' and 'hardlink' are the same file] (foo hardlink) --Pd0ReVV5GZGQvF3a Content-Type: application/octet-stream Content-Disposition: attachment; filename="testit-differences-summary.log.gz" Content-Transfer-Encoding: base64 H4sICJzDclICA3Rlc3RpdC1kaWZmZXJlbmNlcy1zdW1tYXJ5LmxvZwDllEEKgkAYhfee4l3g l1SMFGyTygSiIEIHkBEkERklO35ZUZmith1hdvMG5ns8voTXjY20AqgAkOUFL/LyDFVVFXO7 0w3LAImWBHUHOjaI0gaGBl2zDQuhd1qUy14pE4Vor89zT2n9VBS4oP3C8PuvjxeO48A9+r4X e+HBQ14imUBT+pdEleA1FxfudJFa4h6mUT+9UCDxIkbhBuzrWMUi2N9uKJZ6GQO8Ef41rWMW 96sfJrM32LQ32Jq8wf7zBpPbG2zOG2xd3liGq9wAgGsUa4AKAAA= --Pd0ReVV5GZGQvF3a Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="testit.log.gz" Content-Transfer-Encoding: quoted-printable =1F=8B=08=08=F2=BFrR=02=03testit.log=00=ED]]=8F=DB=B6=12}=DF_=C1=F7=C0=BB= =B6=B4=BB=F6=06H_=DA=14STH=04=F5=02=F7=F1=C2=D7=96=13#=8C=BD=10=9Dn=82=A2@= =7F=C6=BD=7F=AF=BF=A4=92e;=B6=C5=91=86=A2=E4=0Fq=82}=88=BDC=CA><<=1C=1E=CDR= a=12?=8F=93X=ACb=B5R=E2=F6=F6=F6=E6=95=F8=FCi:O=C4TL=EF=A6^=FAr=B5=FC2=F9(f= =BB=FFM=EFf=DE=DE=8B=A9w7=F3=D3=D7r!z*k5O=E4|=F1i=F7=CEL=CC=E62>xk=B1|=F9= =18=A7=17=9D=8E=17=1F=0Ec=BD=ACw=F9=BD=B7=EC=F54{=3D=9B/=A6{]e=D7=D94=DE^P= =F4=E2=AF=F1DH%zr=BA=FC0=17=7F=FC)^=DD<=0C=07=A3=91=F7$=A6=C9=CB=D7=A4=97= =FD=08_=DC=F7=9F=1E=C5=FB=C9J=F8=03=E1=0D^=FB=E9=AF=F3=C0=F4=F5^=A0=A7=0B= =CC0=C9c}=D1K^zI/=FB=11=03=91=FE=EB=17c3l=F2=F0=07!=B3=AE=D7?y=B8W=08=97=A2= =F7=83=D8]=C0=AB=BE=C0l=1B{_=DD=FBl=DD{=D6=E2q=E4=F9=E9=17;n1=17S= =F1=E2=A9=98=9F.Y$^H$Y=C8=C6)=93H=7F=A0=A6=8ET5=A5,d=BF=9Ei=87=9E!=AA%ZD=A7= =16=DFsd2=A1=C7=A6"=E4=AA/d|=EF=91=E9=87=9F=14=AB=A5=9B=A4=B3K=B2=B5=CAd=C2= =0E=C7E=C8U_=CB$;=FBL=BF=92=F3=801=C2EF=14=E3=BB=95L=AA=92c=89q=92Y =1B=DF= =B5d=1A=E2=A7>kIg@06b=99X=A4c=AE=11=A2=D5=976=C5=F7=04=98=8A=C4s=BD1=F2EFt= =E3=FB=9FL0=E2A=E68=E1=AC=04=8F=EF=832%)'=B7=17=E9=174Y4=14p=8DP'yC=90=B1= =A0=D5j=B4=80=AB=D1=9C`=9A>'=0B=E8 Y=D0Z6=C6=83]=18=EC=87=E1=BD=FF=F00=DC= =FF=AA=F7=9A=AF=BA>=CFl=1D:=AAB%=0D=BD=DBu=FCT=F5]=F3=E8=FC=DB=A6=0D=1E=FB= =94=06=B3M=F7=8F=03R=B4L=A3=87=0F=0F=83'=D2G=DFD{=FD*L=D6g=FD=ACC+=99=92=86= =E6=98d=D1=1E)Z=DE=0C=FBOO=DE=B0=92YYt H=1E}O=8AN=FB=1E=F4}=EF=F8=0C;dtd6:y=83=11=A5=FB|8=87=83A=FFq4$5X_=A1=85=07= X 2T3M=0FN=97=A3=B3P=9DU=A8=BCj=A1"6=90=88=B2yU=CAF=8B=EE=8E=B2yU=CAF=8B=D6= *=9BW!T=F4=06=0D=08=15RA=114=FC'=DC=01=FF=15w7=F3kb=D1D=D0=F6=9Fr=07=FC=D7= =DC=EE0=0E=DD=D3I=A3m=9D=BC=F6=9D=DD=3D=BEJ=99DKj=F4.% Ec=F4{(]=FFL=1AH=83= =06=FB =13=BD=81=C9=15J=A6=90=A7=99=10y=C6t0=89*=DB\v=CAJM=FA=F2=84=92=9A= =F4Ug=93=07I_=9F=98=F45!B=E4=85=CFf=93';=B7=CFc=D9b=D9b=D9:=8Bl)l=B7=D7t2= =CE=B9w'soE=DD=ED=A9=B6w{|=9A=84+=8CCw{=85=AA=AAl=AC=D3=81=DD=AD=99=E9=D0= =A6=FD=8C=17=E2=F3=F8S,=92X=8EW=F3=DFc=A1=BE}=FE=EFR=CE'"=A7=CDr!=BFeO$=98|= I=92x=B1=FAN=92=FD=FEf^=93=9D=C9=06;[/=F6=B6=FDUM=B5=08=9F\=E9=C7=D8=A5A=B6= =1FC=D7=B1=3D=F2=DA^e=1B=BD67=16,F=D7y=DB=C6=ADd=92=BC=07=AE=AEGd=EDnO=BB= =E9=99=12=8B9=8B9=8B=B9sb=0E=FAJ^hr=CF=06=BC?=EB=DC=FE=0Ch=95=BC=D0=AA=19= =00=EC=048=C14=BD=0F=00=F4[=BE=C0=95=BCg]=9C=FDk=AA=E4=AD=F8=A6G=B7A=B26=1E= =A5=CD=1E>=85T=C0/=AD}=EB=13=B3=06=83:]=B4=E2=AC=AC=B0wSy[=F1]=F3=B4|=83O= =DE=E6=89=D2=A6A=B1=A0-L=B5o=CD=02=D7=DF=B2=BC=B0=BC8)/H=D5,4\5=0B\5=DB=CD\= =96X5=0BmW=CD=02W=CD=BA=C38t=FF$=8D=B6PW_5=EB=1B=95=9F=F9F=05e=BE=01=A1|=D3= =822=DF=B4>=CC7=A3=AC_=B5=D0=12=DBT=95=88=F9=C6S=C3=AFZ=CE=89m=8ER$R=9BS&= =9D=A4l=AD=E06=97dkM=88=06y=A1=B2=D9Ju=AF=CA=95e=86e=86e=86$3 =DBM5=9D=ECrn=DB=C9=DCVQwS=AA=ED=DD=14W=A5=BA=C28t7=C5U=A9=F9=F2=D7^Y=13pI= =AAI=15=13=9709|=1B=E3=F2R=3D=F2=8E=92kF=CF=A6=AC\0=CAR=CBR{=C5R=BB=AE=E7= =1C/>=1C=AA=EA=EE=9D=ADx=A6T],WB=AD=C6=AB=F5=DEc=F3=FB5=8D=DF-=85=FA2=F9(fs= =19=8BeB=D1=8F]=FF=05=99=B0=B8=90v:<=1E=0E=FC=D1=B9=BF=BB=CF=91=8E=FCb=F9= =F21NbK0=8B=82X=00=17=0Fi m=FC=82]=83=7F=BD=D7*=02=1E=1DB=8C=FB=CB=D1!4=B8= =93l=FE=BD=B4=E7W=EB=0F=AF>l2*m=B29=B9=BA)=F4(=F4=8D*=18\=06o9=15=DD=C2;=AF= =0D)=E2+=DB=17=04=D9Y =D0=17L=E8@>=BD=0CKw=94x[E=A0=05=9E,=C7=B2=AE"=FB=15= =D3=96=D2D+=0E=E5M=DAA=91H=E7=FA=B2,=1BS=E6=AE=E0=AE=F4=CA|=02=8D=E8=B0$(= =9A2=AB3(=B3rH=99=15=A6=CC=CA@=99=D5=E9s=E5=91=FEA/=9B=E6=FA=E4m=A4=7F=CC= =CB=B6=8D=3D=8EDB=D7=D7fu=01Y=F3e!=9F=3DL\=CB=DF=90=8Ai=E8=F0=AEc=8D=1E=85= =B5am=CA=86=BC=CB;=C4=1B=D1=DB=D0@oC=B7=BD=89=0D=8AD=DEF6=D4e=8F=A2=F8=B0s= =04gi=00=ABtx?=81>2=1EA=D5=82=BD=92=F7q=DAg=A5cHGf=D8F=8Cfd=C0=E3=C8=92=CA= =ECJ=E8=9E=8E=ADE=DB=04Y=E7=F7=0FT+"=ACv#=8C=1F=07=ED<=F2=B8=1E+3=3Dv=DE=83= (y=00/=8E=AF=1D=9D=D9=8B=D0=3D=D9=B6=88v=D0=BEg=19t=D5=A2D=1E=FB=AA=03=F9= =F4Nq=E0=8CS=BC{&=AA=16=F8=E8$PG=1D=07=97=C8=F2=E8=FC=0D=01=FB,\=97=8Eq=1DWvy*q=97=DD=D6w=BAY=12=90=CC=926G=C1%=EE+T= =E7O=03x=D7=C1%2^=9D=87=EE=CA1=AE=E3:=AFN=A5=F3=AA=E3:=AF=0Ct^=9DM=E7=95S:= =0F=88/=03=EDc=0D=9D=06=95=C2s8=03=C3=C1)n#=AA=0E'=91t=E8=B2=9E=03=D9=97=81= =F3H98=A6=E3=98/=03'=F1e=A0=CB=BE=0C=90}=198=8F/=03N=F92P=E2=CB=C0=A9|=19= =E8=B8/=03=06=BE=0C=9C=CD=97=01=D7|=19@}=198=89/=03]=F6e=80=EC=CB=C0y|=19p= =CA=97=81=12_=06N=E5=CB@=C7}=190=F0e=E0l=BE=0C\=BB/#~=94=F1x=F1=E5=F9=E6=1F= =F2=BB:=1F=E6=1D=01=00 --Pd0ReVV5GZGQvF3a-- From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 01 20:07:57 2013 Received: (at 15173) by debbugs.gnu.org; 2 Nov 2013 00:07:57 +0000 Received: from localhost ([127.0.0.1]:58327 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VcOku-0000io-IH for submit@debbugs.gnu.org; Fri, 01 Nov 2013 20:07:56 -0400 Received: from mail5.vodafone.ie ([213.233.128.176]:20190) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VcOks-0000ib-H6 for 15173@debbugs.gnu.org; Fri, 01 Nov 2013 20:07:55 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBAIZBdFJtTemc/2dsb2JhbAANTIM/g1u8cIE2gxkBAQEEIwQLAUYQCw0LAgIFFgsCAgkDAgECAUUGDQEHAQGICAipb3aSMoEpji8HgmuBQwOUK4pDjks Received: from unknown (HELO [192.168.1.79]) ([109.77.233.156]) by mail3.vodafone.ie with ESMTP; 02 Nov 2013 00:07:47 +0000 Message-ID: <52744252.3070300@draigBrady.com> Date: Sat, 02 Nov 2013 00:07:46 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Gian Piero Carrubba Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> In-Reply-To: <20131031212847.GE30875@caimano.fdc.rm-rf.it> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Bernhard Voelker , Eric Blake , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 10/31/2013 09:28 PM, Gian Piero Carrubba wrote: > * [Thu, Oct 31, 2013 at 02:54:59PM +0100] Gian Piero Carrubba: >> Oh... I was tweaking a bit the last patch posted by Bernhard in order to let it be POSIX compliant (but now I have to add: "for my interpretation of POSIX"), but didn't had the time to complete before going to work. Will probably finish it up anyway this evening or tomorrow, at this point at least for comparing how far we're currently are from "POSIX". > > Here it is. > First of all, sorry for having generated a lot of noise. I completely misunderstood the meaning of --no-preserve=links. Having get rid of that, the differences in the results of the tests are a lot less. > > $ fgrep "DIFFERENCE in Test: " testit.log | sed 's/^.*: //' > cp -l filelink ... > cp -l --preserve=links filelink ... > cp -L -l filelink ... > cp -L -l --preserve=links filelink ... > cp -L -l -R filelink ... > cp -L -l -R --preserve=links filelink ... > cp -H -l filelink ... > cp -H -l --preserve=links filelink ... > cp -H -l -R filelink ... > cp -H -l -R --preserve=links filelink ... > > I think they are all legit (full log and differences summary attached). > > * Changes with regard to the last patch posted by Bernhard. > > === Minor changes > > - use 'dereference' instead of 'deref' in order to be consistent with 'x->dereference' and for passing the "grep test"[0] > - use 'command_line_arg' instead of 'cli_arg' in order to be consistent with an already used variable and for passing the "grep test" > - move up the declaration of bool dereference in order to use it for every invocation of create_hard_link() > - clean up the initialization of 'flags' in create_hard_link() > > [0] i.e.: http://jamie-wong.com/2013/07/12/grep-test/ > > === Major changes > > - dereference by default (i.e.: unless --no-dereference is used) the source files. > I promise that I will not insist anymore :), but I really think this is important for consistency from a user point of view. > > Ciao, > Gian Piero. So far we have Bernhard's slightly less invasive patch which is an improvement, and behaves as per this table: Old New BSD +------------- ln | S = T ln -L | T = T ln -P | S = S cp -l | S S - cp -lL | S T - cp -lP | NS S - cp -Rl | NS S - cp -RlL | S T - cp -RlP | NS S - NS = New symlink S = hard link to symlink T = hard link to symlink target Furthermore my previously noted POSIX interpretation, and Gian's preference and patch, is to also deref in the 'cp -l' case above (to turn it to a T). There are valid arguments to doing that. 1. Follows naturally from standard cp which would create files in the dest 2. POSIX seems to imply we should operation on target without -P 3. A hardlink to a relative symlink may become invalid when in a different dir Arguments against doing it would be: 1. It would be a little more invasive given the less specific cp command. 2. would be inconsistent with `ln`. Though not on BSD. Now we're free to change ln to hardlink to targets rather than to symlinks by default, and that may be more natural as per the 3 points above. Though that would be more invasive again. So I would be 60:40 for going with Gian's addition of dereferencing with just `cp -l`, and I would be 60:40 against changing the behavior of `ln` even though it would now be inconsistent with `cp -l` (and still inconsistent with BSD). thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 03 19:48:29 2013 Received: (at 15173) by debbugs.gnu.org; 4 Nov 2013 00:48:29 +0000 Received: from localhost ([127.0.0.1]:33244 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vd8LD-0007ad-WE for submit@debbugs.gnu.org; Sun, 03 Nov 2013 19:48:28 -0500 Received: from moutng.kundenserver.de ([212.227.17.10]:49314) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vd8LA-0007aH-4r for 15173@debbugs.gnu.org; Sun, 03 Nov 2013 19:48:25 -0500 Received: from [192.168.1.11] (p5499C6C3.dip0.t-ipconnect.de [84.153.198.195]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0MIyAj-1VfbJF1eYr-0035PH; Mon, 04 Nov 2013 01:48:12 +0100 Message-ID: <5276EECB.6050003@bernhard-voelker.de> Date: Mon, 04 Nov 2013 01:48:11 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> In-Reply-To: <52744252.3070300@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:KuHL5adUscgFy7GveFZaYFxi0ECqC3Xae4EXsrrx/C0 u1hApngVJL7HcUHLus3upWdkF1AgmE3Pb158hUPLZCKtits0cI wnINB50KoAhkbh6Td4hd4pacpBuSGX/GNEmcGfy+/Gs8DXSXVY i5RitZQA9zEwG3kxx5W1+hhVnwnBy1P6fPK6ulC0HsHKexNSEu FnugGtBjxcHusBtqatVZ7Ng5z9HnWgz5Bo4ExLBe6CpeEA0TrS R5cJT7RfnAQJN9QNkNT+1625VokmVJz03OE8hBl/slNnhSh+ag WrAPSyzxwWQwobVrWsxG1eNJrCQBBLDv1Byt42aAkCp+DbK6wN xPphodFQ0A9hsYg5ExXCcUb+M83Hp5vEdoFhaofC2 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , Eric Blake , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 11/02/2013 01:07 AM, Pádraig Brady wrote: > So I would be 60:40 for going with Gian's addition > of dereferencing with just `cp -l`, and I would be > 60:40 against changing the behavior of `ln` even though > it would now be inconsistent with `cp -l` (and still inconsistent with BSD). Thanks for the summary. After playing a bit more, I'd also tend to use Gian's solution: hard links to symbolic links are probably not that useful, because * they have the same owner/group as the original symbolic link which could lead to problems with permissions during removal of the symlink in a sticky dir like /tmp), and * the target cannot be changed without creating the symlink again which is problematic to remember in both places. BUT I'm not happy at all with the following case: $ : > file $ ln -s file filelink $ src/cp --link filelink dst--link $ src/cp --link -R filelink dst--link-R $ ls -ldogi file filelink dst--link dst--link-R 537364 -rw-r--r-- 2 0 Nov 4 01:30 dst--link 537365 lrwxrwxrwx 2 4 Nov 4 01:30 dst--link-R -> file 537364 -rw-r--r-- 2 0 Nov 4 01:30 file 537365 lrwxrwxrwx 2 4 Nov 4 01:30 filelink -> file That's exactly what Gian was worried about in a different case of my solution: it *matters* whether the rather unrelated -R option is specified or not. ;-( It got late again. I'll have a look tomorrow again - maybe there are no side effects with the following: diff --git a/src/cp.c b/src/cp.c index 7bc8630..78c0a04 100644 --- a/src/cp.c +++ b/src/cp.c @@ -1135,7 +1135,7 @@ main (int argc, char **argv) if (x.dereference == DEREF_UNDEFINED) { - if (x.recursive) + if (x.recursive && ! x.hard_link) /* This is compatible with FreeBSD. */ x.dereference = DEREF_NEVER; else Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 04 04:37:16 2013 Received: (at 15173) by debbugs.gnu.org; 4 Nov 2013 09:37:16 +0000 Received: from localhost ([127.0.0.1]:33572 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VdGax-0003yb-Lu for submit@debbugs.gnu.org; Mon, 04 Nov 2013 04:37:15 -0500 Received: from mail1.vodafone.ie ([213.233.128.43]:20733) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VdGav-0003yH-7y for 15173@debbugs.gnu.org; Mon, 04 Nov 2013 04:37:13 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBANNpd1JtTcsE/2dsb2JhbAANTIcauTWCfYE4gxkBAQEEIwQLAUYQCw0BCgICBRYLAgIJAwIBAgFFBg0BBwEBF4drqwJ2khKBKY4vB4JrgUMDnm6OSw Received: from unknown (HELO [192.168.1.79]) ([109.77.203.4]) by mail1.vodafone.ie with ESMTP; 04 Nov 2013 09:37:06 +0000 Message-ID: <52776AC3.3020407@draigBrady.com> Date: Mon, 04 Nov 2013 09:37:07 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> In-Reply-To: <5276EECB.6050003@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , Eric Blake , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 11/04/2013 12:48 AM, Bernhard Voelker wrote: > On 11/02/2013 01:07 AM, Pádraig Brady wrote: >> So I would be 60:40 for going with Gian's addition >> of dereferencing with just `cp -l`, and I would be >> 60:40 against changing the behavior of `ln` even though >> it would now be inconsistent with `cp -l` (and still inconsistent with BSD). > > Thanks for the summary. > > After playing a bit more, I'd also tend to use Gian's solution: > hard links to symbolic links are probably not that useful, because > * they have the same owner/group as the original symbolic link which > could lead to problems with permissions during removal of the symlink > in a sticky dir like /tmp), and > * the target cannot be changed without creating the symlink again > which is problematic to remember in both places. > > BUT I'm not happy at all with the following case: > > $ : > file > $ ln -s file filelink > $ src/cp --link filelink dst--link > $ src/cp --link -R filelink dst--link-R > $ ls -ldogi file filelink dst--link dst--link-R > 537364 -rw-r--r-- 2 0 Nov 4 01:30 dst--link > 537365 lrwxrwxrwx 2 4 Nov 4 01:30 dst--link-R -> file > 537364 -rw-r--r-- 2 0 Nov 4 01:30 file > 537365 lrwxrwxrwx 2 4 Nov 4 01:30 filelink -> file > > That's exactly what Gian was worried about in a different case > of my solution: it *matters* whether the rather unrelated -R option > is specified or not. ;-( > > It got late again. I'll have a look tomorrow again - maybe there > are no side effects with the following: > > diff --git a/src/cp.c b/src/cp.c > index 7bc8630..78c0a04 100644 > --- a/src/cp.c > +++ b/src/cp.c > @@ -1135,7 +1135,7 @@ main (int argc, char **argv) > > if (x.dereference == DEREF_UNDEFINED) > { > - if (x.recursive) > + if (x.recursive && ! x.hard_link) > /* This is compatible with FreeBSD. */ > x.dereference = DEREF_NEVER; > else Yes I didn't consider -R in the table as I don't see any reason for it to behave differently when -l is specified (and -l aplies neither to POSIX or BSD (comment)). So the above adjustment looks correct to me. thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 04 18:03:03 2013 Received: (at 15173) by debbugs.gnu.org; 4 Nov 2013 23:03:03 +0000 Received: from localhost ([127.0.0.1]:34749 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VdTAj-0002ds-Fk for submit@debbugs.gnu.org; Mon, 04 Nov 2013 18:03:02 -0500 Received: from moutng.kundenserver.de ([212.227.17.10]:59476) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VdTAe-0002da-EH for 15173@debbugs.gnu.org; Mon, 04 Nov 2013 18:02:58 -0500 Received: from [192.168.1.11] (p5499C6C3.dip0.t-ipconnect.de [84.153.198.195]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0MZwat-1VLfKp1DCx-00Lsfg; Tue, 05 Nov 2013 00:02:48 +0100 Message-ID: <52782797.5010404@bernhard-voelker.de> Date: Tue, 05 Nov 2013 00:02:47 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> In-Reply-To: <52776AC3.3020407@draigBrady.com> Content-Type: multipart/mixed; boundary="------------080809050604070708080102" X-Provags-ID: V02:K0:ejZ6T2YEauHrfcZD2lf7iQgykZCkZdgpWZWmW2PDwtC DdLq+Gx8OUAwJq14o2AdIMY8GahQKkgnmnTHfoaSRYahWlwkSU j1McZkw1A3lt5xjFnw06grj6FojeUZIrnJRcMVij2ejp2f7iwe EsE3Cr+rMJCcbUjRhvI3JBz8sE2HPpCHiw9mcLuyOmzkvr2U96 BcnAYRxYYrr2LUyHQXbVxFxoBQWbP0kfsR4wmny3xmYHD1/FDU 6KExtEVgAcjWT1WSp4L3gPPBrN+twmKfn/PYvQDbzyTJwR7lR1 eXZOJLqZlTjLIeKAIsO3fwj2Fi7TmVwIigGW35pvFuHGY4QgqO mH+Suz9w8rbqmJYMReChqV/Tse+rDrnU0mPX6k788 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , Eric Blake , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) This is a multi-part message in MIME format. --------------080809050604070708080102 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 11/04/2013 10:37 AM, Pádraig Brady wrote: > On 11/04/2013 12:48 AM, Bernhard Voelker wrote: >> It got late again. I'll have a look tomorrow again - maybe there >> are no side effects with the following: >> >> diff --git a/src/cp.c b/src/cp.c >> index 7bc8630..78c0a04 100644 >> --- a/src/cp.c >> +++ b/src/cp.c >> @@ -1135,7 +1135,7 @@ main (int argc, char **argv) >> >> if (x.dereference == DEREF_UNDEFINED) >> { >> - if (x.recursive) >> + if (x.recursive && ! x.hard_link) >> /* This is compatible with FreeBSD. */ >> x.dereference = DEREF_NEVER; >> else > > Yes I didn't consider -R in the table as I don't see any reason > for it to behave differently when -l is specified (and -l aplies > neither to POSIX or BSD (comment)). So the above adjustment > looks correct to me. Indeed, that adjustment seems to be the right one - finally. ;-) I have added it to the patch as well as a new test case. I've added a "Co-authored-by:"-me line for that. @Gian: please note that we use "double-blank after-dot" format in comments. I've fixed that for you. The patch passes make check and syntax-check. I've also attached the test result cp-8.21 versus the new one. These are the differences (I leave out the --preserve=links cases as these are also affected but unrelated): COMMAND | 8.21 | NEW cp -l filelink ... | S | T cp -l -R filelink ... | S | T cp -L -l filelink ... | S | T cp -L -l -R filelink ... | S | T cp -H -l filelink ... | S | T cp -H -l -R filelink ... | S | T cp -l -R dirlink ... | S | NDH cp -l -R danglink ... | S | ERR_DEREF NDH = New directory with hard links below S = hard link to symlink T = hard link to symlink target ERR_DEREF = failure because dereferencing fails Now, the dereferencing behavior of cp --link is not related to -R anymore. I hope we don't introduce a regression ... Comments? Have a nice day, Berny --------------080809050604070708080102 Content-Type: text/x-patch; name="cp--link--deref-v3.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cp--link--deref-v3.patch" >From c29ed31b9bbdb8182758bc4e51604d19421bc1ec Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Mon, 4 Nov 2013 23:37:01 +0100 Subject: [PATCH] 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. * 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 --- NEWS | 5 +++ src/copy.c | 46 +++++++++++++++------ src/cp.c | 2 +- tests/cp/link-deref.sh | 110 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/cp/same-file.sh | 6 +-- tests/local.mk | 1 + 6 files changed, 153 insertions(+), 17 deletions(-) create mode 100755 tests/cp/link-deref.sh diff --git a/NEWS b/NEWS index 39dd3d6..7333488 100644 --- a/NEWS +++ b/NEWS @@ -70,6 +70,11 @@ GNU coreutils NEWS -*- outline -*- ** Changes in behavior + cp --link now dereferences a symbolic link as source before creating the + hard link in the destination unless explicitly requested via the -P option. + Previously, it would create a hard link of the symbolic link - even when one + of the dereferencing options -L or -H was specified, too. + dd status=none now suppresses all non fatal diagnostic messages, not just the transfer counts. diff --git a/src/copy.c b/src/copy.c index f66ab46..bcae123 100644 --- a/src/copy.c +++ b/src/copy.c @@ -1558,18 +1558,23 @@ restore_default_fscreatecon_or_die (void) _("failed to restore the default file creation context")); } -/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE and - VERBOSE settings. Return true upon success. Otherwise, diagnose - the failure and return false. - If SRC_NAME is a symbolic link it will not be followed. If the system - doesn't support hard links to symbolic links, then DST_NAME will - be created as a symbolic link to SRC_NAME. */ +/* Create a hard link DST_NAME to SRC_NAME, honoring the REPLACE, VERBOSE and + DEREFERENCE settings. Return true upon success. Otherwise, diagnose the + failure and return false. If SRC_NAME is a symbolic link, then it will not + be followed unless DEREFERENCE is true. + If the system doesn't support hard links to symbolic links, then DST_NAME + will be created as a symbolic link to SRC_NAME. */ static bool create_hard_link (char const *src_name, char const *dst_name, - bool replace, bool verbose) + bool replace, bool verbose, bool dereference) { - /* We want to guarantee that symlinks are not followed. */ - bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); + /* We want to guarantee that symlinks are not followed, unless requested. */ + int flags = 0; + if (dereference) + flags = AT_SYMLINK_FOLLOW; + + bool link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) + != 0); /* If the link failed because of an existing destination, remove that file and then call link again. */ @@ -1582,7 +1587,8 @@ create_hard_link (char const *src_name, char const *dst_name, } if (verbose) printf (_("removed %s\n"), quote (dst_name)); - link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0) != 0); + link_failed = (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, flags) + != 0); } if (link_failed) @@ -1595,6 +1601,17 @@ create_hard_link (char const *src_name, char const *dst_name, return true; } +/* Return true if the current file should be (tried to be) dereferenced: + either for DEREF_ALWAYS or for DEREF_COMMAND_LINE_ARGUMENTS in the case + where the current file is a COMMAND_LINE_ARG; otherwise return false. */ +static inline bool _GL_ATTRIBUTE_PURE +should_dereference (const struct cp_options *x, bool command_line_arg) +{ + return x->dereference == DEREF_ALWAYS + || (x->dereference == DEREF_COMMAND_LINE_ARGUMENTS + && command_line_arg); +} + /* Copy the file SRC_NAME to the file DST_NAME. The files may be of any type. NEW_DST should be true if the file DST_NAME cannot exist because its parent directory was just created; NEW_DST should @@ -1670,6 +1687,8 @@ copy_internal (char const *src_name, char const *dst_name, record_file (x->src_info, src_name, &src_sb); } + bool dereference = should_dereference (x, command_line_arg); + if (!new_dst) { /* Regular files can be created by writing through symbolic @@ -1748,7 +1767,7 @@ copy_internal (char const *src_name, char const *dst_name, /* Note we currently replace DST_NAME unconditionally, even if it was a newer separate file. */ if (! create_hard_link (earlier_file, dst_name, true, - x->verbose)) + x->verbose, dereference)) { goto un_backup; } @@ -2078,7 +2097,8 @@ copy_internal (char const *src_name, char const *dst_name, } else { - if (! create_hard_link (earlier_file, dst_name, true, x->verbose)) + if (! create_hard_link (earlier_file, dst_name, true, x->verbose, + dereference)) goto un_backup; return true; @@ -2389,7 +2409,7 @@ copy_internal (char const *src_name, char const *dst_name, && !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode) && x->dereference == DEREF_NEVER)) { - if (! create_hard_link (src_name, dst_name, false, false)) + if (! create_hard_link (src_name, dst_name, false, false, dereference)) goto un_backup; } else if (S_ISREG (src_mode) diff --git a/src/cp.c b/src/cp.c index 7bc8630..78c0a04 100644 --- a/src/cp.c +++ b/src/cp.c @@ -1135,7 +1135,7 @@ main (int argc, char **argv) if (x.dereference == DEREF_UNDEFINED) { - if (x.recursive) + if (x.recursive && ! x.hard_link) /* This is compatible with FreeBSD. */ x.dereference = DEREF_NEVER; else diff --git a/tests/cp/link-deref.sh b/tests/cp/link-deref.sh new file mode 100755 index 0000000..105c464 --- /dev/null +++ b/tests/cp/link-deref.sh @@ -0,0 +1,110 @@ +#!/bin/sh +# Exercise cp --link's behavior regarding the dereferencing of symbolic links. + +# Copyright (C) 2013 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src +print_ver_ cp + +mkdir dir || framework_failure_ +cp --help > file || framework_failure_ +ln -s dir dirlink || framework_failure_ +ln -s file filelink || framework_failure_ +ln -s nowhere danglink || framework_failure_ + +# printf format of the output line. +outformat='%s|result=%s|inode=%s|type=%s|error=%s\n' + +for src in dirlink filelink danglink; do + # Get symlink's target. + tgt=$(readlink $src) || framework_failure_ + # Get inodes and file type of the symlink (src) and its target (tgt). + # Note: this will fail for 'danglink'; catch it. + ino_src="$(stat -c '%i' $src)" || framework_failure_ + typ_src="$(stat -c '%F' $src)" || framework_failure_ + ino_tgt="$(stat -c '%i' $tgt 2>/dev/null)" || ino_tgt= + typ_tgt="$(stat -c '%F' $tgt 2>/dev/null)" || typ_tgt= + + for o in '' -L -H -P; do + for r in '' -R; do + + command="cp --link $o $r $src dst" + $command 2> err + result=$? + + # Get inode and file type of the destination (which may fail, too). + ino_dst="$(stat -c '%i' dst 2>/dev/null)" || ini_dst= + typ_dst="$(stat -c '%F' dst 2>/dev/null)" || typ_dst= + + # Print the actual result in a certain format. + printf "$outformat" \ + "$command" \ + "$result" \ + "$ino_dst" \ + "$typ_dst" \ + "$(< err)" \ + > out + + # What was expected? + if [ "$o" = "-P" ]; then + # cp --link should not dereference if -P is given. + exp_result=0 + exp_inode=$ino_src + exp_ftype=$typ_src + exp_error= + elif [ "$src" = 'danglink' ]; then + # Dereferencing should fail for the 'danglink'. + exp_result=1 + exp_inode= + exp_ftype= + exp_error="cp: cannot stat 'danglink': No such file or directory" + elif [ "$src" = 'dirlink' ] && [ "$r" != '-R' ]; then + # Dereferencing should fail for the 'dirlink' without -R. + exp_result=1 + exp_inode= + exp_ftype= + exp_error="cp: omitting directory 'dirlink'" + elif [ "$src" = 'dirlink' ]; then + # cp --link -R 'dirlink' should create a new directory. + exp_result=0 + exp_inode=$ino_dst + exp_ftype=$typ_dst + exp_error= + else + # cp --link 'filelink' should create a hard link to the target. + exp_result=0 + exp_inode=$ino_tgt + exp_ftype=$typ_tgt + exp_error= + fi + + # Print the expected result in a certain format. + printf "$outformat" \ + "$command" \ + "$exp_result" \ + "$exp_inode" \ + "$exp_ftype" \ + "$exp_error" \ + > exp + + compare exp out || { ls -lid $src $tgt dst; fail=1; } + + rm -rf dst err exp out || framework_failure_ + done + done +done + +Exit $fail diff --git a/tests/cp/same-file.sh b/tests/cp/same-file.sh index 003a62b..326f9c6 100755 --- a/tests/cp/same-file.sh +++ b/tests/cp/same-file.sh @@ -189,9 +189,9 @@ cat <<\EOF | sed "$remove_these_sed" > expected 0 -bf (foo sl1 -> foo sl2 sl2.~1~ -> foo) 0 -bdf (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) 1 -l [cp: cannot create hard link 'sl2' to 'sl1'] (foo sl1 -> foo sl2 -> foo) -0 -fl (foo sl1 -> foo sl2 -> foo) -0 -bl (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) -0 -bfl (foo sl1 -> foo sl2 -> foo sl2.~1~ -> foo) +0 -fl (foo sl1 -> foo sl2) +0 -bl (foo sl1 -> foo sl2 sl2.~1~ -> foo) +0 -bfl (foo sl1 -> foo sl2 sl2.~1~ -> foo) 1 [cp: 'foo' and 'hardlink' are the same file] (foo hardlink) 1 -d [cp: 'foo' and 'hardlink' are the same file] (foo hardlink) diff --git a/tests/local.mk b/tests/local.mk index e18deac..3c92425 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 \ -- 1.8.3.1 --------------080809050604070708080102 Content-Type: application/x-xz; name="testit.log.xz" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="testit.log.xz" /Td6WFoAAATm1rRGAgAhARYAAAB0L+Wj4SFtChZdACgciKczaUHouSdYKENK1feCL6hq2rdu MZ3l9HVnmKVOFssYrx1j5TPzdxLupIREYS+GNcNIzWlSnNnzL2y7K95GpfVVkHY9TZYU2kR1 8vfFOYTUlIoB8zg4EIo5/sF44X/ArNJiiKVh1pCCTuYteRIFKZfCSuoxfAaPC2Dvev3SiwF/ h7A+DzNpMI4PNyFsxwKOIg11pU/lucWx36AnQFJKDnI+LS5NBB0fo/8WGYQw7RXma2Yb1JL0 SN3t+DShF45900V7SLLZRTt9OUKDVO9lK+c6czdhOIvy/r/eEGgF4a7wqageTVkg9wPSYzRN tHxTs283KdOMitIfLaNL5wU/AwU7YLfRUNnySCrfmvBxA8zo3S5jXlujDgNbsDRAmxMXOj1G ibnYBy+uHSxjhiB1g2fP78+vk6kG7WMapu5I50C486/LyYpkv+fqxo1WjpEYIYjuFfpWoEq6 WOe+OUHQiMYvEIsqBP5FgM8WnE0X5b3KHUdt/9nZcW75TFiQoqAZHnaYsoBBgba8xGH0t70W lvcDxKyXFK89DKnzgNxEDGpwBpT7iGcYfOj0/Tz7+SyduyTO/AvnhEJ1xNAK+7UC+ofHp7m5 4b7QYDe4dbxh112cNTN9IYW3VMjvx8CNxNEGAYtwp4c20pPG2RHBiNuLhLVwk5u9zVRP3stZ dSdgTHn3wSF8Zv0CktltLhQIqAwDdIMnd2KkTLweGZP+mYYfmHlKmWRhsImf4PP/yUpz5AcI 54PVEhL3e9gnvnGpRD4mJpLpxVl87S4PT35Y+ZhZuVsMxjOVOml7uWBHDtIp2H7BR3OeMoiJ WrNWe9DEySeD2fgInHdk31S/YeTVlMMb8oRfauzhT1EHiqsxhxq6tZbsN04DeUVoZvO5ZzCx tgyt1tubLpuviWYjVu0LCXPCsE/BXEtwWXSNkN0CeLNnuekRdxOCboAwjPnsTAVVrcyJM9Rf jLA5s95VhjueOBsd9OYDbmJnpEbUMyLKPVJcCTDI+JrA19BegKLeHuEuCSOup9pGWJ7Lx7Oq LiT0JT+a8BBvUowyLBKYBQ4/s/GxY8zGM/V9E9szEZNIgo1VQexGHWEKIhzsg66heszFz+Sz QZxAVO6wDod407iizajqYw97O67OZcz8ZcaBIewpNrgyW9XFkIhhgxG3/jQUsXKq2MkJEwbB Z9Kds74EEFJQ/UuKyVFIPD7Rdf/+pXicE2m+QOMfcCt2Su511vk4iQL7Df8iBVCmluwMclkl 6mHtOGcx9Q8QW/q9fv+HKG8RAHNr5hzBZwCUtsdfq2dMCOEHIWmCMHYSOkTWtwmO3yFjiBhx zcq5N7w7QEp9JzvrZxWs755xP5CEam8FjnZMu9RNt4ZlElVwRX/qNagX8UNigvs0sHXXOI2o XAsWUIqwDWCZHX/fA06/6Rfg6OMyJjii/FZoiDZTl055S718/dtp2KKnWKkgK8SS8YWqO7VJ oBvUU4u6+BUY84VDAFd5gwVHbDCLr6Jp2sykoInkzfg1i1eYUJQWdZBgVQJc3e5BBStmYzQD REE208YOkEYI+NBUzfna3ra5XWzyNnCw27kmcfiNywRK/McXEMKN3u1jijKGwvKOty5w4HFt wYytmAFfSoAM37RBYxso1YcRvNdLX38iItPvgRMfvCkzRISoCK0qt5FubOHZIxkqVB1TyMPe UBvZ8gSioPcTezOXGPWaOIHmYc71rugZR/zJVh8ek12zsgTMCVEmSqvxYMMkj+/frvt/r8Kk drpAUOyNHMK8lTM6aeT3AAgcqnsG4JcaPaQqz6XtgFkAH1suiKH7etuiP+cqbLgnKVC+/Jfd 6sYZbXtH8g2p1LC8tI1mmLzUQtp7hsuMF2vnAJBcwxs62F0qx32gvkNyj+Y5D/nx8LuNjvXM rCxT63Kqk5CzbFkNsbAbajUaKkQe7mP48z7/qsSo/3KCRgPsBj4urTD5PuwsIk6D+pP10OI3 J2hK1B6lc4fBADP4uLq27mKbaEfP281WbXT840Rf/kj3WPJR9EdUz/ezkYpCEpoWgci5fMn5 PRJSV8qvIlvy9FkK74hXoq+Epz6lPAyv/Z7SiZueKTEnbQenCMOmVTurDv9MQXmM3jpBFah7 PYiIErNZ+ZYmxe5BMojPMTB3jCODInonB2E99gweF+Pgyj4urdaA3LVRQWcNwDxrUK0wrm/q vgVrmjuwBa8vmZmeQJ6ly+cfLTOlhvGjfjUFDU9iu1wCPcM67+Ba5Dl3qLTxrCZmrz8vdVCn vT4V0SorP6aS+/OVtlBjuvrzOgPgjkuncG2zA8q3vgW4ESstjixypYWBrEhiMoK7eWJ2Txq1 u8g3ZC/QWDprMABwloUG0j5MnbuiXWFqroc7MCVIjcBO9+XMAmjGVW5CMRmoWd2uQk2ySIcM 0m95dA2rWFuvRlV+PD43GTsACIKcrAwcVCn6XL+uZ92TAksqykSVgP/dpk2XNaV1fuQv7PLZ uKZc5aTaTRF+45VrCNmtoTHsDyfCGA44168tSd2gbvwBD6w4Qe/1IFY7aUColMDgVFeVUbsB ZRGlNPrm/HfS2sqOmdLp3epV6Kh7llvHgBeuQ7Z7+zp8I/jqGWKXbaLRqD5q0D+3n40RIJXh IjqXCni2BopPq7OwwnTFv6SEnxwpaUJYQhb1a+QG8IkZ/ziZGF1uFrsLipG5o+FtTbi3uBjQ puy0Z24HgYpjbRuSq8CB2ltcd/nxRZKv3qYFau/JYxW8iAbXcUah6mX5YXKlVlIG/EgMU9h7 G5G8zxfTliJwpa0HCQyGb0ZUrcRNPnwNDJwEyW9/mZSJO0/iVWLGPC8xqdRQksiW+hv26pnF g+zEk8a9Y2t9h6MHTIC9neF2WpRdN2vfYkIO5dge7ke31vxfkgoMvVOhOGecgYXAdKwgeqbU zmIE176/4t2fubCg4WMj6wCizccztl4XDRdTuQZKtS4JRXEq/CG7GCdulgQWdw1t/Cw8xxms gMiHgRPFEEqSwKQjvy11pg7jZfdCN8UsWgNUg8DsgoIX+9a4hI/cj5jVUXSZud/gdmtHyuGa TPG/bU9WzrrVuArhD0kYzKOk08ZVJtgiyNg2cPRXwGkMuQBFMIvWZLstoUL+nf6r1xPNmwU5 +4lyqJO5D9tQmAgaugbbzOAgEfESvR8Ng6+j6LOuQ8L/tJMK1X/YKCOtGsL+h4ZdNHwCPVPg H6j+/YTfqvC9vCotBrl3UYG5Fi0ylpKE5MFpeTeEk2dhsbV2JopmOD09XSh5xCQEfj8iaFoY 9uwwmk2fMaseF3kr9GRz+eLqi33hNVUaYxnMCOATyy3ombwZF1U6MpU/+YNKY+sI1ZBYCfsX T7MmxsA42hB+uzDbTLZQcW/eDvdYEMSmn8X8Wlvl+EExtkvMwkT6t9PX9x6qV6qA3k2N0QdY UIPDKlXr1NSnlWbaQ/vaL71e/a+AAAAAzxwJld10Y5EAAbIU7sIEAMDm0MGxxGf7AgAAAAAE WVo= --------------080809050604070708080102-- From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 04 18:33:12 2013 Received: (at 15173) by debbugs.gnu.org; 4 Nov 2013 23:33:12 +0000 Received: from localhost ([127.0.0.1]:34781 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VdTdv-0004U7-TY for submit@debbugs.gnu.org; Mon, 04 Nov 2013 18:33:12 -0500 Received: from mail1.vodafone.ie ([213.233.128.43]:30522) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VdTds-0004Ta-6p for 15173@debbugs.gnu.org; Mon, 04 Nov 2013 18:33:09 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBAPwteFJtTcsE/2dsb2JhbAANTIcauTmCf4E9gxkBAQEDASMPAUYFCwsNAQoCAgUWCwICCQMCAQIBRQYNAQcBARaHYQurCnaSPYEpji8HgmuBQwOebo5L Received: from unknown (HELO [192.168.1.79]) ([109.77.203.4]) by mail1.vodafone.ie with ESMTP; 04 Nov 2013 23:33:01 +0000 Message-ID: <52782EAC.4020609@draigBrady.com> Date: Mon, 04 Nov 2013 23:33:00 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <20130823214034.GA9000@caimano.fdc.rm-rf.it> <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <52782797.5010404@bernhard-voelker.de> In-Reply-To: <52782797.5010404@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , Eric Blake , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 11/04/2013 11:02 PM, Bernhard Voelker wrote: > On 11/04/2013 10:37 AM, Pádraig Brady wrote: >> On 11/04/2013 12:48 AM, Bernhard Voelker wrote: >>> It got late again. I'll have a look tomorrow again - maybe there >>> are no side effects with the following: >>> >>> diff --git a/src/cp.c b/src/cp.c >>> index 7bc8630..78c0a04 100644 >>> --- a/src/cp.c >>> +++ b/src/cp.c >>> @@ -1135,7 +1135,7 @@ main (int argc, char **argv) >>> >>> if (x.dereference == DEREF_UNDEFINED) >>> { >>> - if (x.recursive) >>> + if (x.recursive && ! x.hard_link) >>> /* This is compatible with FreeBSD. */ >>> x.dereference = DEREF_NEVER; >>> else >> >> Yes I didn't consider -R in the table as I don't see any reason >> for it to behave differently when -l is specified (and -l aplies >> neither to POSIX or BSD (comment)). So the above adjustment >> looks correct to me. > > Indeed, that adjustment seems to be the right one - finally. ;-) > I have added it to the patch as well as a new test case. I've added > a "Co-authored-by:"-me line for that. > > @Gian: please note that we use "double-blank after-dot" format in > comments. I've fixed that for you. > > The patch passes make check and syntax-check. > > I've also attached the test result cp-8.21 versus the new one. > These are the differences (I leave out the --preserve=links cases > as these are also affected but unrelated): > > COMMAND | 8.21 | NEW > cp -l filelink ... | S | T > cp -l -R filelink ... | S | T > cp -L -l filelink ... | S | T > cp -L -l -R filelink ... | S | T > cp -H -l filelink ... | S | T > cp -H -l -R filelink ... | S | T great > cp -l -R dirlink ... | S | NDH > cp -l -R danglink ... | S | ERR_DEREF These are Ok too I think given that cp -al will not deref and thus not give the errors. > NDH = New directory with hard links below > S = hard link to symlink > T = hard link to symlink target > ERR_DEREF = failure because dereferencing fails > > Now, the dereferencing behavior of cp --link is not related to -R anymore. > I hope we don't introduce a regression ... > > Comments? Small suggested adjustment to NEWS: + cp --link now dereferences a symbolic link as source before creating the + hard link in the destination unless the -P,--no-deref option is specified. + Previously, it would create a hard link of the symbolic link, even when + the dereferencing options -L or -H were specified. In the test I would do this to minimise writes to disk: - cp --help > file || framework_failure_ + touch file || framework_failure_ Very nice test BTW. thanks! Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 04 19:01:19 2013 Received: (at 15173) by debbugs.gnu.org; 5 Nov 2013 00:01:19 +0000 Received: from localhost ([127.0.0.1]:34801 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VdU59-0005H0-1v for submit@debbugs.gnu.org; Mon, 04 Nov 2013 19:01:19 -0500 Received: from ramona.rm-rf.it ([149.154.157.136]:35931) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VdU56-0005Gh-OR for 15173@debbugs.gnu.org; Mon, 04 Nov 2013 19:01:17 -0500 Received: from valentina.fdc.rm-rf.it (valentina.fdc.rm-rf.it [192.168.192.1]) by ramona.rm-rf.it (Postfix) with ESMTP id 4E4D73D2 for <15173@debbugs.gnu.org>; Tue, 5 Nov 2013 01:01:09 +0100 (CET) Received: from caimano.fdc.rm-rf.it (caimano.fdc.rm-rf.it [192.168.192.17]) by valentina.fdc.rm-rf.it (Postfix) with ESMTP id 5A5AF21011 for <15173@debbugs.gnu.org>; Tue, 5 Nov 2013 01:01:07 +0100 (CET) Received: from gpiero (uid 1000) (envelope-from gpiero@rm-rf.it) id 3c014 by caimano.fdc.rm-rf.it (DragonFly Mail Agent v0.9); Tue, 05 Nov 2013 01:01:06 +0100 Date: Tue, 5 Nov 2013 01:01:06 +0100 From: Gian Piero Carrubba To: =?utf-8?Q?P=C3=A1draig?= Brady Subject: Re: bug#15173: [cp] --link overrides dereference settings Message-ID: <20131105000106.GB5665@caimano.fdc.rm-rf.it> References: <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <52776AC3.3020407@draigBrady.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Bernhard Voelker , Eric Blake , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) >On 11/04/2013 12:48 AM, Bernhard Voelker wrote: [...] >> BUT I'm not happy at all with the following case: >> >> $ : > file >> $ ln -s file filelink >> $ src/cp --link filelink dst--link >> $ src/cp --link -R filelink dst--link-R >> $ ls -ldogi file filelink dst--link dst--link-R >> 537364 -rw-r--r-- 2 0 Nov 4 01:30 dst--link >> 537365 lrwxrwxrwx 2 4 Nov 4 01:30 dst--link-R -> file >> 537364 -rw-r--r-- 2 0 Nov 4 01:30 file >> 537365 lrwxrwxrwx 2 4 Nov 4 01:30 filelink -> file >> >> That's exactly what Gian was worried about in a different case >> of my solution: it *matters* whether the rather unrelated -R option >> is specified or not. ;-( Exactly. But this is a problem with the implementation of '-R', and as such I think it should be fixed there. Please see the just-opened bug #15806 [0]. Imho, modifying it here would mean special-casing a special-case. Add we wouldn't gain a lot in terms of consistency ( `cp` dereferences, `cp -R` doesn't, `cp -lR` does ). [0] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15806 * [Mon, Nov 04, 2013 at 09:37:07AM +0000] Pádraig Brady: >> diff --git a/src/cp.c b/src/cp.c >> index 7bc8630..78c0a04 100644 >> --- a/src/cp.c >> +++ b/src/cp.c >> @@ -1135,7 +1135,7 @@ main (int argc, char **argv) >> >> if (x.dereference == DEREF_UNDEFINED) >> { >> - if (x.recursive) >> + if (x.recursive && ! x.hard_link) >> /* This is compatible with FreeBSD. */ >> x.dereference = DEREF_NEVER; >> else > >Yes I didn't consider -R in the table as I don't see any reason >for it to behave differently when -l is specified (and -l aplies >neither to POSIX or BSD (comment)). So the above adjustment >looks correct to me. Not sure I've understood what you mean here. If '-R' should act the same when '-l' is specified, the above change should _not_ be applied. But I probably misunderstood. Ciao, Gian Piero. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 07 02:07:33 2013 Received: (at 15173) by debbugs.gnu.org; 7 Nov 2013 07:07:33 +0000 Received: from localhost ([127.0.0.1]:38238 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeJgi-00038F-LN for submit@debbugs.gnu.org; Thu, 07 Nov 2013 02:07:33 -0500 Received: from moutng.kundenserver.de ([212.227.126.171]:61052) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeJgf-000381-0g for 15173@debbugs.gnu.org; Thu, 07 Nov 2013 02:07:30 -0500 Received: from [192.168.1.11] (p5499C6C3.dip0.t-ipconnect.de [84.153.198.195]) by mrelayeu.kundenserver.de (node=mreu4) with ESMTP (Nemesis) id 0Ly7gf-1Vjh370HqP-015cph; Thu, 07 Nov 2013 08:07:12 +0100 Message-ID: <527B3C1F.1020400@bernhard-voelker.de> Date: Thu, 07 Nov 2013 08:07:11 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Gian Piero Carrubba Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> In-Reply-To: <20131105000106.GB5665@caimano.fdc.rm-rf.it> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:0OpeWL0O9y8vCQeTX11i2DBFXzHjGwuAVp5GQRBgycQ a1VchV/RjE5ImkHmRV7spD5niuWAMrP9xLsFhJBqIvE55S0NTo m2BFjBKD7CEOgzNUZAVpok7bIz3Mj/Qo0qoxTeOOL9fdfa73Nb 6ivJHbdBky/PYvj68oZdbhEgdS37+ITuR1AK2wKysKkIcA4n47 MppItHTLO1zhl1uYr516XR0geaGoUdddAow6bb1hhP3tL5Ldue 9tN7gFslw5TxZ1UttAV/ScbljjuPcVQqBkLeIsEwWSAL9lMUbU 79G+tSdNi56PU1r/g1J4NXN6PqjyKqH6zkXAcoXnDw0vFERGIZ 1rhwsA/M8NZGDn3hgys/a/c2CznNHCkdkEJ4Cq179 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Eric Blake , =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= , Jim Meyering , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) [I was hoping that someone with more coreutils history was jumping in here - adding Jim for that matter.] On 11/05/2013 01:01 AM, Gian Piero Carrubba wrote: >> On 11/04/2013 12:48 AM, Bernhard Voelker wrote: > [...] >>> BUT I'm not happy at all with the following case: >>> >>> $ : > file >>> $ ln -s file filelink >>> $ src/cp --link filelink dst--link >>> $ src/cp --link -R filelink dst--link-R >>> $ ls -ldogi file filelink dst--link dst--link-R >>> 537364 -rw-r--r-- 2 0 Nov 4 01:30 dst--link >>> 537365 lrwxrwxrwx 2 4 Nov 4 01:30 dst--link-R -> file >>> 537364 -rw-r--r-- 2 0 Nov 4 01:30 file >>> 537365 lrwxrwxrwx 2 4 Nov 4 01:30 filelink -> file >>> >>> That's exactly what Gian was worried about in a different case >>> of my solution: it *matters* whether the rather unrelated -R option >>> is specified or not. ;-( > > Exactly. But this is a problem with the implementation of '-R', and as > such I think it should be fixed there. Please see the just-opened bug > #15806 [0]. Imho, modifying it here would mean special-casing a > special-case. Add we wouldn't gain a lot in terms of consistency ( `cp` > dereferences, `cp -R` doesn't, `cp -lR` does ). > > [0] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15806 Okay, so we're leaving the ground of the GNU extension --link here. cp's dereferencing vs. non-dereferencing behavior with -r seems to be a longer story, e.g. there have been several commits between Dec 2001 and Mar 2002. I don't know why and I can't tell a reason, but I have the impression that the current behavior is the best choice for almost all situations. On the other side, many scripts I've seen (including mine) are using the -a option (which is "-dR --preserve=all" with in turn -d as "--no-dereference --preserve=links") for copying whole directory tree ... that may be an indication that the default for -r alone is not that much used. Anyway, I belief that doing a change aside from this --link patch would be quite delicate. Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 07 02:52:53 2013 Received: (at 15173) by debbugs.gnu.org; 7 Nov 2013 07:52:53 +0000 Received: from localhost ([127.0.0.1]:38385 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeKOa-0004IA-MS for submit@debbugs.gnu.org; Thu, 07 Nov 2013 02:52:53 -0500 Received: from ramona.rm-rf.it ([149.154.157.136]:35961) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeKOY-0004Hs-9R for 15173@debbugs.gnu.org; Thu, 07 Nov 2013 02:52:51 -0500 Received: from valentina.fdc.rm-rf.it (valentina.fdc.rm-rf.it [192.168.192.1]) by ramona.rm-rf.it (Postfix) with ESMTP id 70F69292 for <15173@debbugs.gnu.org>; Thu, 7 Nov 2013 08:52:43 +0100 (CET) Received: from caimano.fdc.rm-rf.it (caimano.fdc.rm-rf.it [192.168.192.17]) by valentina.fdc.rm-rf.it (Postfix) with ESMTP id 22CE8203A4 for <15173@debbugs.gnu.org>; Thu, 7 Nov 2013 08:52:41 +0100 (CET) Received: from gpiero (uid 1000) (envelope-from gpiero@rm-rf.it) id 3c014 by caimano.fdc.rm-rf.it (DragonFly Mail Agent v0.9); Thu, 07 Nov 2013 08:52:39 +0100 Date: Thu, 7 Nov 2013 08:52:39 +0100 From: Gian Piero Carrubba To: Bernhard Voelker Subject: Re: bug#15173: [cp] --link overrides dereference settings Message-ID: <20131107075239.GA22232@caimano.fdc.rm-rf.it> References: <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline In-Reply-To: <527B3C1F.1020400@bernhard-voelker.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Eric Blake , =?utf-8?Q?P=C3=A1draig?= Brady , Jim Meyering , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) * [Thu, Nov 07, 2013 at 08:07:11AM +0100] Bernhard Voelker: >> [0] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15806 > >Okay, so we're leaving the ground of the GNU extension --link here. Sure. It's a completely separate matter, just with some interactions (will follow-up on that report as soon as I've enough time: did more researches but as you noticed the commit history is pretty long and not always so linear). >Anyway, I belief that doing a change aside from this --link patch >would be quite delicate. I agree. My point here is that I would avoid modifying the behaviour of '-r' (even if it's considered "wrong") while working on '--link', as imo > - if (x.recursive) > + if (x.recursive && ! x.hard_link) would do. Well... and also that dereference settings in cp should be reorder a bit (but again it doesn't belong here). Ciao, Gian Piero. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 07 05:14:15 2013 Received: (at 15173) by debbugs.gnu.org; 7 Nov 2013 10:14:15 +0000 Received: from localhost ([127.0.0.1]:38583 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeMbO-0007g9-Px for submit@debbugs.gnu.org; Thu, 07 Nov 2013 05:14:15 -0500 Received: from mail3.vodafone.ie ([213.233.128.45]:63035) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeMbM-0007ft-Nn for 15173@debbugs.gnu.org; Thu, 07 Nov 2013 05:14:13 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBAMVme1Jdawop/2dsb2JhbAANTYcGuR+Ce4E9gxkBAQEDASMPAUYFCwsNAQoCAgUWCwICCQMCAQIBRQYNAQcBAYd3C6ozdpI/gSmOMAeCa4FFA55wjkw Received: from unknown (HELO [192.168.1.79]) ([93.107.10.41]) by mail3.vodafone.ie with ESMTP; 07 Nov 2013 10:14:06 +0000 Message-ID: <527B67ED.7050303@draigBrady.com> Date: Thu, 07 Nov 2013 10:14:05 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> In-Reply-To: <527B3C1F.1020400@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , Eric Blake , Jim Meyering , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 11/07/2013 07:07 AM, Bernhard Voelker wrote: > Okay, so we're leaving the ground of the GNU extension --link here. Yes. I think the --link case should be considered separately (with and without -R). I.E. IMHO your current patch is fine and good. > cp's dereferencing vs. non-dereferencing behavior with -r seems to be a > longer story, e.g. there have been several commits between Dec 2001 and > Mar 2002. I don't know why and I can't tell a reason, but I have the > impression that the current behavior is the best choice for almost all > situations. On the other side, many scripts I've seen (including mine) > are using the -a option (which is "-dR --preserve=all" with in turn > -d as "--no-dereference --preserve=links") for copying whole directory > tree ... that may be an indication that the default for -r alone is not > that much used. > Anyway, I belief that doing a change aside from this --link patch > would be quite delicate. The general -R dereferencing discussion can continue in 15806. thanks, Pádraig. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 07 09:09:13 2013 Received: (at 15173) by debbugs.gnu.org; 7 Nov 2013 14:09:13 +0000 Received: from localhost ([127.0.0.1]:38861 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeQGm-00064R-JX for submit@debbugs.gnu.org; Thu, 07 Nov 2013 09:09:13 -0500 Received: from ramona.rm-rf.it ([149.154.157.136]:35965) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeQGk-00064A-1Z for 15173@debbugs.gnu.org; Thu, 07 Nov 2013 09:09:10 -0500 Received: from valentina.fdc.rm-rf.it (valentina.fdc.rm-rf.it [192.168.192.1]) by ramona.rm-rf.it (Postfix) with ESMTP id 89544194 for <15173@debbugs.gnu.org>; Thu, 7 Nov 2013 15:09:03 +0100 (CET) Received: from caimano.fdc.rm-rf.it (caimano.fdc.rm-rf.it [192.168.192.17]) by valentina.fdc.rm-rf.it (Postfix) with ESMTP id 8A510210DE for <15173@debbugs.gnu.org>; Thu, 7 Nov 2013 15:09:02 +0100 (CET) Received: from gpiero (uid 1000) (envelope-from gpiero@rm-rf.it) id 3c014 by caimano.fdc.rm-rf.it (DragonFly Mail Agent v0.9); Thu, 07 Nov 2013 15:09:01 +0100 Date: Thu, 7 Nov 2013 15:09:01 +0100 From: Gian Piero Carrubba To: =?utf-8?Q?P=C3=A1draig?= Brady Subject: Re: bug#15173: [cp] --link overrides dereference settings Message-ID: <20131107140901.GB22232@caimano.fdc.rm-rf.it> References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <527B67ED.7050303@draigBrady.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Bernhard Voelker , Eric Blake , Jim Meyering , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) * [Thu, Nov 07, 2013 at 10:14:05AM +0000] Pádraig Brady: >On 11/07/2013 07:07 AM, Bernhard Voelker wrote: >> Okay, so we're leaving the ground of the GNU extension --link here. > >Yes. >I think the --link case should be considered separately (with and without -R). >I.E. IMHO your current patch is fine and good. Fair enough. In this case please also update the documentation. Maybe something like the following could be enough (please re-word it in order to let it intelligible) ? --- old-issue-15173/doc/coreutils.texi 2013-11-07 14:07:35.139997551 +0100 +++ new-issue-15173/doc/coreutils.texi 2013-11-07 14:07:35.143997573 +0100 @@ -8052,8 +8052,8 @@ to corresponding destination directories. When copying from a symbolic link, @command{cp} normally follows the -link only when not copying -recursively. This default can be overridden with the +link only when not copying recursively or when @option{--link} +(@option{-l}) is used. This default can be overridden with the @option{--archive} (@option{-a}), @option{-d}, @option{--dereference} (@option{-L}), @option{--no-dereference} (@option{-P}), and @option{-H} options. If more than one of these options is specified, @@ -8327,7 +8327,8 @@ @cindex recursively copying directories @cindex non-directories, copying as special files Copy directories recursively. By default, do not follow symbolic -links in the source; see the @option{--archive} (@option{-a}), @option{-d}, +links in the source unless used together with the @option{--link} +(@option{-l}) option; see the @option{--archive} (@option{-a}), @option{-d}, @option{--dereference} (@option{-L}), @option{--no-dereference} (@option{-P}), and @option{-H} options. Special files are copied by creating a destination file of the same type as the source; see the Ciao, Gian Piero. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 07 10:25:57 2013 Received: (at 15173) by debbugs.gnu.org; 7 Nov 2013 15:25:57 +0000 Received: from localhost ([127.0.0.1]:39379 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeRT3-00089l-E1 for submit@debbugs.gnu.org; Thu, 07 Nov 2013 10:25:57 -0500 Received: from mail-pd0-f182.google.com ([209.85.192.182]:51805) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeRSy-00089M-4M for 15173@debbugs.gnu.org; Thu, 07 Nov 2013 10:25:53 -0500 Received: by mail-pd0-f182.google.com with SMTP id q10so737373pdj.13 for <15173@debbugs.gnu.org>; Thu, 07 Nov 2013 07:25:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=bDo/qoefyuHEt8a/IUNCvkRoFqDbymFEaaD/v6y+Wmc=; b=JSg7vRPPDyKmorOwdHWE22za0R7C8TQRyTWFKokToKjn6Z2AzcgSpRSKMamOZEna/t CLoQHUfBDUhFscFzYjNt9I7rC/sfJjCm5HWwBIb6eAnexid8WthgZkeF6CThHhDfIXiy SzHqGCLnjlzYvQ451gwCEgGtlA/nOS/KtCj2otv90WQ5cL1Gw+JCXDigf6LoeKMnNGXk nkPh3Avh4FkH8lvDrmY3do8lBrKD4yVzF0QxW3+p+Ea9AeHenNGZLLFuHQov5bjmhWMs K70XqDnGhUE6O9WNIYZMXBRO+MBSCkVBSpN5Ade1WmrRP+xN3UBZnoQ1QITYtL0yq0U2 9hXg== X-Received: by 10.68.135.100 with SMTP id pr4mr9777550pbb.62.1383837946205; Thu, 07 Nov 2013 07:25:46 -0800 (PST) MIME-Version: 1.0 Received: by 10.68.6.66 with HTTP; Thu, 7 Nov 2013 07:25:25 -0800 (PST) In-Reply-To: <527B3C1F.1020400@bernhard-voelker.de> References: <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> From: Jim Meyering Date: Thu, 7 Nov 2013 07:25:25 -0800 X-Google-Sender-Auth: -qJvvhC9mR_cKn5rhEvpFFq7_MA Message-ID: Subject: Re: bug#15173: [cp] --link overrides dereference settings To: Bernhard Voelker Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , Eric Blake , =?ISO-8859-1?Q?P=E1draig_Brady?= , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Wed, Nov 6, 2013 at 11:07 PM, Bernhard Voelker wrote: > [I was hoping that someone with more coreutils history > was jumping in here - adding Jim for that matter.] Hi Berny, I don't have enough context (12 years is a long time) yet, but would guess that the current behavior was driven by an attempt to be consistent with one of the *BSD implementations. Does the current behavior conflict with POSIX or disagree with how other implementations work? I haven't been following this thread closely. Jim From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 07 12:09:00 2013 Received: (at 15173) by debbugs.gnu.org; 7 Nov 2013 17:09:00 +0000 Received: from localhost ([127.0.0.1]:39551 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeT4l-0002FM-Ug for submit@debbugs.gnu.org; Thu, 07 Nov 2013 12:09:00 -0500 Received: from moutng.kundenserver.de ([212.227.17.10]:50555) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeT4j-0002F7-7C for 15173@debbugs.gnu.org; Thu, 07 Nov 2013 12:08:58 -0500 Received: from [192.168.1.11] (p5499C6C3.dip0.t-ipconnect.de [84.153.198.195]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0LgNIi-1W1U9M30Fg-00oBlK; Thu, 07 Nov 2013 18:08:48 +0100 Message-ID: <527BC91F.1030008@bernhard-voelker.de> Date: Thu, 07 Nov 2013 18:08:47 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Jim Meyering Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:JDeeP8AUfyJcugAiswuRQEuerfYyCS5uHJqgGHxbcbQ hIUlaAxw4TAqwUHQwUGV7kF3d1b4BgKr3CIQupxglVj7PiYmzu kpIl4XnjNkj5/TOb6wfGMA/Yxdw5xt8f3vBe/Z3tHIBNTYF31J 85zTZg0L5vYM7YIUe9oFutxOfEIqJsrNICUpZSt1BYOLsrUFbs Apf7mEeTBd4HEmU3hO0yCkOEfXHKuG6PzfxIAu/PaXgOv0WpwP 6yDmiulb7tsxePm64pEM5ef9Ty2OQSdfpQmol6WNftckbPUqLa gb0JX4Rve2Cw7QilfCvJBovx0vNkYjuV+rJrxvmKUf9ZQxIgav 1ukL+85hGoX+7wGhenuQT23VCQGNj6voPoztu3GQE X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , Eric Blake , =?ISO-8859-1?Q?P=E1draig_Bra?= =?ISO-8859-1?Q?dy?= , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 11/07/2013 04:25 PM, Jim Meyering wrote: > Does the current behavior conflict with POSIX or > disagree with how other implementations work? Hi Jim, no, it doesn't conflict with POSIX, and for the --link case (this thread) I think we have found consensus. The problem is - unfortunately in the other bug#15806 [1] that rm behaves differently regarding the dereferencing (or not) of symbolic links when the -r option is specified (or not). The BSDs seem to also dereference without -r. [1] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15806 (I hope I got it summarized right - I'm in a hurry.) Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 07 12:23:30 2013 Received: (at 15173) by debbugs.gnu.org; 7 Nov 2013 17:23:30 +0000 Received: from localhost ([127.0.0.1]:39567 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeTIn-0002aT-B4 for submit@debbugs.gnu.org; Thu, 07 Nov 2013 12:23:29 -0500 Received: from mail-pd0-f178.google.com ([209.85.192.178]:57045) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeTIl-0002aE-GZ for 15173@debbugs.gnu.org; Thu, 07 Nov 2013 12:23:28 -0500 Received: by mail-pd0-f178.google.com with SMTP id x10so899630pdj.9 for <15173@debbugs.gnu.org>; Thu, 07 Nov 2013 09:23:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=eMXc7jD7lbT1IU4oRN/pkXqc2saluHXLk9hyysAoe+4=; b=IQ9zXgyElhRe+dW4evE7LE2GRCV1tG3eqZAwGsf82AYDj1DJc+ABLqaGNzyTu0jlgl C1QRo1l+5hYid6vPIttuhrpB75SObD4QKAUmPdP3Mex1V56KBeI8PjTO3zSGnhk/nqsS AQQfDhQxXmhcTFxZ5ZRElRzNJsQVXHZNMkXzsojrMKsIlVDakeFT1a46BYVyGK3gIB8E u96yURMrxuROSOk83a4rq5tX1xq99voBSrnUCA7UmjUG2ELCrd1DL0ByG8EyMl5D8CQW qUxnj1F1gpbbSMyBE0nezS5xh4GBzDL0+MN54vhazNXbKZ+7ZnL583fbCPHE4Lofl+Vx jB7g== X-Received: by 10.66.218.226 with SMTP id pj2mr10902866pac.62.1383845001488; Thu, 07 Nov 2013 09:23:21 -0800 (PST) MIME-Version: 1.0 Received: by 10.68.6.66 with HTTP; Thu, 7 Nov 2013 09:23:01 -0800 (PST) In-Reply-To: <527BC91F.1030008@bernhard-voelker.de> References: <52632DA8.6080405@bernhard-voelker.de> <526FFE26.9020704@draigBrady.com> <737687497.219518.1383135238736.open-xchange@email.1und1.de> <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527BC91F.1030008@bernhard-voelker.de> From: Jim Meyering Date: Thu, 7 Nov 2013 09:23:01 -0800 X-Google-Sender-Auth: jKzWsByS6YeABRKkrU4BtY3T6Ks Message-ID: Subject: Re: bug#15173: [cp] --link overrides dereference settings To: Bernhard Voelker Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: Gian Piero Carrubba , Eric Blake , =?ISO-8859-1?Q?P=E1draig_Brady?= , 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Thu, Nov 7, 2013 at 9:08 AM, Bernhard Voelker wrote: > On 11/07/2013 04:25 PM, Jim Meyering wrote: >> Does the current behavior conflict with POSIX or >> disagree with how other implementations work? > > Hi Jim, > > no, it doesn't conflict with POSIX, and for the --link case > (this thread) I think we have found consensus. > > The problem is - unfortunately in the other bug#15806 [1] > that rm behaves differently regarding the dereferencing (or not) > of symbolic links when the -r option is specified (or not). > The BSDs seem to also dereference without -r. > > [1] http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15806 Right. Thanks for the summary. I was referring to the -R-vs-deref issue but hadn't read the original report carefully. I will follow up on that thread. From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 07 17:59:47 2013 Received: (at 15173-done) by debbugs.gnu.org; 7 Nov 2013 22:59:47 +0000 Received: from localhost ([127.0.0.1]:40139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeYYF-0004dC-Cd for submit@debbugs.gnu.org; Thu, 07 Nov 2013 17:59:47 -0500 Received: from moutng.kundenserver.de ([212.227.126.186]:56262) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VeYYC-0004cw-FN for 15173-done@debbugs.gnu.org; Thu, 07 Nov 2013 17:59:45 -0500 Received: from [192.168.1.11] (p5499C6C3.dip0.t-ipconnect.de [84.153.198.195]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0Mhh2N-1VJQl026YF-00Mvyk; Thu, 07 Nov 2013 23:59:29 +0100 Message-ID: <527C1B50.20708@bernhard-voelker.de> Date: Thu, 07 Nov 2013 23:59:28 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Gian Piero Carrubba Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> In-Reply-To: <20131107140901.GB22232@caimano.fdc.rm-rf.it> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:ED5cLNwLirlfVcd+P29CBoTrRg/IgLvRq0qIoTq2lS/ 3pwVy/UwSCXLz/Pn9AG0Jb3f3wSKBDk4tezAjMSUDAs5l1f69w Gxdw1jsqNSvV5DeV1grE0cM49Ty/ogpllhtQzcwwZhX2de5Vo5 lgZDrKc0OoxR0icPY0BgKvOCEWJ0vAXCGn82Ikzps8mPE6RATe q9XE2/xuKqc1hqisx+c8jKEY4M2sd1XUewr1kQXcsANy+eu2CJ p1zsQBY5IBoVMUTQLKMAT8WpCOLpEMe0UROo1wqhUDVRvB0dXL J8DLDTdFNZLqbO5VI02yHNYmgiX6MuX6qw0YOsU/Xz63xn8VGh Aba+VFOOfftgbu/4bVe3yE6BIhldtALs6l8ux4OF6 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15173-done Cc: Eric Blake , =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= , Jim Meyering , 15173-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 11/07/2013 03:09 PM, Gian Piero Carrubba wrote: > * [Thu, Nov 07, 2013 at 10:14:05AM +0000] Pádraig Brady: >> I.E. IMHO your current patch is fine and good. > > Fair enough. In this case please also update the documentation. Good idea, thanks. I pushed it in your name (together with Padraig's notes regarding NEWS and the test case): http://git.sv.gnu.org/cgit/coreutils.git/commit/?id=bf6bf52d I'm hereby marking the bug as done. Thanks again. Have a nice day, Berny From unknown Fri Jun 20 07:15:39 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 06 Dec 2013 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 20:25:04 2013 Received: (at control) by debbugs.gnu.org; 9 Dec 2013 01:25:04 +0000 Received: from localhost ([127.0.0.1]:39017 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vppan-0006KY-J1 for submit@debbugs.gnu.org; Sun, 08 Dec 2013 20:25:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:27886) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Vppag-0006KA-6f; Sun, 08 Dec 2013 20:24:56 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rB91Ooxm014288 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 8 Dec 2013 20:24:50 -0500 Received: from [10.36.116.43] (ovpn-116-43.ams2.redhat.com [10.36.116.43]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rB91Okm9018692 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 8 Dec 2013 20:24:48 -0500 Message-ID: <52A51BDE.3030200@draigBrady.com> Date: Mon, 09 Dec 2013 01:24:46 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: 15173@debbugs.gnu.org Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> <527C1B50.20708@bernhard-voelker.de> In-Reply-To: <527C1B50.20708@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------080506080300040508040202" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: control Cc: Bernhard Voelker , Eric Blake X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) This is a multi-part message in MIME format. --------------080506080300040508040202 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit unarchive 15173 stop The test for this is failing on solaris 10 (NFS) It does seem that hardlinks to symlinks are supported: $ touch tfile $ ln -s tfile tlink $ src/ln -L tlink tlink-ln-L $ src/ln -P tlink tlink-ln-P $ src/ln tlink tlink-ln $ ls -li tfile tlink* 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tfile 8551 lrwxrwxrwx 2 padraig csw 5 Dec 9 01:19 tlink -> tfile 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tlink-ln 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tlink-ln-L 8551 lrwxrwxrwx 2 padraig csw 5 Dec 9 01:19 tlink-ln-P -> tfile But we have linkat() emulation in place I think: $ grep LINK lib/config.h /* #undef CHOWN_MODIFIES_SYMLINK */ #define GNULIB_AREADLINKAT 1 #define GNULIB_TEST_LINK 1 #define GNULIB_TEST_LINKAT 1 #define GNULIB_TEST_READLINK 1 #define GNULIB_TEST_READLINKAT 1 #define GNULIB_TEST_SYMLINK 1 #define GNULIB_TEST_SYMLINKAT 1 #define GNULIB_TEST_UNLINK 1 #define GNULIB_TEST_UNLINKAT 1 #define HAVE_LINK 1 /* #undef HAVE_LINKAT */ #define HAVE_READLINK 1 /* #undef HAVE_READLINKAT */ #define HAVE_SYMLINK 1 /* #undef HAVE_SYMLINKAT */ #define HAVE_UNLINKAT 1 /* #undef LINKAT_TRAILING_SLASH_BUG */ #define LINK_FOLLOWS_SYMLINKS -1 #define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 #define PIPE_LINK_COUNT_MAX (0) /* #undef READLINK_TRAILING_SLASH_BUG */ /* #undef RENAME_HARD_LINK_BUG */ /* #undef UNLINK_CANNOT_UNLINK_DIR */ /* #undef UNLINK_PARENT_BUG */ I've attached the verbose log for the test, as I've not time to look into it at present. thanks, Pádraig. --------------080506080300040508040202 Content-Type: text/x-log; name="test-suite.log" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="test-suite.log" ========================================================== GNU coreutils 8.21.176-37e00: ./tests/test-suite.log ========================================================== # TOTAL: 1 # PASS: 0 # SKIP: 0 # XFAIL: 0 # FAIL: 1 # XPASS: 0 # ERROR: 0 .. contents:: :depth: 2 FAIL: tests/cp/link-deref ========================= ++ initial_cwd_=/home/padraig/coreutils-8.21.176-37e00 ++ fail=0 +++ testdir_prefix_ +++ printf gt ++ pfx_=gt +++ mktempd_ /home/padraig/coreutils-8.21.176-37e00 gt-link-deref.sh.XXXX +++ case $# in +++ destdir_=/home/padraig/coreutils-8.21.176-37e00 +++ template_=gt-link-deref.sh.XXXX +++ MAX_TRIES_=4 +++ case $destdir_ in +++ case $template_ in ++++ unset TMPDIR +++ d=/home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP +++ case $d in +++ test -d /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP ++++ ls -dgo /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP ++++ tr S - +++ perms='drwx------ 2 2 Dec 9 01:00 /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP' +++ case $perms in +++ test 0 = 0 +++ echo /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP +++ return ++ test_dir_=/home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP ++ cd /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP ++ gl_init_sh_nl_=' ' ++ IFS=' ' ++ for sig_ in 1 2 3 13 15 +++ expr 1 + 128 ++ eval 'trap '\''Exit 129'\'' 1' +++ trap 'Exit 129' 1 ++ for sig_ in 1 2 3 13 15 +++ expr 2 + 128 ++ eval 'trap '\''Exit 130'\'' 2' +++ trap 'Exit 130' 2 ++ for sig_ in 1 2 3 13 15 +++ expr 3 + 128 ++ eval 'trap '\''Exit 131'\'' 3' +++ trap 'Exit 131' 3 ++ for sig_ in 1 2 3 13 15 +++ expr 13 + 128 ++ eval 'trap '\''Exit 141'\'' 13' +++ trap 'Exit 141' 13 ++ for sig_ in 1 2 3 13 15 +++ expr 15 + 128 ++ eval 'trap '\''Exit 143'\'' 15' +++ trap 'Exit 143' 15 ++ trap remove_tmp_ 0 + path_prepend_ ./src + test 1 '!=' 0 + path_dir_=./src + case $path_dir_ in + abs_path_dir_=/home/padraig/coreutils-8.21.176-37e00/./src + case $abs_path_dir_ in + PATH=/home/padraig/coreutils-8.21.176-37e00/./src:/home/padraig/coreutils-8.21.176-37e00/src:/usr/xpg4/bin:/usr/bin:/usr/sbin:/sbin:/usr/ccs/bin:/usr/dt/bin:/usr/openwin/bin:/opt/RICHPse/bin:/opt/bop/bin:/opt/csw/bin:/usr/sfw/bin:/usr/sfw/sbin + create_exe_shims_ /home/padraig/coreutils-8.21.176-37e00/./src + case $EXEEXT in + return 0 + shift + test 0 '!=' 0 + export PATH + print_ver_ cp + test yes = yes + local i + for i in '$*' + env cp --version cp (GNU coreutils) 8.21.176-37e00 Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering. + mkdir dir + : + ln -s dir dirlink + ln -s file filelink + ln -s nowhere danglink + outformat='%s|result=%s|inode=%s|type=%s|error=%s\n' + for src in dirlink filelink danglink ++ readlink dirlink + tgt=dir ++ stat -c %i dirlink + ino_src=8436 ++ stat -c %F dirlink + typ_src='symbolic link' ++ stat -c %i dir + ino_tgt=8434 ++ stat -c %F dir + typ_tgt=directory + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link dirlink dst' + cp --link dirlink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link dirlink dst' 1 '' '' 'cp: omitting directory '\''dirlink'\''' + '[' '' = -P ']' + '[' dirlink = danglink ']' + '[' dirlink = dirlink ']' + '[' '' '!=' -R ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: omitting directory '\''dirlink'\''' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link dirlink dst' 1 '' '' 'cp: omitting directory '\''dirlink'\''' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -R dirlink dst' + cp --link -R dirlink dst + result=0 ++ stat -c %i dst + ino_dst=8444 ++ stat -c %F dst + typ_dst=directory ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -R dirlink dst' 0 8444 directory '' + '[' '' = -P ']' + '[' dirlink = danglink ']' + '[' dirlink = dirlink ']' + '[' -R '!=' -R ']' + '[' dirlink = dirlink ']' + exp_result=0 + exp_inode=8444 + exp_ftype=directory + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -R dirlink dst' 0 8444 directory '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -L dirlink dst' + cp --link -L dirlink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L dirlink dst' 1 '' '' 'cp: omitting directory '\''dirlink'\''' + '[' -L = -P ']' + '[' dirlink = danglink ']' + '[' dirlink = dirlink ']' + '[' '' '!=' -R ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: omitting directory '\''dirlink'\''' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L dirlink dst' 1 '' '' 'cp: omitting directory '\''dirlink'\''' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -L -R dirlink dst' + cp --link -L -R dirlink dst + result=0 ++ stat -c %i dst + ino_dst=8453 ++ stat -c %F dst + typ_dst=directory ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L -R dirlink dst' 0 8453 directory '' + '[' -L = -P ']' + '[' dirlink = danglink ']' + '[' dirlink = dirlink ']' + '[' -R '!=' -R ']' + '[' dirlink = dirlink ']' + exp_result=0 + exp_inode=8453 + exp_ftype=directory + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L -R dirlink dst' 0 8453 directory '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -H dirlink dst' + cp --link -H dirlink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H dirlink dst' 1 '' '' 'cp: omitting directory '\''dirlink'\''' + '[' -H = -P ']' + '[' dirlink = danglink ']' + '[' dirlink = dirlink ']' + '[' '' '!=' -R ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: omitting directory '\''dirlink'\''' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H dirlink dst' 1 '' '' 'cp: omitting directory '\''dirlink'\''' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -H -R dirlink dst' + cp --link -H -R dirlink dst + result=0 ++ stat -c %i dst + ino_dst=8462 ++ stat -c %F dst + typ_dst=directory ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H -R dirlink dst' 0 8462 directory '' + '[' -H = -P ']' + '[' dirlink = danglink ']' + '[' dirlink = dirlink ']' + '[' -R '!=' -R ']' + '[' dirlink = dirlink ']' + exp_result=0 + exp_inode=8462 + exp_ftype=directory + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H -R dirlink dst' 0 8462 directory '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -P dirlink dst' + cp --link -P dirlink dst + result=0 ++ stat -c %i dst + ino_dst=8467 ++ stat -c %F dst + typ_dst='symbolic link' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P dirlink dst' 0 8467 'symbolic link' '' + '[' -P = -P ']' + exp_result=0 + exp_inode=8436 + exp_ftype='symbolic link' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P dirlink dst' 0 8436 'symbolic link' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + cat diff.out --- exp Mon Dec 9 01:00:08 2013 +++ out Mon Dec 9 01:00:08 2013 @@ -1,1 +1,1 @@ -cp --link -P dirlink dst|result=0|inode=8436|type=symbolic link|error= +cp --link -P dirlink dst|result=0|inode=8467|type=symbolic link|error= + rm -f diff.out + false + ls -lid dirlink dir dst 8434 drwxr-xr-x 2 padraig csw 2 Dec 9 01:00 dir 8436 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dirlink -> dir 8467 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dst -> dir + fail=1 + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -P -R dirlink dst' + cp --link -P -R dirlink dst + result=0 ++ stat -c %i dst + ino_dst=8472 ++ stat -c %F dst + typ_dst='symbolic link' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P -R dirlink dst' 0 8472 'symbolic link' '' + '[' -P = -P ']' + exp_result=0 + exp_inode=8436 + exp_ftype='symbolic link' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P -R dirlink dst' 0 8436 'symbolic link' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + cat diff.out --- exp Mon Dec 9 01:00:09 2013 +++ out Mon Dec 9 01:00:09 2013 @@ -1,1 +1,1 @@ -cp --link -P -R dirlink dst|result=0|inode=8436|type=symbolic link|error= +cp --link -P -R dirlink dst|result=0|inode=8472|type=symbolic link|error= + rm -f diff.out + false + ls -lid dirlink dir dst 8434 drwxr-xr-x 2 padraig csw 2 Dec 9 01:00 dir 8436 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dirlink -> dir 8472 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dst -> dir + fail=1 + rm -rf dst err exp out + for src in dirlink filelink danglink ++ readlink filelink + tgt=file ++ stat -c %i filelink + ino_src=8437 ++ stat -c %F filelink + typ_src='symbolic link' ++ stat -c %i file + ino_tgt=8435 ++ stat -c %F file + typ_tgt='regular empty file' + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link filelink dst' + cp --link filelink dst + result=0 ++ stat -c %i dst + ino_dst=8435 ++ stat -c %F dst + typ_dst='regular empty file' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link filelink dst' 0 8435 'regular empty file' '' + '[' '' = -P ']' + '[' filelink = danglink ']' + '[' filelink = dirlink ']' + '[' filelink = dirlink ']' + exp_result=0 + exp_inode=8435 + exp_ftype='regular empty file' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link filelink dst' 0 8435 'regular empty file' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -R filelink dst' + cp --link -R filelink dst + result=0 ++ stat -c %i dst + ino_dst=8435 ++ stat -c %F dst + typ_dst='regular empty file' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -R filelink dst' 0 8435 'regular empty file' '' + '[' '' = -P ']' + '[' filelink = danglink ']' + '[' filelink = dirlink ']' + '[' filelink = dirlink ']' + exp_result=0 + exp_inode=8435 + exp_ftype='regular empty file' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -R filelink dst' 0 8435 'regular empty file' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -L filelink dst' + cp --link -L filelink dst + result=0 ++ stat -c %i dst + ino_dst=8435 ++ stat -c %F dst + typ_dst='regular empty file' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L filelink dst' 0 8435 'regular empty file' '' + '[' -L = -P ']' + '[' filelink = danglink ']' + '[' filelink = dirlink ']' + '[' filelink = dirlink ']' + exp_result=0 + exp_inode=8435 + exp_ftype='regular empty file' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L filelink dst' 0 8435 'regular empty file' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -L -R filelink dst' + cp --link -L -R filelink dst + result=0 ++ stat -c %i dst + ino_dst=8435 ++ stat -c %F dst + typ_dst='regular empty file' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L -R filelink dst' 0 8435 'regular empty file' '' + '[' -L = -P ']' + '[' filelink = danglink ']' + '[' filelink = dirlink ']' + '[' filelink = dirlink ']' + exp_result=0 + exp_inode=8435 + exp_ftype='regular empty file' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L -R filelink dst' 0 8435 'regular empty file' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -H filelink dst' + cp --link -H filelink dst + result=0 ++ stat -c %i dst + ino_dst=8435 ++ stat -c %F dst + typ_dst='regular empty file' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H filelink dst' 0 8435 'regular empty file' '' + '[' -H = -P ']' + '[' filelink = danglink ']' + '[' filelink = dirlink ']' + '[' filelink = dirlink ']' + exp_result=0 + exp_inode=8435 + exp_ftype='regular empty file' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H filelink dst' 0 8435 'regular empty file' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -H -R filelink dst' + cp --link -H -R filelink dst + result=0 ++ stat -c %i dst + ino_dst=8435 ++ stat -c %F dst + typ_dst='regular empty file' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H -R filelink dst' 0 8435 'regular empty file' '' + '[' -H = -P ']' + '[' filelink = danglink ']' + '[' filelink = dirlink ']' + '[' filelink = dirlink ']' + exp_result=0 + exp_inode=8435 + exp_ftype='regular empty file' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H -R filelink dst' 0 8435 'regular empty file' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -P filelink dst' + cp --link -P filelink dst + result=0 ++ stat -c %i dst + ino_dst=8502 ++ stat -c %F dst + typ_dst='symbolic link' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P filelink dst' 0 8502 'symbolic link' '' + '[' -P = -P ']' + exp_result=0 + exp_inode=8437 + exp_ftype='symbolic link' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P filelink dst' 0 8437 'symbolic link' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + cat diff.out --- exp Mon Dec 9 01:00:09 2013 +++ out Mon Dec 9 01:00:09 2013 @@ -1,1 +1,1 @@ -cp --link -P filelink dst|result=0|inode=8437|type=symbolic link|error= +cp --link -P filelink dst|result=0|inode=8502|type=symbolic link|error= + rm -f diff.out + false + ls -lid filelink file dst 8502 lrwxrwxrwx 1 padraig csw 4 Dec 9 01:00 dst -> file 8435 -rw-r--r-- 1 padraig csw 0 Dec 9 01:00 file 8437 lrwxrwxrwx 1 padraig csw 4 Dec 9 01:00 filelink -> file + fail=1 + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -P -R filelink dst' + cp --link -P -R filelink dst + result=0 ++ stat -c %i dst + ino_dst=8507 ++ stat -c %F dst + typ_dst='symbolic link' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P -R filelink dst' 0 8507 'symbolic link' '' + '[' -P = -P ']' + exp_result=0 + exp_inode=8437 + exp_ftype='symbolic link' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P -R filelink dst' 0 8437 'symbolic link' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + cat diff.out --- exp Mon Dec 9 01:00:10 2013 +++ out Mon Dec 9 01:00:10 2013 @@ -1,1 +1,1 @@ -cp --link -P -R filelink dst|result=0|inode=8437|type=symbolic link|error= +cp --link -P -R filelink dst|result=0|inode=8507|type=symbolic link|error= + rm -f diff.out + false + ls -lid filelink file dst 8507 lrwxrwxrwx 1 padraig csw 4 Dec 9 01:00 dst -> file 8435 -rw-r--r-- 1 padraig csw 0 Dec 9 01:00 file 8437 lrwxrwxrwx 1 padraig csw 4 Dec 9 01:00 filelink -> file + fail=1 + rm -rf dst err exp out + for src in dirlink filelink danglink ++ readlink danglink + tgt=nowhere ++ stat -c %i danglink + ino_src=8438 ++ stat -c %F danglink + typ_src='symbolic link' ++ stat -c %i nowhere + ino_tgt= + ino_tgt= ++ stat -c %F nowhere + typ_tgt= + typ_tgt= + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link danglink dst' + cp --link danglink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + '[' '' = -P ']' + '[' danglink = danglink ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: cannot stat '\''danglink'\'': No such file or directory' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -R danglink dst' + cp --link -R danglink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -R danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + '[' '' = -P ']' + '[' danglink = danglink ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: cannot stat '\''danglink'\'': No such file or directory' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -R danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -L danglink dst' + cp --link -L danglink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + '[' -L = -P ']' + '[' danglink = danglink ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: cannot stat '\''danglink'\'': No such file or directory' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -L -R danglink dst' + cp --link -L -R danglink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L -R danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + '[' -L = -P ']' + '[' danglink = danglink ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: cannot stat '\''danglink'\'': No such file or directory' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L -R danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -H danglink dst' + cp --link -H danglink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + '[' -H = -P ']' + '[' danglink = danglink ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: cannot stat '\''danglink'\'': No such file or directory' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -H -R danglink dst' + cp --link -H -R danglink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H -R danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + '[' -H = -P ']' + '[' danglink = danglink ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: cannot stat '\''danglink'\'': No such file or directory' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H -R danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -P danglink dst' + cp --link -P danglink dst + result=0 ++ stat -c %i dst + ino_dst=8536 ++ stat -c %F dst + typ_dst='symbolic link' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P danglink dst' 0 8536 'symbolic link' '' + '[' -P = -P ']' + exp_result=0 + exp_inode=8438 + exp_ftype='symbolic link' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P danglink dst' 0 8438 'symbolic link' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + cat diff.out --- exp Mon Dec 9 01:00:10 2013 +++ out Mon Dec 9 01:00:10 2013 @@ -1,1 +1,1 @@ -cp --link -P danglink dst|result=0|inode=8438|type=symbolic link|error= +cp --link -P danglink dst|result=0|inode=8536|type=symbolic link|error= + rm -f diff.out + false + ls -lid danglink nowhere dst ls: cannot access nowhere: No such file or directory 8438 lrwxrwxrwx 1 padraig csw 7 Dec 9 01:00 danglink -> nowhere 8536 lrwxrwxrwx 1 padraig csw 7 Dec 9 01:00 dst -> nowhere + fail=1 + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -P -R danglink dst' + cp --link -P -R danglink dst + result=0 ++ stat -c %i dst + ino_dst=8541 ++ stat -c %F dst + typ_dst='symbolic link' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P -R danglink dst' 0 8541 'symbolic link' '' + '[' -P = -P ']' + exp_result=0 + exp_inode=8438 + exp_ftype='symbolic link' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P -R danglink dst' 0 8438 'symbolic link' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + cat diff.out --- exp Mon Dec 9 01:00:10 2013 +++ out Mon Dec 9 01:00:10 2013 @@ -1,1 +1,1 @@ -cp --link -P -R danglink dst|result=0|inode=8438|type=symbolic link|error= +cp --link -P -R danglink dst|result=0|inode=8541|type=symbolic link|error= + rm -f diff.out + false + ls -lid danglink nowhere dst ls: cannot access nowhere: No such file or directory 8438 lrwxrwxrwx 1 padraig csw 7 Dec 9 01:00 danglink -> nowhere 8541 lrwxrwxrwx 1 padraig csw 7 Dec 9 01:00 dst -> nowhere + fail=1 + rm -rf dst err exp out + Exit 1 + set +e + exit 1 + exit 1 + remove_tmp_ + __st=1 + cleanup_ + : + cd /home/padraig/coreutils-8.21.176-37e00 + chmod -R u+rwx /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP + rm -rf /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP + exit 1 --------------080506080300040508040202-- From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 08 21:24:58 2013 Received: (at 15173) by debbugs.gnu.org; 9 Dec 2013 02:25:00 +0000 Received: from localhost ([127.0.0.1]:39077 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VpqWj-0000X3-KZ for submit@debbugs.gnu.org; Sun, 08 Dec 2013 21:24:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34399) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VpqWf-0000Wo-7w for 15173@debbugs.gnu.org; Sun, 08 Dec 2013 21:24:52 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rB92Olaq007851 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for <15173@debbugs.gnu.org>; Sun, 8 Dec 2013 21:24:48 -0500 Received: from [10.36.116.43] (ovpn-116-43.ams2.redhat.com [10.36.116.43]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rB92OjYe026426 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO) for <15173@debbugs.gnu.org>; Sun, 8 Dec 2013 21:24:46 -0500 Message-ID: <52A529EC.8000305@draigBrady.com> Date: Mon, 09 Dec 2013 02:24:44 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: 15173@debbugs.gnu.org Subject: Re: bug#15173: [cp] --link overrides dereference settings References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> <527C1B50.20708@bernhard-voelker.de> In-Reply-To: <527C1B50.20708@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------020505050100020700000003" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 15173 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) This is a multi-part message in MIME format. --------------020505050100020700000003 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sorry if you get multiple copies of this. The test for this is failing on solaris 10 (NFS) It does seem that hardlinks to symlinks are supported: $ touch tfile $ ln -s tfile tlink $ src/ln -L tlink tlink-ln-L $ src/ln -P tlink tlink-ln-P $ src/ln tlink tlink-ln $ ls -li tfile tlink* 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tfile 8551 lrwxrwxrwx 2 padraig csw 5 Dec 9 01:19 tlink -> tfile 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tlink-ln 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tlink-ln-L 8551 lrwxrwxrwx 2 padraig csw 5 Dec 9 01:19 tlink-ln-P -> tfile But we have linkat() emulation in place I think: $ grep LINK lib/config.h /* #undef CHOWN_MODIFIES_SYMLINK */ #define GNULIB_AREADLINKAT 1 #define GNULIB_TEST_LINK 1 #define GNULIB_TEST_LINKAT 1 #define GNULIB_TEST_READLINK 1 #define GNULIB_TEST_READLINKAT 1 #define GNULIB_TEST_SYMLINK 1 #define GNULIB_TEST_SYMLINKAT 1 #define GNULIB_TEST_UNLINK 1 #define GNULIB_TEST_UNLINKAT 1 #define HAVE_LINK 1 /* #undef HAVE_LINKAT */ #define HAVE_READLINK 1 /* #undef HAVE_READLINKAT */ #define HAVE_SYMLINK 1 /* #undef HAVE_SYMLINKAT */ #define HAVE_UNLINKAT 1 /* #undef LINKAT_TRAILING_SLASH_BUG */ #define LINK_FOLLOWS_SYMLINKS -1 #define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 #define PIPE_LINK_COUNT_MAX (0) /* #undef READLINK_TRAILING_SLASH_BUG */ /* #undef RENAME_HARD_LINK_BUG */ /* #undef UNLINK_CANNOT_UNLINK_DIR */ /* #undef UNLINK_PARENT_BUG */ I've attached the verbose log for the test, as I've not time to look into it at present. thanks, Pádraig. --------------020505050100020700000003 Content-Type: text/x-log; name="test-suite.log" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="test-suite.log" ========================================================== GNU coreutils 8.21.176-37e00: ./tests/test-suite.log ========================================================== # TOTAL: 1 # PASS: 0 # SKIP: 0 # XFAIL: 0 # FAIL: 1 # XPASS: 0 # ERROR: 0 .. contents:: :depth: 2 FAIL: tests/cp/link-deref ========================= ++ initial_cwd_=/home/padraig/coreutils-8.21.176-37e00 ++ fail=0 +++ testdir_prefix_ +++ printf gt ++ pfx_=gt +++ mktempd_ /home/padraig/coreutils-8.21.176-37e00 gt-link-deref.sh.XXXX +++ case $# in +++ destdir_=/home/padraig/coreutils-8.21.176-37e00 +++ template_=gt-link-deref.sh.XXXX +++ MAX_TRIES_=4 +++ case $destdir_ in +++ case $template_ in ++++ unset TMPDIR +++ d=/home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP +++ case $d in +++ test -d /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP ++++ ls -dgo /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP ++++ tr S - +++ perms='drwx------ 2 2 Dec 9 01:00 /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP' +++ case $perms in +++ test 0 = 0 +++ echo /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP +++ return ++ test_dir_=/home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP ++ cd /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP ++ gl_init_sh_nl_=' ' ++ IFS=' ' ++ for sig_ in 1 2 3 13 15 +++ expr 1 + 128 ++ eval 'trap '\''Exit 129'\'' 1' +++ trap 'Exit 129' 1 ++ for sig_ in 1 2 3 13 15 +++ expr 2 + 128 ++ eval 'trap '\''Exit 130'\'' 2' +++ trap 'Exit 130' 2 ++ for sig_ in 1 2 3 13 15 +++ expr 3 + 128 ++ eval 'trap '\''Exit 131'\'' 3' +++ trap 'Exit 131' 3 ++ for sig_ in 1 2 3 13 15 +++ expr 13 + 128 ++ eval 'trap '\''Exit 141'\'' 13' +++ trap 'Exit 141' 13 ++ for sig_ in 1 2 3 13 15 +++ expr 15 + 128 ++ eval 'trap '\''Exit 143'\'' 15' +++ trap 'Exit 143' 15 ++ trap remove_tmp_ 0 + path_prepend_ ./src + test 1 '!=' 0 + path_dir_=./src + case $path_dir_ in + abs_path_dir_=/home/padraig/coreutils-8.21.176-37e00/./src + case $abs_path_dir_ in + PATH=/home/padraig/coreutils-8.21.176-37e00/./src:/home/padraig/coreutils-8.21.176-37e00/src:/usr/xpg4/bin:/usr/bin:/usr/sbin:/sbin:/usr/ccs/bin:/usr/dt/bin:/usr/openwin/bin:/opt/RICHPse/bin:/opt/bop/bin:/opt/csw/bin:/usr/sfw/bin:/usr/sfw/sbin + create_exe_shims_ /home/padraig/coreutils-8.21.176-37e00/./src + case $EXEEXT in + return 0 + shift + test 0 '!=' 0 + export PATH + print_ver_ cp + test yes = yes + local i + for i in '$*' + env cp --version cp (GNU coreutils) 8.21.176-37e00 Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering. + mkdir dir + : + ln -s dir dirlink + ln -s file filelink + ln -s nowhere danglink + outformat='%s|result=%s|inode=%s|type=%s|error=%s\n' + for src in dirlink filelink danglink ++ readlink dirlink + tgt=dir ++ stat -c %i dirlink + ino_src=8436 ++ stat -c %F dirlink + typ_src='symbolic link' ++ stat -c %i dir + ino_tgt=8434 ++ stat -c %F dir + typ_tgt=directory + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link dirlink dst' + cp --link dirlink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link dirlink dst' 1 '' '' 'cp: omitting directory '\''dirlink'\''' + '[' '' = -P ']' + '[' dirlink = danglink ']' + '[' dirlink = dirlink ']' + '[' '' '!=' -R ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: omitting directory '\''dirlink'\''' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link dirlink dst' 1 '' '' 'cp: omitting directory '\''dirlink'\''' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -R dirlink dst' + cp --link -R dirlink dst + result=0 ++ stat -c %i dst + ino_dst=8444 ++ stat -c %F dst + typ_dst=directory ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -R dirlink dst' 0 8444 directory '' + '[' '' = -P ']' + '[' dirlink = danglink ']' + '[' dirlink = dirlink ']' + '[' -R '!=' -R ']' + '[' dirlink = dirlink ']' + exp_result=0 + exp_inode=8444 + exp_ftype=directory + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -R dirlink dst' 0 8444 directory '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -L dirlink dst' + cp --link -L dirlink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L dirlink dst' 1 '' '' 'cp: omitting directory '\''dirlink'\''' + '[' -L = -P ']' + '[' dirlink = danglink ']' + '[' dirlink = dirlink ']' + '[' '' '!=' -R ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: omitting directory '\''dirlink'\''' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L dirlink dst' 1 '' '' 'cp: omitting directory '\''dirlink'\''' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -L -R dirlink dst' + cp --link -L -R dirlink dst + result=0 ++ stat -c %i dst + ino_dst=8453 ++ stat -c %F dst + typ_dst=directory ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L -R dirlink dst' 0 8453 directory '' + '[' -L = -P ']' + '[' dirlink = danglink ']' + '[' dirlink = dirlink ']' + '[' -R '!=' -R ']' + '[' dirlink = dirlink ']' + exp_result=0 + exp_inode=8453 + exp_ftype=directory + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L -R dirlink dst' 0 8453 directory '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -H dirlink dst' + cp --link -H dirlink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H dirlink dst' 1 '' '' 'cp: omitting directory '\''dirlink'\''' + '[' -H = -P ']' + '[' dirlink = danglink ']' + '[' dirlink = dirlink ']' + '[' '' '!=' -R ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: omitting directory '\''dirlink'\''' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H dirlink dst' 1 '' '' 'cp: omitting directory '\''dirlink'\''' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -H -R dirlink dst' + cp --link -H -R dirlink dst + result=0 ++ stat -c %i dst + ino_dst=8462 ++ stat -c %F dst + typ_dst=directory ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H -R dirlink dst' 0 8462 directory '' + '[' -H = -P ']' + '[' dirlink = danglink ']' + '[' dirlink = dirlink ']' + '[' -R '!=' -R ']' + '[' dirlink = dirlink ']' + exp_result=0 + exp_inode=8462 + exp_ftype=directory + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H -R dirlink dst' 0 8462 directory '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -P dirlink dst' + cp --link -P dirlink dst + result=0 ++ stat -c %i dst + ino_dst=8467 ++ stat -c %F dst + typ_dst='symbolic link' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P dirlink dst' 0 8467 'symbolic link' '' + '[' -P = -P ']' + exp_result=0 + exp_inode=8436 + exp_ftype='symbolic link' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P dirlink dst' 0 8436 'symbolic link' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + cat diff.out --- exp Mon Dec 9 01:00:08 2013 +++ out Mon Dec 9 01:00:08 2013 @@ -1,1 +1,1 @@ -cp --link -P dirlink dst|result=0|inode=8436|type=symbolic link|error= +cp --link -P dirlink dst|result=0|inode=8467|type=symbolic link|error= + rm -f diff.out + false + ls -lid dirlink dir dst 8434 drwxr-xr-x 2 padraig csw 2 Dec 9 01:00 dir 8436 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dirlink -> dir 8467 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dst -> dir + fail=1 + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -P -R dirlink dst' + cp --link -P -R dirlink dst + result=0 ++ stat -c %i dst + ino_dst=8472 ++ stat -c %F dst + typ_dst='symbolic link' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P -R dirlink dst' 0 8472 'symbolic link' '' + '[' -P = -P ']' + exp_result=0 + exp_inode=8436 + exp_ftype='symbolic link' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P -R dirlink dst' 0 8436 'symbolic link' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + cat diff.out --- exp Mon Dec 9 01:00:09 2013 +++ out Mon Dec 9 01:00:09 2013 @@ -1,1 +1,1 @@ -cp --link -P -R dirlink dst|result=0|inode=8436|type=symbolic link|error= +cp --link -P -R dirlink dst|result=0|inode=8472|type=symbolic link|error= + rm -f diff.out + false + ls -lid dirlink dir dst 8434 drwxr-xr-x 2 padraig csw 2 Dec 9 01:00 dir 8436 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dirlink -> dir 8472 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dst -> dir + fail=1 + rm -rf dst err exp out + for src in dirlink filelink danglink ++ readlink filelink + tgt=file ++ stat -c %i filelink + ino_src=8437 ++ stat -c %F filelink + typ_src='symbolic link' ++ stat -c %i file + ino_tgt=8435 ++ stat -c %F file + typ_tgt='regular empty file' + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link filelink dst' + cp --link filelink dst + result=0 ++ stat -c %i dst + ino_dst=8435 ++ stat -c %F dst + typ_dst='regular empty file' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link filelink dst' 0 8435 'regular empty file' '' + '[' '' = -P ']' + '[' filelink = danglink ']' + '[' filelink = dirlink ']' + '[' filelink = dirlink ']' + exp_result=0 + exp_inode=8435 + exp_ftype='regular empty file' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link filelink dst' 0 8435 'regular empty file' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -R filelink dst' + cp --link -R filelink dst + result=0 ++ stat -c %i dst + ino_dst=8435 ++ stat -c %F dst + typ_dst='regular empty file' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -R filelink dst' 0 8435 'regular empty file' '' + '[' '' = -P ']' + '[' filelink = danglink ']' + '[' filelink = dirlink ']' + '[' filelink = dirlink ']' + exp_result=0 + exp_inode=8435 + exp_ftype='regular empty file' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -R filelink dst' 0 8435 'regular empty file' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -L filelink dst' + cp --link -L filelink dst + result=0 ++ stat -c %i dst + ino_dst=8435 ++ stat -c %F dst + typ_dst='regular empty file' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L filelink dst' 0 8435 'regular empty file' '' + '[' -L = -P ']' + '[' filelink = danglink ']' + '[' filelink = dirlink ']' + '[' filelink = dirlink ']' + exp_result=0 + exp_inode=8435 + exp_ftype='regular empty file' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L filelink dst' 0 8435 'regular empty file' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -L -R filelink dst' + cp --link -L -R filelink dst + result=0 ++ stat -c %i dst + ino_dst=8435 ++ stat -c %F dst + typ_dst='regular empty file' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L -R filelink dst' 0 8435 'regular empty file' '' + '[' -L = -P ']' + '[' filelink = danglink ']' + '[' filelink = dirlink ']' + '[' filelink = dirlink ']' + exp_result=0 + exp_inode=8435 + exp_ftype='regular empty file' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L -R filelink dst' 0 8435 'regular empty file' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -H filelink dst' + cp --link -H filelink dst + result=0 ++ stat -c %i dst + ino_dst=8435 ++ stat -c %F dst + typ_dst='regular empty file' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H filelink dst' 0 8435 'regular empty file' '' + '[' -H = -P ']' + '[' filelink = danglink ']' + '[' filelink = dirlink ']' + '[' filelink = dirlink ']' + exp_result=0 + exp_inode=8435 + exp_ftype='regular empty file' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H filelink dst' 0 8435 'regular empty file' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -H -R filelink dst' + cp --link -H -R filelink dst + result=0 ++ stat -c %i dst + ino_dst=8435 ++ stat -c %F dst + typ_dst='regular empty file' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H -R filelink dst' 0 8435 'regular empty file' '' + '[' -H = -P ']' + '[' filelink = danglink ']' + '[' filelink = dirlink ']' + '[' filelink = dirlink ']' + exp_result=0 + exp_inode=8435 + exp_ftype='regular empty file' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H -R filelink dst' 0 8435 'regular empty file' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -P filelink dst' + cp --link -P filelink dst + result=0 ++ stat -c %i dst + ino_dst=8502 ++ stat -c %F dst + typ_dst='symbolic link' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P filelink dst' 0 8502 'symbolic link' '' + '[' -P = -P ']' + exp_result=0 + exp_inode=8437 + exp_ftype='symbolic link' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P filelink dst' 0 8437 'symbolic link' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + cat diff.out --- exp Mon Dec 9 01:00:09 2013 +++ out Mon Dec 9 01:00:09 2013 @@ -1,1 +1,1 @@ -cp --link -P filelink dst|result=0|inode=8437|type=symbolic link|error= +cp --link -P filelink dst|result=0|inode=8502|type=symbolic link|error= + rm -f diff.out + false + ls -lid filelink file dst 8502 lrwxrwxrwx 1 padraig csw 4 Dec 9 01:00 dst -> file 8435 -rw-r--r-- 1 padraig csw 0 Dec 9 01:00 file 8437 lrwxrwxrwx 1 padraig csw 4 Dec 9 01:00 filelink -> file + fail=1 + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -P -R filelink dst' + cp --link -P -R filelink dst + result=0 ++ stat -c %i dst + ino_dst=8507 ++ stat -c %F dst + typ_dst='symbolic link' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P -R filelink dst' 0 8507 'symbolic link' '' + '[' -P = -P ']' + exp_result=0 + exp_inode=8437 + exp_ftype='symbolic link' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P -R filelink dst' 0 8437 'symbolic link' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + cat diff.out --- exp Mon Dec 9 01:00:10 2013 +++ out Mon Dec 9 01:00:10 2013 @@ -1,1 +1,1 @@ -cp --link -P -R filelink dst|result=0|inode=8437|type=symbolic link|error= +cp --link -P -R filelink dst|result=0|inode=8507|type=symbolic link|error= + rm -f diff.out + false + ls -lid filelink file dst 8507 lrwxrwxrwx 1 padraig csw 4 Dec 9 01:00 dst -> file 8435 -rw-r--r-- 1 padraig csw 0 Dec 9 01:00 file 8437 lrwxrwxrwx 1 padraig csw 4 Dec 9 01:00 filelink -> file + fail=1 + rm -rf dst err exp out + for src in dirlink filelink danglink ++ readlink danglink + tgt=nowhere ++ stat -c %i danglink + ino_src=8438 ++ stat -c %F danglink + typ_src='symbolic link' ++ stat -c %i nowhere + ino_tgt= + ino_tgt= ++ stat -c %F nowhere + typ_tgt= + typ_tgt= + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link danglink dst' + cp --link danglink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + '[' '' = -P ']' + '[' danglink = danglink ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: cannot stat '\''danglink'\'': No such file or directory' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -R danglink dst' + cp --link -R danglink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -R danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + '[' '' = -P ']' + '[' danglink = danglink ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: cannot stat '\''danglink'\'': No such file or directory' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -R danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -L danglink dst' + cp --link -L danglink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + '[' -L = -P ']' + '[' danglink = danglink ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: cannot stat '\''danglink'\'': No such file or directory' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -L -R danglink dst' + cp --link -L -R danglink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L -R danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + '[' -L = -P ']' + '[' danglink = danglink ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: cannot stat '\''danglink'\'': No such file or directory' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -L -R danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -H danglink dst' + cp --link -H danglink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + '[' -H = -P ']' + '[' danglink = danglink ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: cannot stat '\''danglink'\'': No such file or directory' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -H -R danglink dst' + cp --link -H -R danglink dst + result=1 ++ stat -c %i dst + ino_dst= + ini_dst= ++ stat -c %F dst + typ_dst= + typ_dst= ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H -R danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + '[' -H = -P ']' + '[' danglink = danglink ']' + exp_result=1 + exp_inode= + exp_ftype= + exp_error='cp: cannot stat '\''danglink'\'': No such file or directory' + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -H -R danglink dst' 1 '' '' 'cp: cannot stat '\''danglink'\'': No such file or directory' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + rm -f diff.out + true + rm -rf dst err exp out + for o in ''\'''\''' -L -H -P + for r in ''\'''\''' -R + command='cp --link -P danglink dst' + cp --link -P danglink dst + result=0 ++ stat -c %i dst + ino_dst=8536 ++ stat -c %F dst + typ_dst='symbolic link' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P danglink dst' 0 8536 'symbolic link' '' + '[' -P = -P ']' + exp_result=0 + exp_inode=8438 + exp_ftype='symbolic link' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P danglink dst' 0 8438 'symbolic link' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + cat diff.out --- exp Mon Dec 9 01:00:10 2013 +++ out Mon Dec 9 01:00:10 2013 @@ -1,1 +1,1 @@ -cp --link -P danglink dst|result=0|inode=8438|type=symbolic link|error= +cp --link -P danglink dst|result=0|inode=8536|type=symbolic link|error= + rm -f diff.out + false + ls -lid danglink nowhere dst ls: cannot access nowhere: No such file or directory 8438 lrwxrwxrwx 1 padraig csw 7 Dec 9 01:00 danglink -> nowhere 8536 lrwxrwxrwx 1 padraig csw 7 Dec 9 01:00 dst -> nowhere + fail=1 + rm -rf dst err exp out + for r in ''\'''\''' -R + command='cp --link -P -R danglink dst' + cp --link -P -R danglink dst + result=0 ++ stat -c %i dst + ino_dst=8541 ++ stat -c %F dst + typ_dst='symbolic link' ++ cat err + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P -R danglink dst' 0 8541 'symbolic link' '' + '[' -P = -P ']' + exp_result=0 + exp_inode=8438 + exp_ftype='symbolic link' + exp_error= + printf '%s|result=%s|inode=%s|type=%s|error=%s\n' 'cp --link -P -R danglink dst' 0 8438 'symbolic link' '' + compare exp out + compare_dev_null_ exp out + test 2 = 2 + test xexp = x/dev/null + test xout = x/dev/null + return 2 + case $? in + compare_ exp out + diff -u exp out + cat diff.out --- exp Mon Dec 9 01:00:10 2013 +++ out Mon Dec 9 01:00:10 2013 @@ -1,1 +1,1 @@ -cp --link -P -R danglink dst|result=0|inode=8438|type=symbolic link|error= +cp --link -P -R danglink dst|result=0|inode=8541|type=symbolic link|error= + rm -f diff.out + false + ls -lid danglink nowhere dst ls: cannot access nowhere: No such file or directory 8438 lrwxrwxrwx 1 padraig csw 7 Dec 9 01:00 danglink -> nowhere 8541 lrwxrwxrwx 1 padraig csw 7 Dec 9 01:00 dst -> nowhere + fail=1 + rm -rf dst err exp out + Exit 1 + set +e + exit 1 + exit 1 + remove_tmp_ + __st=1 + cleanup_ + : + cd /home/padraig/coreutils-8.21.176-37e00 + chmod -R u+rwx /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP + rm -rf /home/padraig/coreutils-8.21.176-37e00/gt-link-deref.sh.j8UP + exit 1 --------------020505050100020700000003-- From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 12 13:44:31 2013 Received: (at 15173) by debbugs.gnu.org; 12 Dec 2013 18:44:31 +0000 Received: from localhost ([127.0.0.1]:46076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VrBFO-0003fx-Ts for submit@debbugs.gnu.org; Thu, 12 Dec 2013 13:44:31 -0500 Received: from mail6.vodafone.ie ([213.233.128.184]:55927) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VrBFM-0003fl-6I for 15173@debbugs.gnu.org; Thu, 12 Dec 2013 13:44:29 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApUBALkDqlJtTv+q/2dsb2JhbAANTIcahV2ve4EzgxkBAQEDASMEVwsYBAMBAgEJFgsCAgkDAgECAT0IEwYCAQGHeA2xcXaQFBePAxiCbIFIBJAyjk+OUQ Received: from unknown (HELO [192.168.1.79]) ([109.78.255.170]) by mail3.vodafone.ie with ESMTP; 12 Dec 2013 18:44:15 +0000 Message-ID: <52AA03FF.6020407@draigBrady.com> Date: Thu, 12 Dec 2013 18:44:15 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: 15173@debbugs.gnu.org Subject: [PATCH] cp: with --link always use linkat() if available References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> <527C1B50.20708@bernhard-voelker.de> <52A529EC.8000305@draigBrady.com> In-Reply-To: <52A529EC.8000305@draigBrady.com> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------040409080605040103050205" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------040409080605040103050205 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 12/09/2013 02:24 AM, Pádraig Brady wrote: > Sorry if you get multiple copies of this. > > The test for this is failing on solaris 10 (NFS) > It does seem that hardlinks to symlinks are supported: > > $ touch tfile > $ ln -s tfile tlink > $ src/ln -L tlink tlink-ln-L > $ src/ln -P tlink tlink-ln-P > $ src/ln tlink tlink-ln > $ ls -li tfile tlink* > 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tfile > 8551 lrwxrwxrwx 2 padraig csw 5 Dec 9 01:19 tlink -> tfile > 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tlink-ln > 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tlink-ln-L > 8551 lrwxrwxrwx 2 padraig csw 5 Dec 9 01:19 tlink-ln-P -> tfile > > But we have linkat() emulation in place I think: > > $ grep LINK lib/config.h ... > /* #undef HAVE_LINKAT */ > #define LINK_FOLLOWS_SYMLINKS -1 > FAIL: tests/cp/link-deref > ========================= > --- exp Mon Dec 9 01:00:08 2013 > +++ out Mon Dec 9 01:00:08 2013 > @@ -1,1 +1,1 @@ > -cp --link -P dirlink dst|result=0|inode=8436|type=symbolic link|error= > +cp --link -P dirlink dst|result=0|inode=8467|type=symbolic link|error= > + rm -f diff.out > + false > + ls -lid dirlink dir dst > 8434 drwxr-xr-x 2 padraig csw 2 Dec 9 01:00 dir > 8436 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dirlink -> dir > 8467 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dst -> dir > + fail=1 So the attached should address this on FreeBSD ast least where we HAVE_LINKAT so don't need to fallback to the symlink -> symlink emulation in copy.c For the above case we'll need to skip parts of the test I think, depending on the above 2 config vars. thanks, Pádraig --------------040409080605040103050205 Content-Type: text/x-patch; name="cp-linkat.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cp-linkat.patch" >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 --------------040409080605040103050205-- From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 12 18:11:41 2013 Received: (at 15173) by debbugs.gnu.org; 12 Dec 2013 23:11:41 +0000 Received: from localhost ([127.0.0.1]:46195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VrFPw-0001sz-HG for submit@debbugs.gnu.org; Thu, 12 Dec 2013 18:11:40 -0500 Received: from mail6.vodafone.ie ([213.233.128.184]:5197) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VrFPu-0001so-4i for 15173@debbugs.gnu.org; Thu, 12 Dec 2013 18:11:39 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBAAxCqlJtTv+q/2dsb2JhbAANTINCg1i1VYE0gxkBAQEEI1EVCw0EAwECChYLAgIJAwIBAgE9CBMGAgEBiAWxf3aQFhePAxgWgleBSASQMokThTyOUQ Received: from unknown (HELO [192.168.1.79]) ([109.78.255.170]) by mail3.vodafone.ie with ESMTP; 12 Dec 2013 23:11:36 +0000 Message-ID: <52AA42A8.5080904@draigBrady.com> Date: Thu, 12 Dec 2013 23:11:36 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: 15173@debbugs.gnu.org Subject: Re: bug#15173: [PATCH] cp: with --link always use linkat() if available References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> <527C1B50.20708@bernhard-voelker.de> <52A529EC.8000305@draigBrady.com> <52AA03FF.6020407@draigBrady.com> In-Reply-To: <52AA03FF.6020407@draigBrady.com> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------030305050807010102090600" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------030305050807010102090600 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So while the above patch is probably correct, it's slightly risky at this stage before a release. Also the benefits are minimal as the existing symlink to symlink emulation should be fine on the mentioned systems. Therefore I'll go with the attached patch which fixes the test to run on all platforms. The test failed on freebsd, aix and solaris previously, and I've confirmed it now passes on all those. cheers, Pádraig. --------------030305050807010102090600 Content-Type: text/x-patch; name="link-deref-compat.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="link-deref-compat.patch" >From 4efea60dbee1fef6aab1e9385813beb7d92f8178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Thu, 12 Dec 2013 22:43:05 +0000 Subject: [PATCH] tests: restrict cp --link inode comparisons to compatible systems * tests/cp/link-deref.sh: On systems were cp can't determine if gnulib linkat() emulation might create a symlink instead of a hardlink to a symlink, copy.c will create a symlink to the symlink so that it has more control over its metadata. Also even if the system supports this operation, the particular file system under test may not. So avoid the hardlinked symlink verification in these cases. This fixes a false failure on aix, solaris and freebsd. --- tests/cp/link-deref.sh | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/tests/cp/link-deref.sh b/tests/cp/link-deref.sh index c12dfc8..89f7a36 100755 --- a/tests/cp/link-deref.sh +++ b/tests/cp/link-deref.sh @@ -19,6 +19,18 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ cp +if grep '^#define HAVE_LINKAT 1' "$CONFIG_HEADER" > /dev/null \ + && grep '^#define LINK_FOLLOWS_SYMLINKS 0' "$CONFIG_HEADER" > /dev/null; then + # With this config (which is the case on GNU/Linux) cp will attempt to + # linkat() to hardlink a symlink. So now see if the current file system + # supports this operation. + ln -s testtarget test_sl || framework_failure_ + ln -P test_sl test_hl_sl || framework_failure_ + ino_sl="$(stat -c '%i' test_sl)" || framework_failure_ + ino_hl="$(stat -c '%i' test_hl_sl)" || framework_failure_ + test "$ino_sl" = "$ino_hl" && can_hardlink_to_symlink=1 +fi + mkdir dir || framework_failure_ : > file || framework_failure_ ln -s dir dirlink || framework_failure_ @@ -39,6 +51,10 @@ for src in dirlink filelink danglink; do typ_tgt="$(stat -c '%F' $tgt 2>/dev/null)" || typ_tgt= for o in '' -L -H -P; do + + # Skip the -P case where we don't or can't hardlink symlinks + ! test "$can_hardlink_to_symlink" && test "$o" = '-P' && continue + for r in '' -R; do command="cp --link $o $r $src dst" -- 1.7.7.6 --------------030305050807010102090600-- From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 12 19:51:38 2013 Received: (at 15173) by debbugs.gnu.org; 13 Dec 2013 00:51:38 +0000 Received: from localhost ([127.0.0.1]:46263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VrGyg-0004JS-1D for submit@debbugs.gnu.org; Thu, 12 Dec 2013 19:51:38 -0500 Received: from moutng.kundenserver.de ([212.227.126.171]:64792) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VrGyd-0004JI-8L for 15173@debbugs.gnu.org; Thu, 12 Dec 2013 19:51:36 -0500 Received: from [192.168.1.11] (p5499C1A7.dip0.t-ipconnect.de [84.153.193.167]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0MWQME-1W1ezn0QXK-00XqXF; Fri, 13 Dec 2013 01:51:33 +0100 Message-ID: <52AA5A14.90407@bernhard-voelker.de> Date: Fri, 13 Dec 2013 01:51:32 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#15173: [PATCH] cp: with --link always use linkat() if available References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> <527C1B50.20708@bernhard-voelker.de> <52A529EC.8000305@draigBrady.com> <52AA03FF.6020407@draigBrady.com> <52AA42A8.5080904@draigBrady.com> In-Reply-To: <52AA42A8.5080904@draigBrady.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:+KmrPCBaHIe9liUs0msqQYsIWpRpDWOaFQhESaU+zZ3 SCa2UXiovHXh3X75K998zYJ4JlSIG1QFlPOwJWsVmLMOxEc2bv Hmx4p0afqFVrSwXwmFGHrGJpTuW+qVy1AijMkcpWxUdrTvRagO mdFKRFN6WDdNr6wOvEet/Dt7Lz9y0IIJKWInhXX8WtIl5eOM9R wsYx7U0LFld8keXkabGvTKePp16HsOYnN5+v93Wr7h2PgTr5hM EQ+WUITIahelKE8iZHXz4d+UvhMcGebWpVEtcBnbETrgkaFV7R 2EiwqfxpLL06T+LVnxRAT0vCWyr+rP2DAqiMIhDmFesdzgIdLm zCj7dXOphaue2J75DsVlEAgAmCbD4FvGpXKbF9qqh X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 12/13/2013 12:11 AM, Pádraig Brady wrote: > So while the above patch is probably correct, it's slightly risky > at this stage before a release. Also the benefits are minimal as > the existing symlink to symlink emulation should be fine on the mentioned systems. > > Therefore I'll go with the attached patch which fixes the test to run > on all platforms. The test failed on freebsd, aix and solaris previously, > and I've confirmed it now passes on all those. Unfortunately, I didn't have time to look into the details of this issue. As I understood your comment, it is not a FP in the tests but rather an issue in copy.c on these platforms. I'm fine with the proposed patch for the time being, i.e. to NOP out some test cases to avoid FPs- but it then would probably make sense to document the varying behavior, at least in a FIXME in the test. Thanks & have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Thu Dec 12 20:06:29 2013 Received: (at 15173) by debbugs.gnu.org; 13 Dec 2013 01:06:29 +0000 Received: from localhost ([127.0.0.1]:46291 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VrHD2-0004hY-D7 for submit@debbugs.gnu.org; Thu, 12 Dec 2013 20:06:28 -0500 Received: from mail4.vodafone.ie ([213.233.128.170]:55301) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VrHCz-0004hM-Qt for 15173@debbugs.gnu.org; Thu, 12 Dec 2013 20:06:26 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApQBAP9cqlJtTv+q/2dsb2JhbAANTIcask+DBoE0gxkBAQEDASMPAUEFBQsLDQEKAgIFFgsCAgkDAgECAUUGDQEHAQGHeA2xeXaQBheBKY1rB4JtgUgEnwGOUQ Received: from unknown (HELO [192.168.1.79]) ([109.78.255.170]) by mail3.vodafone.ie with ESMTP; 13 Dec 2013 01:06:24 +0000 Message-ID: <52AA5D90.2000106@draigBrady.com> Date: Fri, 13 Dec 2013 01:06:24 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Bernhard Voelker Subject: Re: bug#15173: [PATCH] cp: with --link always use linkat() if available References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> <527C1B50.20708@bernhard-voelker.de> <52A529EC.8000305@draigBrady.com> <52AA03FF.6020407@draigBrady.com> <52AA42A8.5080904@draigBrady.com> <52AA5A14.90407@bernhard-voelker.de> In-Reply-To: <52AA5A14.90407@bernhard-voelker.de> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 12/13/2013 12:51 AM, Bernhard Voelker wrote: > On 12/13/2013 12:11 AM, Pádraig Brady wrote: >> So while the above patch is probably correct, it's slightly risky >> at this stage before a release. Also the benefits are minimal as >> the existing symlink to symlink emulation should be fine on the mentioned systems. >> >> Therefore I'll go with the attached patch which fixes the test to run >> on all platforms. The test failed on freebsd, aix and solaris previously, >> and I've confirmed it now passes on all those. > > Unfortunately, I didn't have time to look into the details of this > issue. As I understood your comment, it is not a FP in the tests but > rather an issue in copy.c on these platforms. It's a minor issue in copy.c on some of these platforms (with HAVE_LINKAT). Improving that would make the test pass on FreeBSD for example, but we can leave that until the next release. The main issue is the test expected hardlinks to symlinks to be always done by cp --link, so the added guard is needed in any case. > I'm fine with the proposed patch for the time being, i.e. to NOP out > some test cases to avoid FPs- but it then would probably make sense > to document the varying behavior, at least in a FIXME in the test. thanks for the review, Pádraig. From unknown Fri Jun 20 07:15:39 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 10 Jan 2014 12:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 09 21:13:09 2014 Received: (at control) by debbugs.gnu.org; 10 Feb 2014 02:13:09 +0000 Received: from localhost ([127.0.0.1]:32941 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCgMu-0007o6-I6 for submit@debbugs.gnu.org; Sun, 09 Feb 2014 21:13:09 -0500 Received: from mail6.vodafone.ie ([213.233.128.184]:30143) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCgMr-0007nl-3g; Sun, 09 Feb 2014 21:13:06 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApkBANA0+FJtTXJs/2dsb2JhbAANTINEg1iFXbZtgR2DGQEBAQQjBGILDQQDAQIBCRQCCwICCQMCAQIBPQgTBgIBAYgGpnd2oDcXjmwYgm+BSQSQP4Eyh2yFPo5e Received: from unknown (HELO [192.168.1.79]) ([109.77.114.108]) by mail3.vodafone.ie with ESMTP; 10 Feb 2014 02:13:04 +0000 Message-ID: <52F835AF.3010308@draigBrady.com> Date: Mon, 10 Feb 2014 02:13:03 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: 15173@debbugs.gnu.org Subject: Re: bug#15173: [PATCH] cp: with --link always use linkat() if available References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> <527C1B50.20708@bernhard-voelker.de> <52A529EC.8000305@draigBrady.com> <52AA03FF.6020407@draigBrady.com> In-Reply-To: <52AA03FF.6020407@draigBrady.com> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------080803090406000701040901" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------080803090406000701040901 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit unarchive 15173 stop On 12/12/2013 06:44 PM, Pádraig Brady wrote: > On 12/09/2013 02:24 AM, Pádraig Brady wrote: >> Sorry if you get multiple copies of this. >> >> The test for this is failing on solaris 10 (NFS) >> It does seem that hardlinks to symlinks are supported: >> >> $ touch tfile >> $ ln -s tfile tlink >> $ src/ln -L tlink tlink-ln-L >> $ src/ln -P tlink tlink-ln-P >> $ src/ln tlink tlink-ln >> $ ls -li tfile tlink* >> 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tfile >> 8551 lrwxrwxrwx 2 padraig csw 5 Dec 9 01:19 tlink -> tfile >> 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tlink-ln >> 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tlink-ln-L >> 8551 lrwxrwxrwx 2 padraig csw 5 Dec 9 01:19 tlink-ln-P -> tfile >> >> But we have linkat() emulation in place I think: >> >> $ grep LINK lib/config.h > ... >> /* #undef HAVE_LINKAT */ >> #define LINK_FOLLOWS_SYMLINKS -1 > >> FAIL: tests/cp/link-deref >> ========================= > >> --- exp Mon Dec 9 01:00:08 2013 >> +++ out Mon Dec 9 01:00:08 2013 >> @@ -1,1 +1,1 @@ >> -cp --link -P dirlink dst|result=0|inode=8436|type=symbolic link|error= >> +cp --link -P dirlink dst|result=0|inode=8467|type=symbolic link|error= >> + rm -f diff.out >> + false >> + ls -lid dirlink dir dst >> 8434 drwxr-xr-x 2 padraig csw 2 Dec 9 01:00 dir >> 8436 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dirlink -> dir >> 8467 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dst -> dir >> + fail=1 > > So the attached should address this on FreeBSD ast least > where we HAVE_LINKAT so don't need to fallback to > the symlink -> symlink emulation in copy.c I still think this is correct, and while I didn't think it worth the small risk right before the 8.22 release, I hope to push this rebased patch soon. thanks, Pádraig. --------------080803090406000701040901 Content-Type: text/x-patch; name="cp-linkat.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cp-linkat.patch" >From 1893578fb0cdbb1875a42bc86cad452f6c62e5dc 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. * tests/cp/link-deref.sh: Adjust to remove the no longer significant LINK_FOLLOWS_SYMLINKS check. --- src/copy.c | 10 ++++++++-- tests/cp/link-deref.sh | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/copy.c b/src/copy.c index 3e4cbff..d560dfd 100644 --- a/src/copy.c +++ b/src/copy.c @@ -2492,8 +2492,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; @@ -2632,8 +2635,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) diff --git a/tests/cp/link-deref.sh b/tests/cp/link-deref.sh index e56d592..b249fce 100755 --- a/tests/cp/link-deref.sh +++ b/tests/cp/link-deref.sh @@ -19,8 +19,7 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ cp -if grep '^#define HAVE_LINKAT 1' "$CONFIG_HEADER" > /dev/null \ - && grep '^#define LINK_FOLLOWS_SYMLINKS 0' "$CONFIG_HEADER" > /dev/null; then +if grep '^#define HAVE_LINKAT 1' "$CONFIG_HEADER" > /dev/null; then # With this config (which is the case on GNU/Linux) cp will attempt to # linkat() to hardlink a symlink. So now see if the current file system # supports this operation. -- 1.7.7.6 --------------080803090406000701040901-- From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 09 21:18:15 2014 Received: (at 15173) by debbugs.gnu.org; 10 Feb 2014 02:18:15 +0000 Received: from localhost ([127.0.0.1]:32960 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCgRq-0000zs-92 for submit@debbugs.gnu.org; Sun, 09 Feb 2014 21:18:14 -0500 Received: from mail6.vodafone.ie ([213.233.128.184]:15206) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCgRn-0000zj-I1 for 15173@debbugs.gnu.org; Sun, 09 Feb 2014 21:18:12 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApkBABw2+FJtTXJs/2dsb2JhbAANTINEg1iFXbZugR2DGQEBAQQjBGILDQQDAQIBCRQNAgIPAj4IEwYCAQGIBqZ5dqA3F45sGIJvgUkEkD+BModshT6OXg Received: from unknown (HELO [192.168.1.79]) ([109.77.114.108]) by mail3.vodafone.ie with ESMTP; 10 Feb 2014 02:18:11 +0000 Message-ID: <52F836E2.60406@draigBrady.com> Date: Mon, 10 Feb 2014 02:18:10 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: 15173@debbugs.gnu.org Subject: Re: bug#15173: [PATCH] cp: with --link always use linkat() if available References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> <527C1B50.20708@bernhard-voelker.de> <52A529EC.8000305@draigBrady.com> <52AA03FF.6020407@draigBrady.com> In-Reply-To: <52AA03FF.6020407@draigBrady.com> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------020404060902010301020006" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------020404060902010301020006 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 12/12/2013 06:44 PM, Pádraig Brady wrote: > On 12/09/2013 02:24 AM, Pádraig Brady wrote: >> Sorry if you get multiple copies of this. >> >> The test for this is failing on solaris 10 (NFS) >> It does seem that hardlinks to symlinks are supported: >> >> $ touch tfile >> $ ln -s tfile tlink >> $ src/ln -L tlink tlink-ln-L >> $ src/ln -P tlink tlink-ln-P >> $ src/ln tlink tlink-ln >> $ ls -li tfile tlink* >> 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tfile >> 8551 lrwxrwxrwx 2 padraig csw 5 Dec 9 01:19 tlink -> tfile >> 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tlink-ln >> 8550 -rw-r--r-- 3 padraig csw 0 Dec 9 01:18 tlink-ln-L >> 8551 lrwxrwxrwx 2 padraig csw 5 Dec 9 01:19 tlink-ln-P -> tfile >> >> But we have linkat() emulation in place I think: >> >> $ grep LINK lib/config.h > ... >> /* #undef HAVE_LINKAT */ >> #define LINK_FOLLOWS_SYMLINKS -1 > >> FAIL: tests/cp/link-deref >> ========================= > >> --- exp Mon Dec 9 01:00:08 2013 >> +++ out Mon Dec 9 01:00:08 2013 >> @@ -1,1 +1,1 @@ >> -cp --link -P dirlink dst|result=0|inode=8436|type=symbolic link|error= >> +cp --link -P dirlink dst|result=0|inode=8467|type=symbolic link|error= >> + rm -f diff.out >> + false >> + ls -lid dirlink dir dst >> 8434 drwxr-xr-x 2 padraig csw 2 Dec 9 01:00 dir >> 8436 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dirlink -> dir >> 8467 lrwxrwxrwx 1 padraig csw 3 Dec 9 01:00 dst -> dir >> + fail=1 > > So the attached should address this on FreeBSD ast least > where we HAVE_LINKAT so don't need to fallback to > the symlink -> symlink emulation in copy.c I still think this is correct, and while I didn't think it worth the small risk right before the 8.22 release, I hope to push this rebased patch soon. thanks, Pádraig. --------------020404060902010301020006 Content-Type: text/x-patch; name="cp-linkat.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cp-linkat.patch" >From 1893578fb0cdbb1875a42bc86cad452f6c62e5dc 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. * tests/cp/link-deref.sh: Adjust to remove the no longer significant LINK_FOLLOWS_SYMLINKS check. --- src/copy.c | 10 ++++++++-- tests/cp/link-deref.sh | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/copy.c b/src/copy.c index 3e4cbff..d560dfd 100644 --- a/src/copy.c +++ b/src/copy.c @@ -2492,8 +2492,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; @@ -2632,8 +2635,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) diff --git a/tests/cp/link-deref.sh b/tests/cp/link-deref.sh index e56d592..b249fce 100755 --- a/tests/cp/link-deref.sh +++ b/tests/cp/link-deref.sh @@ -19,8 +19,7 @@ . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src print_ver_ cp -if grep '^#define HAVE_LINKAT 1' "$CONFIG_HEADER" > /dev/null \ - && grep '^#define LINK_FOLLOWS_SYMLINKS 0' "$CONFIG_HEADER" > /dev/null; then +if grep '^#define HAVE_LINKAT 1' "$CONFIG_HEADER" > /dev/null; then # With this config (which is the case on GNU/Linux) cp will attempt to # linkat() to hardlink a symlink. So now see if the current file system # supports this operation. -- 1.7.7.6 --------------020404060902010301020006-- From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 09 21:29:17 2014 Received: (at 15173) by debbugs.gnu.org; 10 Feb 2014 02:29:17 +0000 Received: from localhost ([127.0.0.1]:32982 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCgcW-0001Io-Qy for submit@debbugs.gnu.org; Sun, 09 Feb 2014 21:29:17 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:49144) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCgcU-0001Ig-Tf for 15173@debbugs.gnu.org; Sun, 09 Feb 2014 21:29:15 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 5EDA039E8016; Sun, 9 Feb 2014 18:29:14 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lhyuyyhWCtEo; Sun, 9 Feb 2014 18:29:14 -0800 (PST) Received: from [192.168.1.9] (pool-108-0-233-62.lsanca.fios.verizon.net [108.0.233.62]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id EA22539E8014; Sun, 9 Feb 2014 18:29:13 -0800 (PST) Message-ID: <52F83979.8090402@cs.ucla.edu> Date: Sun, 09 Feb 2014 18:29:13 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= , 15173@debbugs.gnu.org Subject: Re: bug#15173: [PATCH] cp: with --link always use linkat() if available References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> <527C1B50.20708@bernhard-voelker.de> <52A529EC.8000305@draigBrady.com> <52AA03FF.6020407@draigBrady.com> <52F836E2.60406@draigBrady.com> In-Reply-To: <52F836E2.60406@draigBrady.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -2.9 (--) X-Debbugs-Envelope-To: 15173 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.9 (--) Pádraig Brady wrote: > +#if ! defined HAVE_LINKAT > && !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode) > - && x->dereference == DEREF_NEVER)) > + && x->dereference == DEREF_NEVER) > +#endif Could you reword that sort of thing so as not to use the #if inside an expression? Something like this instead, perhaps, earlier in the code: #if !defined HAVE_LINKAT && LINK_FOLLOWS_SYMLINKS # define LINKAT_FOLLOWS_SYMLINKS 1 #else # define LINKAT_FOLLOWS_SYMLINKS 0 #endif That way, the rest of the code can simply replace LINK_FOLLOWS_SYMLINKS with LINKAT_FOLLOWS_SYMLINKS, which will make it easier to read. From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 09 23:02:28 2014 Received: (at 15173) by debbugs.gnu.org; 10 Feb 2014 04:02:28 +0000 Received: from localhost ([127.0.0.1]:33310 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCi4h-0001Pj-AP for submit@debbugs.gnu.org; Sun, 09 Feb 2014 23:02:27 -0500 Received: from mail3.vodafone.ie ([213.233.128.45]:52253) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCi4e-0001Pa-HD for 15173@debbugs.gnu.org; Sun, 09 Feb 2014 23:02:25 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApkBANBO+FJtTt9d/2dsb2JhbAANTA6DNoNYhV22boEdgxkBAQEEIwRSEAsNBAMBAgEJFAILAgIJAwIBAgE9CAYNAQUCAQGIBqcKdqA+F45sEQcJgmaBSQSQP4EyjSqOHz8 Received: from unknown (HELO [192.168.1.79]) ([109.78.223.93]) by mail3.vodafone.ie with ESMTP; 10 Feb 2014 04:02:22 +0000 Message-ID: <52F84F4E.8010600@draigBrady.com> Date: Mon, 10 Feb 2014 04:02:22 +0000 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Paul Eggert Subject: Re: bug#15173: [PATCH] cp: with --link always use linkat() if available References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> <527C1B50.20708@bernhard-voelker.de> <52A529EC.8000305@draigBrady.com> <52AA03FF.6020407@draigBrady.com> <52F836E2.60406@draigBrady.com> <52F83979.8090402@cs.ucla.edu> In-Reply-To: <52F83979.8090402@cs.ucla.edu> X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------000900040206060105050304" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) This is a multi-part message in MIME format. --------------000900040206060105050304 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 02/10/2014 02:29 AM, Paul Eggert wrote: > Pádraig Brady wrote: >> +#if ! defined HAVE_LINKAT >> && !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode) >> - && x->dereference == DEREF_NEVER)) >> + && x->dereference == DEREF_NEVER) >> +#endif > > Could you reword that sort of thing so as not to use the #if inside an expression? Something like this instead, perhaps, earlier in the code: > > #if !defined HAVE_LINKAT && LINK_FOLLOWS_SYMLINKS > # define LINKAT_FOLLOWS_SYMLINKS 1 > #else > # define LINKAT_FOLLOWS_SYMLINKS 0 > #endif That's slightly confusing as linkat() emulation never actually symlinks the referent. I went for the more direct: #if defined HAVE_LINKAT || ! LINK_FOLLOWS_SYMLINKS # define CAN_HARDLINK_SYMLINKS 1 #else # define CAN_HARDLINK_SYMLINKS 0 #endif Full patch is attached. thanks, Pádraig. --------------000900040206060105050304 Content-Type: text/x-patch; name="cp-linkat.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cp-linkat.patch" >From 9196a8c3375a3c8f7478b2ca8373ceeef31eaeb2 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. * tests/cp/link-deref.sh: Adjust to the checks to cater for all cases where hardlinks to symlinks are supported. --- src/copy.c | 20 ++++++++++++++------ tests/cp/link-deref.sh | 7 +++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/copy.c b/src/copy.c index 3e4cbff..127eed2 100644 --- a/src/copy.c +++ b/src/copy.c @@ -98,6 +98,14 @@ rpl_mkfifo (char const *file, mode_t mode) #define SAME_GROUP(A, B) ((A).st_gid == (B).st_gid) #define SAME_OWNER_AND_GROUP(A, B) (SAME_OWNER (A, B) && SAME_GROUP (A, B)) +/* LINK_FOLLOWS_SYMLINKS is tri-state; if it is -1, we don't know + how link() behaves, so assume we can't hardlink symlinks in that case. */ +#if defined HAVE_LINKAT || ! LINK_FOLLOWS_SYMLINKS +# define CAN_HARDLINK_SYMLINKS 1 +#else +# define CAN_HARDLINK_SYMLINKS 0 +#endif + struct dir_list { struct dir_list *parent; @@ -2484,16 +2492,15 @@ copy_internal (char const *src_name, char const *dst_name, should not follow the link. We can approximate the desired behavior by skipping this hard-link creating block and instead copying the symlink, via the 'S_ISLNK'- copying code below. - LINK_FOLLOWS_SYMLINKS is tri-state; if it is -1, we don't know - how link() behaves, so we use the fallback case for safety. Note gnulib's linkat module, guarantees that the symlink is not dereferenced. However its emulation currently doesn't maintain timestamps or ownership so we only call it when we know the emulation will not be needed. */ else if (x->hard_link - && !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode) - && x->dereference == DEREF_NEVER)) + && !(! CAN_HARDLINK_SYMLINKS && S_ISLNK (src_mode) + && x->dereference == DEREF_NEVER) + ) { if (! create_hard_link (src_name, dst_name, false, false, dereference)) goto un_backup; @@ -2632,8 +2639,9 @@ 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) - && !(LINK_FOLLOWS_SYMLINKS && S_ISLNK (src_mode) - && x->dereference == DEREF_NEVER)) + && !(! CAN_HARDLINK_SYMLINKS && S_ISLNK (src_mode) + && x->dereference == DEREF_NEVER) + ) return delayed_ok; if (copied_as_regular) diff --git a/tests/cp/link-deref.sh b/tests/cp/link-deref.sh index e56d592..5bbd8d4 100755 --- a/tests/cp/link-deref.sh +++ b/tests/cp/link-deref.sh @@ -20,10 +20,9 @@ print_ver_ cp if grep '^#define HAVE_LINKAT 1' "$CONFIG_HEADER" > /dev/null \ - && grep '^#define LINK_FOLLOWS_SYMLINKS 0' "$CONFIG_HEADER" > /dev/null; then - # With this config (which is the case on GNU/Linux) cp will attempt to - # linkat() to hardlink a symlink. So now see if the current file system - # supports this operation. + || grep '^#define LINK_FOLLOWS_SYMLINKS 0' "$CONFIG_HEADER" > /dev/null; then + # With this config cp will attempt to linkat() to hardlink a symlink. + # So now see if the current file system supports this operation. ln -s testtarget test_sl || framework_failure_ ln -P test_sl test_hl_sl || framework_failure_ ino_sl="$(stat -c '%i' test_sl)" || framework_failure_ -- 1.7.7.6 --------------000900040206060105050304-- From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 09 23:14:19 2014 Received: (at 15173) by debbugs.gnu.org; 10 Feb 2014 04:14:19 +0000 Received: from localhost ([127.0.0.1]:33349 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCiGB-0001kc-3l for submit@debbugs.gnu.org; Sun, 09 Feb 2014 23:14:19 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:52065) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCiG8-0001kS-FS for 15173@debbugs.gnu.org; Sun, 09 Feb 2014 23:14:17 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 0361039E8018; Sun, 9 Feb 2014 20:14:15 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hYPZXXW3fgFf; Sun, 9 Feb 2014 20:14:14 -0800 (PST) Received: from [192.168.1.9] (pool-108-0-233-62.lsanca.fios.verizon.net [108.0.233.62]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 9027739E8014; Sun, 9 Feb 2014 20:14:14 -0800 (PST) Message-ID: <52F85216.5040404@cs.ucla.edu> Date: Sun, 09 Feb 2014 20:14:14 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= Subject: Re: bug#15173: [PATCH] cp: with --link always use linkat() if available References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> <527C1B50.20708@bernhard-voelker.de> <52A529EC.8000305@draigBrady.com> <52AA03FF.6020407@draigBrady.com> <52F836E2.60406@draigBrady.com> <52F83979.8090402@cs.ucla.edu> <52F84F4E.8010600@draigBrady.com> In-Reply-To: <52F84F4E.8010600@draigBrady.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.9 (--) X-Debbugs-Envelope-To: 15173 Cc: 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.9 (--) Thanks, looks good. From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 10 03:58:30 2014 Received: (at 15173) by debbugs.gnu.org; 10 Feb 2014 08:58:30 +0000 Received: from localhost ([127.0.0.1]:39081 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCmhC-0002ZF-0i for submit@debbugs.gnu.org; Mon, 10 Feb 2014 03:58:30 -0500 Received: from moutng.kundenserver.de ([212.227.126.186]:63713) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WCmh9-0002Yy-Gq for 15173@debbugs.gnu.org; Mon, 10 Feb 2014 03:58:28 -0500 Received: from [10.0.2.15] (gw.camline.com [62.153.148.194]) by mrelayeu.kundenserver.de (node=mreue004) with ESMTP (Nemesis) id 0MYrHb-1Vittv09UB-00Vgmv; Mon, 10 Feb 2014 09:58:12 +0100 Message-ID: <52F894A3.4070304@bernhard-voelker.de> Date: Mon, 10 Feb 2014 09:58:11 +0100 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= , Paul Eggert Subject: Re: bug#15173: [PATCH] cp: with --link always use linkat() if available References: <5271BB65.5030007@bernhard-voelker.de> <52724947.6090200@draigBrady.com> <20131031135459.GB30875@caimano.fdc.rm-rf.it> <20131031212847.GE30875@caimano.fdc.rm-rf.it> <52744252.3070300@draigBrady.com> <5276EECB.6050003@bernhard-voelker.de> <52776AC3.3020407@draigBrady.com> <20131105000106.GB5665@caimano.fdc.rm-rf.it> <527B3C1F.1020400@bernhard-voelker.de> <527B67ED.7050303@draigBrady.com> <20131107140901.GB22232@caimano.fdc.rm-rf.it> <527C1B50.20708@bernhard-voelker.de> <52A529EC.8000305@draigBrady.com> <52AA03FF.6020407@draigBrady.com> <52F836E2.60406@draigBrady.com> <52F83979.8090402@cs.ucla.edu> <52F84F4E.8010600@draigBrady.com> In-Reply-To: <52F84F4E.8010600@draigBrady.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:g1P1ojRhC8CCru5D84yfcXx2wfYW7S3w/P2Nd8dTady K/eoCmZYG8tHbe6zlmAsSb9aH/P9PgowDf16J8yqp4amQeR3KO B3EIcsdb+5LwK9CE9XRqGQdRdt6UAC4FdBKkUz1u+pewcLHZP/ gt/reGpsQs/dM+Csee3Xp7H6U7VGt77/qR7lZAo1PSIVrWT0z8 +ZFMsKlijHnExplAIcuuEvutGfH2fxUQDfoIT68XJnmLDAsaAB 6VmKdH9JZJHPrvURZ5sOj/bOFNN79FM23Wa080ygB8d8RT587W fektlMTbATjp3BmBHI+hiFiq7NA7rthJTI8D2rvl53naPrIGQk L42cDu+xV+1wLOWLOyim/ma6u+BrjTi+qm0YSyBed X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 15173 Cc: 15173@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 02/10/2014 05:02 AM, Pádraig Brady wrote: > Full patch is attached. +1 Have a nice day, Berny From unknown Fri Jun 20 07:15:39 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 10 Mar 2014 11:24:14 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 27 18:09:00 2018 Received: (at control) by debbugs.gnu.org; 27 Oct 2018 22:09:00 +0000 Received: from localhost ([127.0.0.1]:45921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGWlQ-0006q6-ED for submit@debbugs.gnu.org; Sat, 27 Oct 2018 18:09:00 -0400 Received: from mail-pg1-f179.google.com ([209.85.215.179]:38781) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGWlO-0006pq-Ge; Sat, 27 Oct 2018 18:08:58 -0400 Received: by mail-pg1-f179.google.com with SMTP id f8-v6so2110413pgq.5; Sat, 27 Oct 2018 15:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=xyNzEhNLoXUC7b7KyivyIdw6lpXIN4/fA7lOJyTulfc=; b=NSDXQVvIbytSioui5Gpf85bo9VjSO6VREXUwdcQFwZbbXpg8GqCRH8kehrECNgIq2y Hhee9HFdGbVMiGNV17KJ9KEkoJtC9KII/F6wb0fODINt0ulZe2/0rH8f1WgQKOYOA1Ag jjeLIGHeOgz24JUTLm12Ow+7tncHbTWDDBnJG/ktuyOdJ4FYBeqSqHSW1vkG+KbZdkIY Q505iDZKq+rbT4vKE0v2Wy3UFfY4mVyMsC57KPOpkuF6BPBwfM9+C4tidCT8ql3l/e4a 7AoYPEwJPWk6lAQPZsMPMK6FAZ/xy5GG+z0qZRIPPzrIPmfA1u1d0G1roMaSy8irIuL4 krIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xyNzEhNLoXUC7b7KyivyIdw6lpXIN4/fA7lOJyTulfc=; b=KQoB2PyERJoB8aKml4OCcZy1HNfRZqRP1AunADGPCqBsEbZ4pf2joNf3efpPq3z0q/ vcErHv5TgixFvanstW0t0T5O18dkiusY3M1Ju0Tg+mJ1PFRXjNLGLfgrOh/w4OQkORPp 4kihWlxJ1VqHns5j5/G/e5MPq/LGRh1MFZTTBAARDFQsdlN1vtLySNF0iOxgeCnQF22h DaahCkk4SAiymrYNsPTt9TmpMktDs6GJFtMsfFPQtLzWMmK+Z/pupz1czO9v+sHOmnEk Xf+f0COQK4KYAKvxxWroUL8Ra6icwUIxlIsau09B0ESMcHKGGQsfiJJTb5wvo8u3XiB/ n5qQ== X-Gm-Message-State: AGRZ1gLA9CIxaagSI7QPiXxy7mdqwkgFwAdmDIS4c55UCrcpdB1IMBpQ ITsmbe84aV55eA6fiRVCAPRmXNhU X-Google-Smtp-Source: AJdET5fziKY3EnRW///d1oN5qmObvULWKzB4nenqod53pl1lvmd80Paj/AclgfzesLJGEPR2yqMgLw== X-Received: by 2002:a62:f715:: with SMTP id h21-v6mr8829130pfi.169.1540678132143; Sat, 27 Oct 2018 15:08:52 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id y1-v6sm17404166pfy.89.2018.10.27.15.08.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 15:08:50 -0700 (PDT) Subject: Re: bug#23120: cp with --dereference (-L) and --link (-l) or --symbolic-link (-s) To: 23120@debbugs.gnu.org References: <56F6661F.9080804@gmail.com> <56F6C64C.4090703@draigBrady.com> From: Assaf Gordon Message-ID: <9ed229b9-c01e-b9a2-9472-7e31f2f1eff7@gmail.com> Date: Sat, 27 Oct 2018 16:08:49 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <56F6C64C.4090703@draigBrady.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) unarchive 15173 merge 23120 15173 tags 23120 fixed close 23120 stop (triaging old bugs) On 2016-03-26 11:26 a.m., Pádraig Brady wrote: > > On 26/03/16 10:36, Petr Skočík wrote: >> >> I'm on a system with cp 8.21, and when I do `cp -Ll` or `cp -Ls` on a >> symlink, it hardlinks (-Ll) or symlinks (-Ls) the symlink instead of the >> target of the symlink. >> > > The -Ll hardlink case was fixed in 8.22 with a bit of > an epic discussion in http://bugs.gnu.org/15173 > > The -Ls symlink case currently just symlinks the source symlink. With no further comments in 2 years, I'm closing this bug. -assaf From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 27 18:10:09 2018 Received: (at control) by debbugs.gnu.org; 27 Oct 2018 22:10:09 +0000 Received: from localhost ([127.0.0.1]:45930 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGWmX-0006t1-2Y for submit@debbugs.gnu.org; Sat, 27 Oct 2018 18:10:09 -0400 Received: from mail-it1-f180.google.com ([209.85.166.180]:38192) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGWmU-0006sC-Rr for control@debbugs.gnu.org; Sat, 27 Oct 2018 18:10:07 -0400 Received: by mail-it1-f180.google.com with SMTP id i76-v6so5597971ita.3 for ; Sat, 27 Oct 2018 15:10:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:message-id:date:user-agent:mime-version:content-language :content-transfer-encoding; bh=ZGT4XKP1ENKm5v473vkdPhaTqT8bGvU6KAJEO1soMDY=; b=uVAcjF8sGBj0nBgM9EseMPLJvva9SRE76AcqaJNggyeI154EqwtPlLP+7BVmdbMSSb ceY0Dy8fSSZg6ws7KOWrSCZOuB9NjrxzVOI0+0EgWgmyalyEqRuL+9Jzd3//gx6/hgvL 7pPL/MPwhaZcuWF7D6HThXMyOvikcp8Rq1rHdeZNs6ywtcn1a6UNaTsOUfWKsjTWiWqm k1+WtZEL0zJkxgX5tmUHnDpek5BssRaxvmq+/xooVROF1FYUzsjm1i34sOgu3AVobfeU IBScExfggiHw3d39tDWbYFtIojsIc+uSq8QMqoeUiDL8dbTq8LpFQ41SmPYDIyN6edrP /Olw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=ZGT4XKP1ENKm5v473vkdPhaTqT8bGvU6KAJEO1soMDY=; b=SMDPlcYalXRAx0pzQh51KXOk8RTpGZBKD+YjvOfo9aOSEeobtHOEmnsJazi0mmtx8Q im/z8096YyjgVy6oQl8xANynqzwV01Z27mNJGgB7OnYJcWQv5ZX4g3Y4wlSwn8ZlesEx UkPB2zKV8WNjEJg6flIvh7w1+NFM1vVNTMC2vJ8LxeM2fAX7TBsmnRJMp8gqvuWAZeF9 tYKwRJv70hwHoHJ5pjgt4OBfxOMuvHYsMcg6lH2XWXmfKLLz/Sx7FXse7Khr9Sz+q0tk 8Zl8OBcfRxfbZpFq8iPlWxeTf7t4p0mP1A60IndrekvAaGTqKEStjAbxr0jsPE69q/+o G5zA== X-Gm-Message-State: AGRZ1gKZt/TEL2tFKfM3YDD5HazdQ0ONNLIidSL6Ec0SswsK9zcyBItM aB5J+t3Q6YkOngsdHn6sTqoZubhE X-Google-Smtp-Source: AJdET5f0bDNwAD8AHdOVeO5KVGXr79qXFRbx2a1PpC397bSxEEWgMhbbXuqMR+DaTs9aThFe6spMYQ== X-Received: by 2002:a24:b645:: with SMTP id d5-v6mr7291600itj.15.1540678200641; Sat, 27 Oct 2018 15:10:00 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id w71-v6sm4041163ita.0.2018.10.27.15.09.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 15:09:59 -0700 (PDT) To: control@debbugs.gnu.org From: Assaf Gordon Message-ID: Date: Sat, 27 Oct 2018 16:09:57 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: merge 23120 15173 [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.166.180 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (assafgordon[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.180 listed in wl.mailspike.net] 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) merge 23120 15173 From unknown Fri Jun 20 07:15:39 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 25 Nov 2018 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator