]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz: Use POSIX_FADV_RANDOM for in "xz --list" mode.
authorLasse Collin <lasse.collin@tukaani.org>
Thu, 30 Mar 2017 19:01:54 +0000 (22:01 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Thu, 30 Mar 2017 19:01:54 +0000 (22:01 +0300)
xz --list is random access so POSIX_FADV_SEQUENTIAL was clearly
wrong.

src/xz/file_io.c

index c01f4e8bb99ddc34d9bf6aed0a0eac6f9ef946f3..041bed88e0067a81c3cf5ca56a2f0f45ccab5ac3 100644 (file)
@@ -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;