GNU bug report logs - #9513
cp -p fails to preserve permissions

Previous Next

Package: coreutils;

Reported by: Charles ELSAESSER WebmailOrange <charles.elsaesser <at> wanadoo.fr>

Date: Thu, 15 Sep 2011 13:24:01 UTC

Severity: normal

Tags: moreinfo

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9513 in the body.
You can then email your comments to 9513 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#9513; Package coreutils. (Thu, 15 Sep 2011 13:24:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Charles ELSAESSER WebmailOrange <charles.elsaesser <at> wanadoo.fr>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Thu, 15 Sep 2011 13:24:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Charles ELSAESSER WebmailOrange <charles.elsaesser <at> wanadoo.fr>
To: bug-coreutils <at> gnu.org
Subject: improvement remark for "cp"
Date: Thu, 15 Sep 2011 14:23:23 +0200 (CEST)
Bonjour,

Here is bug report.
Thank you for what can be done.

symptom
-------

cp -p file1 file2

does not preserve timestamp.

ls -l file1 file2
-rwxr-xr-x. 1 joe joe 11626 9 sept. 23:20 file2
-rwxr-xr-x. 1 joe joe 11626 9 sept. 23:20 file1

ls --full-time $f1 $f2
-rwxr-xr-x. 1 joe joe 11626 2011-09-09 19:20:27.000000000 +0200 file2
-rwxr-xr-x. 1 joe joe 11626 2011-09-09 19:20:26.000000000 +0200 file1

cmp $f1 $f2
echo $?
0


comment
-------

French man page says that timestamp will be slightly different between original and copy
because copy operation needs a read access to source file.

On the documentation point of view, this seems to be a wrong expression because reading timestamp original file
needs a read access to structures of directory containing original file,
which helds the last access time actime and the last modification time mtime
but not to file itself.

But after processing of "cp -p file1 file2" , the different timestamps between the two files seems to be not conform to the "cp -p " functionality.

Actually, if copy process of "file1" on "file2" is long ( minutes, hours, ...)
when destination hardwares are slow,
then timestamps can be very different.

Am I wrong?

As a consequence when processing after this a
cp -u file1 file2
update is not processed because destination file is newer than original file.

Other consequences may happen on files management applications.

action
------

At least user should be warned by a mention in man page of "cp" of existence of function "touch" which seems to execute the timestamp setting, if requested.

When user requires "cp -p" he cannot suspect that his requirement will not be executed.

Can anything be done to correct GNU "cp" function, for example processing a "touch" like function ?

system technical level
----------------------
SLinux localhost 2.6.32-131.12.1.el6.i686 #1 SMP Tue Aug 23 11:12:55 CDT 2011 i686 i686 i386 GNU/Linux

software technical level
------------------------
cp (GNU coreutils) 8.4
GNU coreutils 8.4 November 2010 CP(1)

man documentation level ( french)
---------------------------------

TRADUCTION
Ce document est une traduction réalisée par Christophe Blaess
le 5 décembre 1996, mise à jour par Alain
Portal  le 8 juillet 2005 et révisée le
19 novembre 2007.
i.e.

TRANSLATION
This document is a translation processed by Christophe Blaess
on 5 december 1996, updated by Alain
Portal  on 8 july 2005 and revised on
19 novembre 2007.

comments in man documentation ( french)
---------------------------------------

OPTIONS POSIX
Posix définit quatre options et demi :
...
-p Conserver le propriétaire, le groupe, les permissions d’accès et les
horodatages du fichier original. Si la conservation du propriétaire ou
du groupe est impossible, les bits Set-UID et Set-GID sont effacés.
L’horodatage sera quand même légèrement différent entre l’original et
la copie car l’opération de copie nécessite un accès en lecture au
fichier source.
...
OPTIONS GNU
...
-p, --preserve
Conserver le propriétaire, le groupe, les permissions d’accès et les
horodatages du fichier original.
...
i.e. ( french comments translated to english)

OPTIONS POSIX
Posix defines four options and a half :
...
-p Keep owner,group, access rights and timestamps of original file.
If owner or group cannot be kept, then bits Set-UID and Set-GID are erased.
Timestamp may be slightly different between original and copy
because copy operation needs a read access to source file.
...
OPTIONS GNU
...
-p, --preserve
Keep owner, group, access rights and timestamp of original file.




