GNU bug report logs - #47059
bug in cp removing destination file when it can't be replaced due to cross-volume linking

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Reported by: L A Walsh <coreutils@HIDDEN>; Keywords: moreinfo; dated Wed, 10 Mar 2021 21:42:01 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.
Added tag(s) moreinfo. Request was from Paul Eggert <eggert@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 47059 <at> debbugs.gnu.org:


Received: (at 47059) by debbugs.gnu.org; 21 Feb 2022 09:18:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 21 04:18:54 2022
Received: from localhost ([127.0.0.1]:35046 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1nM4qL-0003Vy-OC
	for submit <at> debbugs.gnu.org; Mon, 21 Feb 2022 04:18:53 -0500
Received: from zimbra.cs.ucla.edu ([131.179.128.68]:47594)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eggert@HIDDEN>) id 1nM4qJ-0003Vh-3C
 for 47059 <at> debbugs.gnu.org; Mon, 21 Feb 2022 04:18:52 -0500
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id AB6B6160103;
 Mon, 21 Feb 2022 01:18:44 -0800 (PST)
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032)
 with ESMTP id RsRK57akkv8h; Mon, 21 Feb 2022 01:18:44 -0800 (PST)
Received: from localhost (localhost [127.0.0.1])
 by zimbra.cs.ucla.edu (Postfix) with ESMTP id F4126160106;
 Mon, 21 Feb 2022 01:18:43 -0800 (PST)
X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu
Received: from zimbra.cs.ucla.edu ([127.0.0.1])
 by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026)
 with ESMTP id s5rLlPKh6vax; Mon, 21 Feb 2022 01:18:43 -0800 (PST)
Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com
 [172.91.119.151])
 by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id CE821160103;
 Mon, 21 Feb 2022 01:18:43 -0800 (PST)
Message-ID: <4b389613-5863-2bfe-6f8c-af50676e861d@HIDDEN>
Date: Mon, 21 Feb 2022 01:18:43 -0800
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.5.0
Content-Language: en-US
To: L A Walsh <coreutils@HIDDEN>
References: <60493CF1.3010209@HIDDEN>
From: Paul Eggert <eggert@HIDDEN>
Organization: UCLA Computer Science Department
Subject: Re: bug#47059: bug in cp removing destination file when it can't be
 replaced due to cross-volume linking
In-Reply-To: <60493CF1.3010209@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 47059
Cc: 47059 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

I can't reproduce the problem with either coreutils 8.23 or 9.0. 
Unfortunately, the original bug report does not have a recipe for 
reproducing the problem from scratch, without having access to your 
system. If you could come up with the a self-contained way to reproduce 
the problem with current coreutils, that would be helpful.

> When creating a link to a local file, I
> first create the link to a temporary name to ensure I have
> appropriate access (or that its not cross-linked in this
> case).  Apparently 'cp' doesn't exercise the same caution.

Actually, cp -l is even more cautious than the procedure you describe. 
If the destination already exists, cp -l fails without altering the 
destination.

$ echo a >abc
$ echo bb >/tmp/def
$ cp -l abc /tmp/def
cp: cannot create hard link '/tmp/def' to 'abc': File exists
$ ls -l abc /tmp/def
-rw-rw-r-- 1 eggert eggert 3 Feb 21 01:13 /tmp/def
-rw-rw-r-- 1 eggert eggert 2 Feb 21 01:13 abc

Hence the symptoms you reported are mysterious; I don't see how they 
could have happened.




Information forwarded to bug-coreutils@HIDDEN:
bug#47059; Package coreutils. Full text available.
Disconnected #48002 from all other report(s). Request was from Paul Eggert <eggert@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Disconnected #47883 from all other report(s). Request was from Paul Eggert <eggert@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Merged 47059 47883 48002. Request was from Paul Eggert <eggert@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 11 Mar 2021 19:23:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 11 14:23:38 2021
Received: from localhost ([127.0.0.1]:54925 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lKQuH-0001hk-Os
	for submit <at> debbugs.gnu.org; Thu, 11 Mar 2021 14:23:38 -0500
Received: from lists.gnu.org ([209.51.188.17]:49344)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <coreutils@HIDDEN>) id 1lKQuG-0001hc-5g
 for submit <at> debbugs.gnu.org; Thu, 11 Mar 2021 14:23:36 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:42416)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <coreutils@HIDDEN>)
 id 1lKQuF-0005il-TF
 for bug-coreutils@HIDDEN; Thu, 11 Mar 2021 14:23:35 -0500
