diff options
author | kientzle <kientzle@FreeBSD.org> | 2005-03-13 01:47:31 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2005-03-13 01:47:31 +0000 |
commit | ebf75b4df5a9f42d3bbf6ab357ced195a26b3212 (patch) | |
tree | 5b47c481309a322d856646b9a64690debc22b66c /lib/libarchive | |
parent | 21240a6daf5497baf0d15c2c75c104e72760a7df (diff) | |
download | FreeBSD-src-ebf75b4df5a9f42d3bbf6ab357ced195a26b3212.zip FreeBSD-src-ebf75b4df5a9f42d3bbf6ab357ced195a26b3212.tar.gz |
If the output is not a regular file, it's okay to add it to the archive.
In particular, /dev/st0 can be added to an archive being written to /dev/st0.
Thanks to: Jaakko Heinonen
Diffstat (limited to 'lib/libarchive')
-rw-r--r-- | lib/libarchive/archive_write_open_file.c | 11 | ||||
-rw-r--r-- | lib/libarchive/archive_write_open_filename.c | 11 |
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/libarchive/archive_write_open_file.c b/lib/libarchive/archive_write_open_file.c index 106420f..65cdbb6 100644 --- a/lib/libarchive/archive_write_open_file.c +++ b/lib/libarchive/archive_write_open_file.c @@ -125,8 +125,15 @@ file_open(struct archive *a, void *client_data) return (ARCHIVE_FATAL); } - a->skip_file_dev = pst->st_dev; - a->skip_file_ino = pst->st_ino; + /* + * If the output file is a regular file, don't add it to + * itself. If it's a device file, it's okay to add the device + * entry to the output archive. + */ + if (S_ISREG(pst->st_mode)) { + a->skip_file_dev = pst->st_dev; + a->skip_file_ino = pst->st_ino; + } return (ARCHIVE_OK); } diff --git a/lib/libarchive/archive_write_open_filename.c b/lib/libarchive/archive_write_open_filename.c index 106420f..65cdbb6 100644 --- a/lib/libarchive/archive_write_open_filename.c +++ b/lib/libarchive/archive_write_open_filename.c @@ -125,8 +125,15 @@ file_open(struct archive *a, void *client_data) return (ARCHIVE_FATAL); } - a->skip_file_dev = pst->st_dev; - a->skip_file_ino = pst->st_ino; + /* + * If the output file is a regular file, don't add it to + * itself. If it's a device file, it's okay to add the device + * entry to the output archive. + */ + if (S_ISREG(pst->st_mode)) { + a->skip_file_dev = pst->st_dev; + a->skip_file_ino = pst->st_ino; + } return (ARCHIVE_OK); } |