lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Thu,  2 Jan 2014 08:55:28 +0200
From:	Baruch Siach <baruch@...s.co.il>
To:	Theodore Ts'o <tytso@....edu>
Cc:	linux-ext4@...r.kernel.org, Baruch Siach <baruch@...s.co.il>
Subject: [PATCH] e4defrag: choose the best available posix_fadvise variant

Use posix_fadvise64() when available. This allows 64bit offsets on 32bit
systems.

Rename the internal posix_fadvise() implementation to avoid collision with the
C library signature that is sometimes present event when the implementation
itself is not. This fixes build errors like:

e4defrag.c:189:2: warning: #warning Using locally defined posix_fadvise interface. [-Wcpp
e4defrag.c:203:12: error: conflicting types for ‘posix_fadvise’

Signed-off-by: Baruch Siach <baruch@...s.co.il>
---
v2: fix #endif comment
---
 configure.in    |  1 +
 misc/e4defrag.c | 29 ++++++++++++++++++++++-------
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/configure.in b/configure.in
index fef8d9b7b935..9f13a46ac8ae 100644
--- a/configure.in
+++ b/configure.in
@@ -1102,6 +1102,7 @@ AC_CHECK_FUNCS(m4_flatten([
 	open64
 	pathconf
 	posix_fadvise
+	posix_fadvise64
 	posix_memalign
 	prctl
 	secure_getenv
diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index c6a5f0daef96..7ad324b48fd2 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -183,13 +183,27 @@ static ext4_fsblk_t	files_block_count;
 static struct frag_statistic_ino	frag_rank[SHOW_FRAG_FILES];
 
 
-/* Local definitions of some syscalls glibc may not yet have */
+/* Local definitions of some syscalls glibc may not yet have
+ *
+ * We prefer posix_fadvise64 when available, as it allows 64bit offset on
+ * 32bit systems
+ */
+
+#if defined(HAVE_POSIX_FADVISE64)
+#define posix_fadvise	posix_fadvise64
+#elif defined(__NR_fadvise64_64)
+#define FADVISE_SYSCALL_NR	__NR_fadvise64_64
+#elif defined(HAVE_POSIX_FADVISE)
+#define posix_fadvise	posix_fadvise
+#elif defined(__NR_fadvise64)
+#define FADVISE_SYSCALL_NR	__NR_fadvise64
+#endif
 
-#ifndef HAVE_POSIX_FADVISE
+#ifndef posix_fadvise
 #warning Using locally defined posix_fadvise interface.
 
-#ifndef __NR_fadvise64_64
-#error Your kernel headers dont define __NR_fadvise64_64
+#ifndef FADVISE_SYSCALL_NR
+#error Your kernel headers dont define __NR_fadvise64_64 or __NR_fadvise64
 #endif
 
 /*
@@ -200,11 +214,12 @@ static struct frag_statistic_ino	frag_rank[SHOW_FRAG_FILES];
  * @len:		area length.
  * @advise:		process flag.
  */
-static int posix_fadvise(int fd, loff_t offset, size_t len, int advise)
+#define posix_fadvise	__posix_fadvise
+static int __posix_fadvise(int fd, loff_t offset, size_t len, int advise)
 {
-	return syscall(__NR_fadvise64_64, fd, offset, len, advise);
+	return syscall(FADVISE_SYSCALL_NR, fd, offset, len, advise);
 }
-#endif /* ! HAVE_FADVISE64_64 */
+#endif /* ! posix_fadvise */
 
 #ifndef HAVE_SYNC_FILE_RANGE
 #warning Using locally defined sync_file_range interface.
-- 
1.8.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