diff options
author | kientzle <kientzle@FreeBSD.org> | 2008-07-01 05:45:03 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2008-07-01 05:45:03 +0000 |
commit | 4068ef17cb788c294a763796d62b43b9bbc29808 (patch) | |
tree | 85b6064ca20e554cad558a643974a5886c783e48 /usr.bin/cpio/cpio.c | |
parent | 5a79d28b35e00e62af96e45a2d6be274f0d40131 (diff) | |
download | FreeBSD-src-4068ef17cb788c294a763796d62b43b9bbc29808.zip FreeBSD-src-4068ef17cb788c294a763796d62b43b9bbc29808.tar.gz |
Don't try to hardlink directories. While I'm here, expand some
comments to make this section of code a little clearer.
Diffstat (limited to 'usr.bin/cpio/cpio.c')
-rw-r--r-- | usr.bin/cpio/cpio.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.bin/cpio/cpio.c b/usr.bin/cpio/cpio.c index 249f5ce..c5d86d7 100644 --- a/usr.bin/cpio/cpio.c +++ b/usr.bin/cpio/cpio.c @@ -535,16 +535,23 @@ entry_to_archive(struct cpio *cpio, struct archive_entry *entry) fprintf(stderr,"%s", destpath); /* - * Obviously, this only gets invoked in pass mode. + * Obviously, this only gets invoked in pass mode, since + * option_link is nonsense otherwise. Note that we can't + * hardlink dirs, and that if a link operation fails (because + * of cross-device restrictions), we'll fall back to copy mode + * for that entry. */ - if (cpio->option_link) { + if (cpio->option_link + && archive_entry_filetype(entry) != AE_IFDIR) + { struct archive_entry *t; /* Save the original entry in case we need it later. */ t = archive_entry_clone(entry); if (t == NULL) cpio_errc(1, ENOMEM, "Can't create link"); /* Note: link(2) doesn't create parent directories, - * so we use archive_write_header() instead. */ + * so we use archive_write_header() instead as a + * convenience. */ archive_entry_set_hardlink(t, srcpath); /* This is a straight link that carries no data. */ archive_entry_set_size(t, 0); |