xref: /freebsd/sys/contrib/openzfs/config/kernel-inode-getattr.m4 (revision 19fae0f66023a97a9b464b3beeeabb2081f575b3)
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		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		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		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	ZFS_LINUX_TEST_SRC([inode_operations_getattr_vfsmount], [
62		#include <linux/fs.h>
63
64		int test_getattr(
65		    struct vfsmount *mnt, struct dentry *d,
66		    struct kstat *k)
67		    { return 0; }
68
69		static const struct inode_operations
70		    iops __attribute__ ((unused)) = {
71			.getattr = test_getattr,
72		};
73	],[])
74])
75
76AC_DEFUN([ZFS_AC_KERNEL_INODE_GETATTR], [
77	dnl #
78	dnl # Kernel 6.3 test
79	dnl #
80	AC_MSG_CHECKING([whether iops->getattr() takes mnt_idmap])
81	ZFS_LINUX_TEST_RESULT([inode_operations_getattr_mnt_idmap], [
82		AC_MSG_RESULT(yes)
83		AC_DEFINE(HAVE_IDMAP_IOPS_GETATTR, 1,
84		    [iops->getattr() takes struct mnt_idmap*])
85	],[
86		AC_MSG_RESULT(no)
87		dnl #
88		dnl # Kernel 5.12 test
89		dnl #
90		AC_MSG_CHECKING([whether iops->getattr() takes user_namespace])
91		ZFS_LINUX_TEST_RESULT([inode_operations_getattr_userns], [
92			AC_MSG_RESULT(yes)
93			AC_DEFINE(HAVE_USERNS_IOPS_GETATTR, 1,
94			    [iops->getattr() takes struct user_namespace*])
95		],[
96			AC_MSG_RESULT(no)
97
98			dnl #
99			dnl # Kernel 4.11 test
100			dnl #
101			AC_MSG_CHECKING([whether iops->getattr() takes a path])
102			ZFS_LINUX_TEST_RESULT([inode_operations_getattr_path], [
103				AC_MSG_RESULT(yes)
104				AC_DEFINE(HAVE_PATH_IOPS_GETATTR, 1,
105					[iops->getattr() takes a path])
106			],[
107				AC_MSG_RESULT(no)
108
109				dnl #
110				dnl # Kernel < 4.11 test
111				dnl #
112				AC_MSG_CHECKING([whether iops->getattr() takes a vfsmount])
113				ZFS_LINUX_TEST_RESULT([inode_operations_getattr_vfsmount], [
114					AC_MSG_RESULT(yes)
115					AC_DEFINE(HAVE_VFSMOUNT_IOPS_GETATTR, 1,
116						[iops->getattr() takes a vfsmount])
117				],[
118					AC_MSG_RESULT(no)
119				])
120			])
121		])
122	])
123])
124