xref: /freebsd/sys/contrib/openzfs/config/kernel-inode-getattr.m4 (revision 96190b4fef3b4a0cc3ca0606b0c4e3e69a5e6717)
1AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_GETATTR], [
2	dnl #
3	dnl # Linux 6.3 API
4	dnl # The first arg of getattr I/O operations handler type
5	dnl # is changed to struct mnt_idmap*
6	dnl #
7	ZFS_LINUX_TEST_SRC([inode_operations_getattr_mnt_idmap], [
8		#include <linux/fs.h>
9
10		static int test_getattr(
11		    struct mnt_idmap *idmap,
12		    const struct path *p, struct kstat *k,
13		    u32 request_mask, unsigned int query_flags)
14		    { return 0; }
15
16		static const struct inode_operations
17		    iops __attribute__ ((unused)) = {
18			.getattr = test_getattr,
19		};
20	],[])
21
22	dnl #
23	dnl # Linux 5.12 API
24	dnl # The getattr I/O operations handler type was extended to require
25	dnl # a struct user_namespace* as its first arg, to support idmapped
26	dnl # mounts.
27	dnl #
28	ZFS_LINUX_TEST_SRC([inode_operations_getattr_userns], [
29		#include <linux/fs.h>
30
31		static int test_getattr(
32			struct user_namespace *userns,
33		    const struct path *p, struct kstat *k,
34		    u32 request_mask, unsigned int query_flags)
35		    { return 0; }
36
37		static const struct inode_operations
38		    iops __attribute__ ((unused)) = {
39			.getattr = test_getattr,
40		};
41	],[])
42
43	dnl #
44	dnl # Linux 4.11 API
45	dnl # See torvalds/linux@a528d35
46	dnl #
47	ZFS_LINUX_TEST_SRC([inode_operations_getattr_path], [
48		#include <linux/fs.h>
49
50		static int test_getattr(
51		    const struct path *p, struct kstat *k,
52		    u32 request_mask, unsigned int query_flags)
53		    { return 0; }
54
55		static const struct inode_operations
56		    iops __attribute__ ((unused)) = {
57			.getattr = test_getattr,
58		};
59	],[])
60])
61
62AC_DEFUN([ZFS_AC_KERNEL_INODE_GETATTR], [
63	dnl #
64	dnl # Kernel 6.3 test
65	dnl #
66	AC_MSG_CHECKING([whether iops->getattr() takes mnt_idmap])
67	ZFS_LINUX_TEST_RESULT([inode_operations_getattr_mnt_idmap], [
68		AC_MSG_RESULT(yes)
69		AC_DEFINE(HAVE_IDMAP_IOPS_GETATTR, 1,
70		    [iops->getattr() takes struct mnt_idmap*])
71	],[
72		AC_MSG_RESULT(no)
73		dnl #
74		dnl # Kernel 5.12 test
75		dnl #
76		AC_MSG_CHECKING([whether iops->getattr() takes user_namespace])
77		ZFS_LINUX_TEST_RESULT([inode_operations_getattr_userns], [
78			AC_MSG_RESULT(yes)
79			AC_DEFINE(HAVE_USERNS_IOPS_GETATTR, 1,
80			    [iops->getattr() takes struct user_namespace*])
81		],[
82			AC_MSG_RESULT(no)
83
84			dnl #
85			dnl # Kernel 4.11 test
86			dnl #
87			AC_MSG_CHECKING([whether iops->getattr() takes a path])
88			ZFS_LINUX_TEST_RESULT([inode_operations_getattr_path], [
89				AC_MSG_RESULT(yes)
90				AC_DEFINE(HAVE_PATH_IOPS_GETATTR, 1,
91					[iops->getattr() takes a path])
92			],[
93				AC_MSG_RESULT(no)
94			])
95		])
96	])
97])
98