Information forwarded to owner <at> debbugs.gnu.org, bug-coreutils <at> gnu.org:
bug#9513; Package coreutils. (Thu, 15 Sep 2011 16:47:01 GMT) Full text and rfc822 format available.

Message #8 received at 9513 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Charles ELSAESSER WebmailOrange <charles.elsaesser <at> wanadoo.fr>
Cc: 9513 <at> debbugs.gnu.org
Subject: Re: bug#9513: improvement remark for "cp"
Date: Thu, 15 Sep 2011 09:41:52 -0700
On 09/15/11 05:23, Charles ELSAESSER WebmailOrange wrote:
> cp -p file1 file2
> 
> does not preserve timestamp.

That looks like a bug.

Can you please try it with coreutils 8.13?  That has some
fixes in this area; the version you're using (8.4) is a bit old.

ftp://ftp.gnu.org/gnu/coreutils/coreutils-8.13.tar.gz

If you're still seeing the problem with 8.13, can you
please send your config.log (when building coreutils)
and the output of the shell command "strace cp -p file1 file2"?
Thanks.




Information forwarded to bug-coreutils <at> gnu.org:
bug#9513; Package coreutils. (Sun, 13 Nov 2011 11:50:01 GMT) Full text and rfc822 format available.

Message #11 received at 9513 <at> debbugs.gnu.org (full text, mbox):

From: Jim Meyering <jim <at> meyering.net>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 9513 <at> debbugs.gnu.org,
	Charles ELSAESSER WebmailOrange <charles.elsaesser <at> wanadoo.fr>
Subject: Re: bug#9513: improvement remark for "cp"
Date: Sun, 13 Nov 2011 12:48:51 +0100
retitle 9513 cp -p fails to preserve permissions
tags 9513 + moreinfo
thanks

Paul Eggert wrote:
> On 09/15/11 05:23, Charles ELSAESSER WebmailOrange wrote:
>> cp -p file1 file2
>>
>> does not preserve timestamp.
>
> That looks like a bug.
>
> Can you please try it with coreutils 8.13?  That has some
> fixes in this area; the version you're using (8.4) is a bit old.
>
> ftp://ftp.gnu.org/gnu/coreutils/coreutils-8.13.tar.gz
>
> If you're still seeing the problem with 8.13, can you
> please send your config.log (when building coreutils)
> and the output of the shell command "strace cp -p file1 file2"?

Hello Charles,

The latest release is now coreutils-8.14.
Would you please try to reproduce the problem using that version
and send us the information that Paul requested?




Changed bug title to 'cp -p fails to preserve permissions' from 'improvement remark for "cp"' Request was from Jim Meyering <jim <at> meyering.net> to control <at> debbugs.gnu.org. (Sun, 13 Nov 2011 11:50:02 GMT) Full text and rfc822 format available.

Added tag(s) moreinfo. Request was from Jim Meyering <jim <at> meyering.net> to control <at> debbugs.gnu.org. (Sun, 13 Nov 2011 11:50:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#9513; Package coreutils. (Tue, 23 Oct 2018 03:11:02 GMT) Full text and rfc822 format available.

Message #18 received at 9513 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: 9513 <at> debbugs.gnu.org
Subject: Re: bug#9513: improvement remark for "cp"
Date: Mon, 22 Oct 2018 21:10:36 -0600
close 9513
stop

(triaging old bugs)

On 13/11/11 04:48 AM, Jim Meyering wrote:
> Paul Eggert wrote:
>> On 09/15/11 05:23, Charles ELSAESSER WebmailOrange wrote:
>>> cp -p file1 file2
>>>
>>> does not preserve timestamp.
>>
>> That looks like a bug.
>>
>> Can you please try it with coreutils 8.13?  That has some
>> fixes in this area; the version you're using (8.4) is a bit old.
>>
> Hello Charles,
> The latest release is now coreutils-8.14.
> Would you please try to reproduce the problem using that version
> and send us the information that Paul requested?
> 


With no follow-ups in 7 years, I'm closing this bug.

-assaf






bug closed, send any further explanations to 9513 <at> debbugs.gnu.org and Charles ELSAESSER WebmailOrange <charles.elsaesser <at> wanadoo.fr> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 23 Oct 2018 03:11:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 20 Nov 2018 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 269 days ago.

Previous Next


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