@@ -1102,6 +1102,7 @@ AC_CHECK_FUNCS(m4_flatten([
open64
pathconf
posix_fadvise
+ posix_fadvise64
posix_memalign
prctl
secure_getenv
@@ -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.
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@tkos.co.il> --- v2: fix #endif comment --- configure.in | 1 + misc/e4defrag.c | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-)