logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: 248736cbce831e8064973bbd08f3cec4a591d654
parent 20dc0e9ae15d0a2c8a216803bcdecca343f34423
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 10 Jun 2025 20:17:29 +0200

cmd/cmp: Use posix_fadvise(3) prior to comparing the contents

Diffstat:

Mcmd/cmp.c4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cmd/cmp.c b/cmd/cmp.c @@ -7,7 +7,7 @@ #include <assert.h> #include <errno.h> -#include <fcntl.h> // open +#include <fcntl.h> // open, posix_fadvise #include <stdbool.h> #include <stdio.h> // fopen, fprintf, getline #include <stdlib.h> // abort, strtoul @@ -234,6 +234,7 @@ main(int argc, char *argv[]) return 1; } + posix_fadvise(fd1, 0, 0, POSIX_FADV_SEQUENTIAL); } if(fd2 != STDIN_FILENO) @@ -250,6 +251,7 @@ main(int argc, char *argv[]) return 1; } + posix_fadvise(fd2, 0, 0, POSIX_FADV_SEQUENTIAL); } int ret = do_cmp(file1, argv[0], file2, argv[1]);