develooper Front page | perl.perl5.porters | Postings from September 2013

Re: [perl #116451] File::Copy::syscopy doesn't preserve attrs asintended on Linux

Thread Previous
Ricardo Signes
September 6, 2013 03:01
Re: [perl #116451] File::Copy::syscopy doesn't preserve attrs asintended on Linux
Message ID:
* Linda Walsh via RT <> [2013-09-05T22:41:51]
> The difference being -- that on Mac & Win32, the file attribute are
> preserved (include ACL's and extended data and times).

That's odd, how does Mac gets this different behavior?  There is no special
casing for it in the code (or documentation) that I can see.

[type type type]

Actually, this does not appear to be true:

  /etc$ uname -a
  Darwin walrus.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May  1 17:57:12
  PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64
  /etc$ /bin/ls -l -@ ntp.conf
  -rw-r--r--@ 1 root  wheel  22 Oct 22  2010 ntp.conf  15 
  /etc$ perl -MFile::Copy -E 'File::Copy::syscopy("ntp.conf", "$ENV{HOME}/ntp.conf")'
  /etc$ /bin/ls -l -@ ~/ntp.conf
  -rw-r--r--  1 rjbs  rjbs  22 Sep  5 22:51 /Users/rjbs/ntp.conf

> If you even just wanted to preserve the time, all the platforms except 
> unix do this.   But ACL's, Extended attr's and ownership are just as
> important on Unix as on Win/Mac.

I just don't think this is true.  From what I can tell, there are three
platforms that do anything other than what copy does: VMS, OS/2, and Win32.  Of
all the rest of the platforms, most of which fall under the umbrella of "Unix"
(see perlport), syscopy is literally just copy:

  # &syscopy is an XSUB under OS/2
  unless (defined &syscopy) {
      if ($^O eq 'VMS') {
        *syscopy = \&rmscopy;
      } elsif ($^O eq 'MSWin32' && defined &DynaLoader::boot_DynaLoader) {
        # Win32::CopyFile() fill only work if we can load Win32.xs
        *syscopy = sub {
          return 0 unless @_ == 2;
          return Win32::CopyFile(@_, 1);
      } else {
        $Syscopy_is_copy = 1;
        *syscopy = \&copy;

> As for changing Unix to be consistent with Mac & Win -- that would seem
> to make the call more reliable.  As it is now, the behavior is not
> reliable between OS's.  So it can't be used, reliably, in a program to
> get the same effect across OS's.  

I feel somewhat uncomfortable with equating the kind of "everything-preserving
copy" that you get on the three platforms that provide it.  Does rmscopy really
do the same kind of thing that `cp -p` does?  Based on my limited understanding
of VMS, I think the answer is no.

So by making syscopy start to act like `cp -p`, I don't think we're getting
better cross-platform portability.  And then there's the question of whether we
can really guarantee proper cross-platform portability of attribute-preserving
copy across all unixes!  Maybe it's trivial, but to quote a wookiee, "I've got
a bad feeling about this."


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About