summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read_open_fd.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2007-06-26 03:06:48 +0000
committerkientzle <kientzle@FreeBSD.org>2007-06-26 03:06:48 +0000
commit0d5ae862936f390eeabe0d0030d8992f8aef43b0 (patch)
treea05439b0b80a18ac1fe803e9152fa185536a9373 /lib/libarchive/archive_read_open_fd.c
parenta404044c907d9b5f13dccea6e9e518f93fcfa73f (diff)
downloadFreeBSD-src-0d5ae862936f390eeabe0d0030d8992f8aef43b0.zip
FreeBSD-src-0d5ae862936f390eeabe0d0030d8992f8aef43b0.tar.gz
Fix 'bsdtar -t' on tape drives. Libarchive uses the
skip() callback to skip over data when reading uncompressed archives. This gets invoked, for example, during tar -t or tar -x with a filename argument. The revised code only calls [lf]seek() on regular files, instead of depending on the kernel to return an error. Thanks to: bde for explaining the implementation of lseek() Thanks to: Daniel O'Connor for testing Approved by: re (Ken Smith) MFC after: 5 days
Diffstat (limited to 'lib/libarchive/archive_read_open_fd.c')
-rw-r--r--lib/libarchive/archive_read_open_fd.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/libarchive/archive_read_open_fd.c b/lib/libarchive/archive_read_open_fd.c
index 0608fd6..13afe63 100644
--- a/lib/libarchive/archive_read_open_fd.c
+++ b/lib/libarchive/archive_read_open_fd.c
@@ -78,7 +78,8 @@ archive_read_open_fd(struct archive *a, int fd, size_t block_size)
return (ARCHIVE_FATAL);
}
mine->fd = fd;
- mine->can_skip = 1;
+ /* lseek() hardly ever works, so disable it by default. See below. */
+ mine->can_skip = 0;
return (archive_read_open2(a, mine, file_open, file_read, file_skip, file_close));
}
@@ -93,8 +94,18 @@ file_open(struct archive *a, void *client_data)
return (ARCHIVE_FATAL);
}
- if (S_ISREG(st.st_mode))
+ if (S_ISREG(st.st_mode)) {
archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
+ /*
+ * Enabling skip here is a performance optimization for
+ * anything that supports lseek(). On FreeBSD, only
+ * regular files and raw disk devices support lseek() and
+ * there's no portable way to determine if a device is
+ * a raw disk device, so we only enable this optimization
+ * for regular files.
+ */
+ mine->can_skip = 1;
+ }
return (ARCHIVE_OK);
}
OpenPOWER on IntegriCloud