aboutsummaryrefslogtreecommitdiff
path: root/src/xz
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2017-03-30 22:01:54 +0300
committerLasse Collin <lasse.collin@tukaani.org>2017-03-30 22:02:10 +0300
commit2a4b2fa75d06a097261a02ecd3cf2b6d449bf754 (patch)
tree55a04d3f68ac7b5a8c4cdb7928cb7bae9cf140a6 /src/xz
parentliblzma: Fix lzma_memlimit_set(strm, 0). (diff)
downloadxz-2a4b2fa75d06a097261a02ecd3cf2b6d449bf754.tar.xz
xz: Use POSIX_FADV_RANDOM for in "xz --list" mode.
xz --list is random access so POSIX_FADV_SEQUENTIAL was clearly wrong.
Diffstat (limited to 'src/xz')
-rw-r--r--src/xz/file_io.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/xz/file_io.c b/src/xz/file_io.c
index c01f4e8b..041bed88 100644
--- a/src/xz/file_io.c
+++ b/src/xz/file_io.c
@@ -525,7 +525,10 @@ io_open_src_real(file_pair *pair)
#endif
#ifdef HAVE_POSIX_FADVISE
// It will fail if stdin is a pipe and that's fine.
- (void)posix_fadvise(STDIN_FILENO, 0, 0, POSIX_FADV_SEQUENTIAL);
+ (void)posix_fadvise(STDIN_FILENO, 0, 0,
+ opt_mode == MODE_LIST
+ ? POSIX_FADV_RANDOM
+ : POSIX_FADV_SEQUENTIAL);
#endif
return false;
}
@@ -716,7 +719,10 @@ io_open_src_real(file_pair *pair)
#ifdef HAVE_POSIX_FADVISE
// It will fail with some special files like FIFOs but that is fine.
- (void)posix_fadvise(pair->src_fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+ (void)posix_fadvise(pair->src_fd, 0, 0,
+ opt_mode == MODE_LIST
+ ? POSIX_FADV_RANDOM
+ : POSIX_FADV_SEQUENTIAL);
#endif
return false;