diff options
Diffstat (limited to 'lib/libarchive/archive_read_open_fd.c')
-rw-r--r-- | lib/libarchive/archive_read_open_fd.c | 15 |
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); } |