]> git.ipfire.org Git - pakfire.git/commitdiff
archive: Tell the kernel that we will read the file sequentially
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 5 Sep 2022 16:24:49 +0000 (16:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 5 Sep 2022 16:24:49 +0000 (16:24 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/archive.c

index a48cbbc219a4255b7a215146393ecf51e20e019d..62499943b89cdf30a448b9bed3155fd7a8a9a50e 100644 (file)
@@ -19,6 +19,7 @@
 #############################################################################*/
 
 #include <errno.h>
+#include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
@@ -608,6 +609,13 @@ static int pakfire_archive_try_open(struct pakfire_archive* archive, const char*
        if (!archive->f)
                return 1;
 
+       // Let the kernel know, that we will read the file sequentially
+       r = posix_fadvise(fileno(archive->f), 0, 0, POSIX_FADV_SEQUENTIAL);
+       if (r) {
+               ERROR(archive->pakfire, "posix_fadvise() failed: %m\n");
+               goto ERROR;
+       }
+
        // Call stat() on f
        r = fstat(fileno(archive->f), &archive->stat);
        if (r) {