void-packages/srcpkgs/gpart/patches/0003-gpart-use-posix_fadvise-to-increase-reading-speed.patch
Đoàn Trần Công Danh 7fc9190f0e srcpkgs/g*: convert patches to -Np1
* gcc is kept at -Np0, because of void-cross

```sh
git grep -l '^patch_args=-Np0' "srcpkgs/$1*/template" |
while read template; do
	for p in ${template%/template}/patches/*; do
		sed -i '
			\,^[+-][+-][+-] /dev/null,b
			/^[*-]\+ [0-9]\+\(,[0-9]\+\)\? [*-]\+$/b
			s,^[*][*][*] ,&a/,
			/^--- /{
				s,\(^--- \)\(./\)*,\1a/,
				s,[.][Oo][Rr][Ii][Gg]\([	/]\),\1,
				s/[.][Oo][Rr][Ii][Gg]$//
				s/[.]patched[.]\([^.]\)/.\1/
				h
			}
			/^+++ -/{
				g
				s/^--- a/+++ b/
				b
			}
			s,\(^+++ \)\(./\)*,\1b/,
		' "$p"
	done
	sed -i '/^patch_args=/d' $template
done
```
2021-06-20 13:17:29 +07:00

42 lines
1.3 KiB
Diff

From b01b124b36f81a76d38eb0169e6d279a777646c9 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@arcor.de>
Date: Thu, 19 Nov 2015 23:24:43 +0100
Subject: [PATCH 3/5] gpart: use posix_fadvise to increase reading speed
Use fadvise to tell the OS to try readahead.
---
configure.ac | 2 +-
src/gpart.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git configure.ac configure.ac
index 6eca1de..21dfc00 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@ AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_MALLOC
-AC_CHECK_FUNCS([getpagesize memset strchr strdup strerror strtoul])
+AC_CHECK_FUNCS([getpagesize memset strchr strdup strerror strtoul posix_fadvise])
# Configure system services.
AC_SYS_LARGEFILE
diff --git src/gpart.c src/gpart.c
index bd3806a..63b36a5 100644
--- a/src/gpart.c
+++ b/src/gpart.c
@@ -949,6 +949,10 @@ static void do_guess_loop(disk_desc *d)
if ((d->d_fd = open(d->d_dev,O_RDONLY)) == -1)
pr(FATAL,EM_OPENFAIL,d->d_dev,strerror(errno));
+#if HAVE_POSIX_FADVISE
+ posix_fadvise(d->d_fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+ posix_fadvise(d->d_fd, 0, 0, POSIX_FADV_WILLNEED);
+#endif /* HAVE_POSIX_FADVISE */
/*
* initialize modules. Each should return the minimum
* size in bytes it wants to receive for a test.
--
2.24.0