@@ -304,12 +304,6 @@ static int posix_fadvise(int fd, loff_t offset, size_t len, int advise)
#ifndef HAVE_SYNC_FILE_RANGE
#warning Using locally defined sync_file_range interface.
-#ifndef __NR_sync_file_range
-#ifndef __NR_sync_file_range2 /* ppc */
-#error Your kernel headers dont define __NR_sync_file_range
-#endif
-#endif
-
/*
* sync_file_range() - Sync file region.
*
@@ -322,8 +316,19 @@ int sync_file_range(int fd, loff_t offset, loff_t length, unsigned int flag)
{
#ifdef __NR_sync_file_range
return syscall(__NR_sync_file_range, fd, offset, length, flag);
-#else
+#elif defined(__NR_sync_file_range2)
return syscall(__NR_sync_file_range2, fd, flag, offset, length);
+#else
+ return fsync(fd);
+#ifndef SYNC_FILE_RANGE_WAIT_BEFORE
+#define SYNC_FILE_RANGE_WAIT_BEFORE 0
+#endif
+#ifndef SYNC_FILE_RANGE_WRITE
+#define SYNC_FILE_RANGE_WRITE 0
+#endif
+#ifndef SYNC_FILE_RANGE_WAIT_AFTER
+#define SYNC_FILE_RANGE_WAIT_AFTER 0
+#endif
#endif
}
#endif /* ! HAVE_SYNC_FILE_RANGE */
@@ -332,7 +337,17 @@ int sync_file_range(int fd, loff_t offset, loff_t length, unsigned int flag)
#warning Using locally defined fallocate syscall interface.
#ifndef __NR_fallocate
-#error Your kernel headers dont define __NR_fallocate
+# if defined(__x86_64__)
+# define __NR_fallocate 285
+# elif defined(__i386__)
+# define __NR_fallocate 324
+# elif defined(__powerpc__)
+# define __NR_fallocate 309
+# else
+/* fallback position might be posix_fallocate(), but I suspect any kernel
+ * that doesn't have fallocate will also not have EXT4_IOC_MOVE_EXT */
+# error Your kernel headers dont define __NR_fallocate
+# endif
#endif
/*