Received: from ishtar.tlinx.org ([173.164.175.65]:54986
 helo=Ishtar.sc.tlinx.org)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <coreutils@HIDDEN>)
 id 1lKQuC-00087t-9Y
 for bug-coreutils@HIDDEN; Thu, 11 Mar 2021 14:23:35 -0500
Received: from [192.168.3.12] (Athenae [192.168.3.12])
 by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id
 12BJNRYQ044359
 for <bug-coreutils@HIDDEN>; Thu, 11 Mar 2021 11:23:30 -0800
Message-ID: <604A6E30.8040907@HIDDEN>
Date: Thu, 11 Mar 2021 11:23:28 -0800
From: L A Walsh <coreutils@HIDDEN>
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
To: Coreutils <bug-coreutils@HIDDEN>
Subject: Re: bug#47059: (bug in cp removing destination file when it can't
 be replaced due to cross-volume linking)
References: <60493CF1.3010209@HIDDEN>
 <handler.47059.B.16154124842889.ack <at> debbugs.gnu.org>
In-Reply-To: <handler.47059.B.16154124842889.ack <at> debbugs.gnu.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=173.164.175.65; envelope-from=coreutils@HIDDEN;
 helo=Ishtar.sc.tlinx.org
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

Did anyone see this?  Usually someone says something like
confirming it or asking for more info.

Is this a known bug and/or has it been seen before?

(slightly cleaned up report below)

Thanks!

On 2021/03/10 13:41, L A Walsh wrote:
> Was trying to save disk space by linking duplicate files, in a dir.=20
> FWIW, my 'cp', is aliased to 'cp --preserve=3Dall'
>=20
>>  for f in Roboto*.ttf;do > cp -l /usr/share/fonts/TTF/$f .; done
> cp: cannot create hard link './Roboto-Bold.ttf' to=20
> '/usr/share/fonts/TTF/Roboto-Bold.ttf': Invalid cross-device link
> =E2=80=A6
> cp: cannot create hard link './RobotoSlab-Thin.ttf' to=20
> '/usr/share/fonts/TTF/RobotoSlab-Thin.ttf': Invalid cross-device link
> ----
>     Well that didn't work, guess I'll copy over the affected files.
>
>     Repeating command w/o "-l":
>
> Ishtar:=E2=80=A6/3.1.16055.164_0> for f in Roboto*.ttf; do=20
> cp /usr/share/fonts/TTF/$f . ; done
> cp: cannot access '/usr/share/fonts/TTF/Roboto*.ttf': No such file or d=
irectory
> ---
> Huh?...all of the files were deleted!
>
> That's not good.  When creating a link to a local file, I
> first create the link to a temporary name in the same directory
> to ensure I have appropriate access (or that its not cross-linked
> as in this case).  Apparently 'cp' doesn't exercise the same caution.
> It seems 'cp' deletes the target first (as it was linked to some
> other file), but then can't perform the requested copy-link, so
> leaves the target location with no file at all.
>
> Is this fixed in a newer core utils version?
> coreutils-8.23-2.3.2.x86_64





Information forwarded to bug-coreutils@HIDDEN:
bug#47059; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 10 Mar 2021 21:41:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 10 16:41:24 2021
Received: from localhost ([127.0.0.1]:52011 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lK6a4-0000kX-8j
	for submit <at> debbugs.gnu.org; Wed, 10 Mar 2021 16:41:24 -0500
Received: from lists.gnu.org ([209.51.188.17]:46774)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <coreutils@HIDDEN>) id 1lK6a2-0000kQ-F1
 for submit <at> debbugs.gnu.org; Wed, 10 Mar 2021 16:41:22 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:60010)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <coreutils@HIDDEN>)
 id 1lK6Zy-0001XN-SU
 for bug-coreutils@HIDDEN; Wed, 10 Mar 2021 16:41:20 -0500
