"cp" behaves strangly when overwriting a file

Hervé Pagès <[email protected]> Wed, 16 Apr 2003 19:19:10 +0200
Newsgroups gmane.comp.gnu.fileutils.bugs
Message-ID <[email protected]>
Hi,

It seems that overwriting an existing file with "cp" doesn't
exactly replace the old one by the new one but preserves the
old one and only replaces its content!


EXAMPLE: The file "toto" is not mine but is in my home:

   $ id
   uid=1003(hpages) gid=100(users) groups=100(users)

   $ umask
   0022

   $ cd
   $ ls -l toto
   -rw-rw-rw-  1 stranger  www       293 Apr 16 19:08 toto

I am NOT 'stranger' and I don't belong to group 'www'
but I have write permission on file 'toto'.

Now I want to override 'toto' with some file (I could also
do it with one of my files) :

   $ ls -l /home/bush/somefile
   -rw-r--r--  1 bush      apache   1534 Apr 10 17:20 /home/bush/somefile

   $ cp /home/bush/somefile toto -i
   cp: overwrite `toto'? y

   $ ls -l toto
   -rw-rw-r--  1 stranger  www      1534 Apr 16 19:25 toto

Ownership and mode have been preserved! Only content and
mtime have changed.

In case file 'toto' did not exist, I would have obtained:

   $ ls -l toto
   -rw-r--r--  1 hpages    users    1534 Apr 16 19:25 toto

I just wonder if this is a normal behaviour...


MY SYSTEM IS: Red Hat 8.0

   $ rpm -q fileutils
   fileutils-4.1.9-11

My /home partition is ext3 formatted.

-- 
Hervé Pagès
[email protected]
CIR-BDD Bureau 93
INRP Paris
Tél : 01.46.34.90.42
Fax : 01.46.34.90.46