1dnl #
2dnl # Linux 2.6.38 - 3.x API
3dnl # The fallocate callback was moved from the inode_operations
4dnl # structure to the file_operations structure.
5dnl #
6dnl #
7dnl # Linux 3.15+
8dnl # fallocate learned a new flag, FALLOC_FL_ZERO_RANGE
9dnl #
10AC_DEFUN([ZFS_AC_KERNEL_SRC_FALLOCATE], [
11	ZFS_LINUX_TEST_SRC([file_fallocate], [
12		#include <linux/fs.h>
13
14		long test_fallocate(struct file *file, int mode,
15		    loff_t offset, loff_t len) { return 0; }
16
17		static const struct file_operations
18		    fops __attribute__ ((unused)) = {
19			.fallocate = test_fallocate,
20		};
21	], [])
22	ZFS_LINUX_TEST_SRC([falloc_fl_zero_range], [
23		#include <linux/falloc.h>
24	],[
25		int flags __attribute__ ((unused));
26		flags = FALLOC_FL_ZERO_RANGE;
27	])
28])
29
30AC_DEFUN([ZFS_AC_KERNEL_FALLOCATE], [
31	AC_MSG_CHECKING([whether fops->fallocate() exists])
32	ZFS_LINUX_TEST_RESULT([file_fallocate], [
33		AC_MSG_RESULT(yes)
34		AC_MSG_CHECKING([whether FALLOC_FL_ZERO_RANGE exists])
35		ZFS_LINUX_TEST_RESULT([falloc_fl_zero_range], [
36			AC_MSG_RESULT(yes)
37			AC_DEFINE(HAVE_FALLOC_FL_ZERO_RANGE, 1, [FALLOC_FL_ZERO_RANGE is defined])
38		],[
39			AC_MSG_RESULT(no)
40		])
41	],[
42		ZFS_LINUX_TEST_ERROR([file_fallocate])
43	])
44])
45