cpio -l fails to revert to copy-mode

Tim Kientzle kientzle at freebsd.org
Fri Jun 20 05:24:27 UTC 2008


Pietro Cerutti wrote:
> ~> cpio -dumpl /tmp/
> test
> cpio: Can't create '/tmp/test': Cross-device link: Cross-device link

Try the following patch and let me know if it works for you.
The error messages are a little funky, but the behavior
seems to roughly follow GNU cpio.  I'm tempted to clear
the link option here so that after the first EXDEV error,
cpio won't even bother trying to link subsequent files.
That should be slightly more efficient in the common case
(where you're copying a whole tree across devices) but
will change behavior in the very uncommon case where the
target is partially on the same device and partially on
a different device.  This would differ from GNU cpio,
which spits out the same warning for every cross-device
link.

==== src/usr.bin/cpio/cpio.c ====
@@ -545,6 +545,12 @@
                             archive_error_string(cpio->archive));
                 if (r == ARCHIVE_FATAL)
                         exit(1);
+#ifdef EXDEV
+               if (r != ARCHIVE_OK && archive_errno(cpio->archive) == 
EXDEV) {
+                       cpio_warnc(0, "Copying file instead");
+                       archive_entry_set_hardlink(entry, NULL);
+               } else
+#endif
                 return (0);
         }


More information about the freebsd-current mailing list