From 666cdfecc983e2bde4c929043fc6dbd598e1e0fb Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sun, 13 Mar 2005 01:47:31 +0000 Subject: 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 --- lib/libarchive/archive_write_open_file.c | 11 +++++++++-- lib/libarchive/archive_write_open_filename.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/libarchive/archive_write_open_file.c b/lib/libarchive/archive_write_open_file.c index 106420f3ed4f..65cdbb604b05 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 106420f3ed4f..65cdbb604b05 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); } -- cgit v1.3