Received: from ishtar.tlinx.org ([173.164.175.65]:58764
 helo=Ishtar.sc.tlinx.org)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <coreutils@HIDDEN>)
 id 1lK6Zq-00028o-7V
 for bug-coreutils@HIDDEN; Wed, 10 Mar 2021 16:41:18 -0500
Received: from [192.168.3.12] (Athenae [192.168.3.12])
 by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id
 12ALf50f075856
 for <bug-coreutils@HIDDEN>; Wed, 10 Mar 2021 13:41:07 -0800
Message-ID: <60493CF1.3010209@HIDDEN>
Date: Wed, 10 Mar 2021 13:41:05 -0800
From: L A Walsh <coreutils@HIDDEN>
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
To: Coreutils <bug-coreutils@HIDDEN>
Subject: bug in cp removing destination file when it can't be replaced due
 to cross-volume linking
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=173.164.175.65; envelope-from=coreutils@HIDDEN;
 helo=Ishtar.sc.tlinx.org
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

Was trying to save disk space by linking duplicate
files, in a dir.=20
FWIW, my 'cp', is aliased to 'cp --preserve=3Dall'

>  for f in Roboto*.ttf;do
cp -l /usr/share/fonts/TTF/$f .
>  done
cp: cannot create hard link './Roboto-Bold.ttf' to=20
'/usr/share/fonts/TTF/Roboto-Bold.ttf': Invalid cross-device link
cp: cannot create hard link './Roboto-Italic.ttf' to=20
'/usr/share/fonts/TTF/Roboto-Italic.ttf': Invalid cross-device link
cp: cannot create hard link './Roboto-Light.ttf' to=20
'/usr/share/fonts/TTF/Roboto-Light.ttf': Invalid cross-device link
cp: cannot create hard link './Roboto-Medium.ttf' to=20
'/usr/share/fonts/TTF/Roboto-Medium.ttf': Invalid cross-device link
cp: cannot create hard link './Roboto-Regular.ttf' to=20
'/usr/share/fonts/TTF/Roboto-Regular.ttf': Invalid cross-device link
cp: cannot create hard link './RobotoCondensed-Bold.ttf' to=20
'/usr/share/fonts/TTF/RobotoCondensed-Bold.ttf': Invalid cross-device lin=
k
cp: cannot create hard link './RobotoCondensed-Light.ttf' to=20
'/usr/share/fonts/TTF/RobotoCondensed-Light.ttf': Invalid cross-device li=
nk
cp: cannot create hard link './RobotoCondensed-Regular.ttf' to=20
'/usr/share/fonts/TTF/RobotoCondensed-Regular.ttf': Invalid cross-device =

link
cp: cannot create hard link './RobotoSlab-Bold.ttf' to=20
'/usr/share/fonts/TTF/RobotoSlab-Bold.ttf': Invalid cross-device link
cp: cannot create hard link './RobotoSlab-Light.ttf' to=20
'/usr/share/fonts/TTF/RobotoSlab-Light.ttf': Invalid cross-device link
cp: cannot create hard link './RobotoSlab-Regular.ttf' to=20
'/usr/share/fonts/TTF/RobotoSlab-Regular.ttf': Invalid cross-device link
cp: cannot create hard link './RobotoSlab-Thin.ttf' to=20
'/usr/share/fonts/TTF/RobotoSlab-Thin.ttf': Invalid cross-device link
----
    Well that didn't work, guess I'll copy over the affected files.

    Repeating command w/o "-l":

Ishtar:=E2=80=A6/3.1.16055.164_0> for f in Roboto*.ttf
do
cp -l /usr/share/fonts/TTF/$f .
done
Ishtar:=E2=80=A6/3.1.16055.164_0> ll Roboto*
ls: cannot access 'Roboto*': No such file or directory
---
Huh?...all of the files were deleted!

That's not good.  When creating a link to a local file, I
first create the link to a temporary name to ensure I have
appropriate access (or that its not cross-linked in this
case).  Apparently 'cp' doesn't exercise the same caution.
It seems 'cp' deletes the target first (as
it was linked to some other file), but then can't
perform the requested copy-link, so leaves the
target location with no file at all.

Um...not good.
Is this fixed in a newer core utils version?
coreutils-8.23-2.3.2.x86_64






Acknowledgement sent to L A Walsh <coreutils@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#47059; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 25 Feb 2022 18:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.