bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

preserve option on "cp" is screwey


From: blaander
Subject: preserve option on "cp" is screwey
Date: Thu, 22 May 2003 14:22:54 -0500

My Lotus Notes is messed up and I wanted to make sure this was going out as
plain text, so I'm sending it again.

I have a remote file system that is mounted on 6 linux machines.  Four of
my machines are running Linux  2.4.18-14 from RedHat.  The other 2 are
running Linux 2.4.2-2, also from RedHat.

I wrote some scripts that use "cp" to get files copied around, using the
network attached storage device as the target.  The way the file system is
set up on the NAS, anything I put there is automatically given permissions
777.  This is what my IT dept decided to do, not my idea :-)

Anyway, I wanted to copy a directory recursively and force overwrite.  I
also wanted to keep the timestamps on the files (and directories) as they
were.  I started working on the older machine with version fileutils
version 4.0.36 (it came with linux).  I used
   cp -frp    OLDDIR    NEWOLDDIR

The thing yelled back to me that it could not set permissions on the FILES
OR DIRECTORIES, but the files and directories were all copied and the dates
were right , so I let it slide.  The logging was extrememly messy, so it
was somewhat bothersome.  Here's a sample:

   address@hidden:[bin]$cp -rfp SOME_DIR NEW_DIR
      cp: setting permissions for `NEW_DIR/Some_file': Operation not
permitted
      cp: setting permissions for `NEW_DIR': Operation not permitted
   address@hidden:[bin]$ls -al
      drwxrwxrwx    4 blaander genusers     4096 May 22 14:06 .
      drwxrwxrwx    6 blaander genusers     4096 May 22 13:59 ..
      drwxrwxrwx    2 blaander genusers     4096 May 22 14:02 NEW_DIR
      drwxrwxrwx    2 blaander genusers     4096 May 22 14:02 SOME_DIR

Well, I then happened to be on one of the newer machines one day and did a
man on "cp" and saw that in the newer version of fileutils (4.1.9) I could
tell it to preserve only timestamps if I wanted.  So, I used
   cp -rf --preserve=timestamps    OLDDIR   NEWDIR

The results was that all of my pages and pages of log messages were GONE.
It worked great.  However, on the older linux machines I couldn't use this
format because the "--preserve-timestamps" option wasn't available on that
version of "cp".  So, my script wasn't yet portable between my 6 linux
machines, and making it portable by changing the option on the older
machines meant that the error messages would again come back.

I downloaded the source for 4.1.10 version of fileutils and compiled them
on the old machine.  I was able to compile them and use them, and I saw
that the "--preserve[=ATTR_LIST]" option was available.  However, I still
got the same warnings, even though I wasn't trying to save all of the
properties.  I just wanted to save the timestamps using the command just
above here.  The sample output is below:

   address@hidden:[bin]$newcp -rf --preserve=timestamps SOME_DIR NEW_DIR
      newcp: setting permissions for `NEW_DIR': Operation not permitted

Note that the warning for the FILE (NEW_DIR/Somefile) went away.  I only
got a warning on the directory this time.  It was interesting.  This new
"cp" that was compiled on the old machines gave a similar result when run
on the new machines -- all files and directories were copied with the
correct timestamp, but there were warnings for every single DIRECTORY (no
file warnings) about the permissions.  Compiling the new (4.1.10) version
of 'cp' on the newer machines and then running it there didn't help either.
Same error that you see directly above.

So, my question is this:  How come the 4.1.9 version that came with RedHat
doesn't give me problems, but the old one does?  How come the new one gives
me headaches as well, but just on directories, and not on files?

Basically, my output from the script is a mungled mess if I allow all of
those warnings that don't mean anything.  I could always only use the
built-in 'cp' command on the new machine exclusively, and not use the old
machines, but I know that in 3 months when I'm no longer working on this
project someone else will try to run the scripts with the older machines,
and they'll wonder why they get all of the 'errors'.

If anyone here knows the answer, I'd really appreciate it.  I don't have
access to the message board newsgroup thing from here at work, so if you
could email me at address@hidden, I'd appreciate it.  Thanks

-Brian







reply via email to

[Prev in Thread] Current Thread [Next in Thread]