xref: /freebsd/sys/contrib/openzfs/config/kernel-acl.m4 (revision 7a7741af18d6c8a804cc643cb7ecda9d730c6aa6)
1dnl #
2dnl # 3.1 API change,
3dnl # posix_acl_equiv_mode now wants an umode_t instead of a mode_t
4dnl #
5AC_DEFUN([ZFS_AC_KERNEL_SRC_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T], [
6	ZFS_LINUX_TEST_SRC([posix_acl_equiv_mode], [
7		#include <linux/fs.h>
8		#include <linux/posix_acl.h>
9	],[
10		umode_t tmp;
11		posix_acl_equiv_mode(NULL, &tmp);
12	])
13])
14
15AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T], [
16	AC_MSG_CHECKING([whether posix_acl_equiv_mode() wants umode_t])
17	ZFS_LINUX_TEST_RESULT([posix_acl_equiv_mode], [
18		AC_MSG_RESULT(yes)
19	],[
20		ZFS_LINUX_TEST_ERROR([posix_acl_equiv_mode()])
21	])
22])
23
24dnl #
25dnl # 3.1 API change,
26dnl # Check if inode_operations contains the function get_acl
27dnl #
28dnl # 5.15 API change,
29dnl # Added the bool rcu argument to get_acl for rcu path walk.
30dnl #
31dnl # 6.2 API change,
32dnl # get_acl() was renamed to get_inode_acl()
33dnl #
34AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_GET_ACL], [
35	ZFS_LINUX_TEST_SRC([inode_operations_get_acl], [
36		#include <linux/fs.h>
37
38		static struct posix_acl *get_acl_fn(struct inode *inode, int type)
39		    { return NULL; }
40
41		static const struct inode_operations
42		    iops __attribute__ ((unused)) = {
43			.get_acl = get_acl_fn,
44		};
45	],[])
46
47	ZFS_LINUX_TEST_SRC([inode_operations_get_acl_rcu], [
48		#include <linux/fs.h>
49
50		static struct posix_acl *get_acl_fn(struct inode *inode, int type,
51		    bool rcu) { return NULL; }
52
53		static const struct inode_operations
54		    iops __attribute__ ((unused)) = {
55			.get_acl = get_acl_fn,
56		};
57	],[])
58
59	ZFS_LINUX_TEST_SRC([inode_operations_get_inode_acl], [
60		#include <linux/fs.h>
61
62		static struct posix_acl *get_inode_acl_fn(struct inode *inode, int type,
63		    bool rcu) { return NULL; }
64
65		static const struct inode_operations
66		    iops __attribute__ ((unused)) = {
67			.get_inode_acl = get_inode_acl_fn,
68		};
69	],[])
70])
71
72AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL], [
73	AC_MSG_CHECKING([whether iops->get_acl() exists])
74	ZFS_LINUX_TEST_RESULT([inode_operations_get_acl], [
75		AC_MSG_RESULT(yes)
76		AC_DEFINE(HAVE_GET_ACL, 1, [iops->get_acl() exists])
77	],[
78		ZFS_LINUX_TEST_RESULT([inode_operations_get_acl_rcu], [
79			AC_MSG_RESULT(yes)
80			AC_DEFINE(HAVE_GET_ACL_RCU, 1, [iops->get_acl() takes rcu])
81		],[
82			ZFS_LINUX_TEST_RESULT([inode_operations_get_inode_acl], [
83				AC_MSG_RESULT(yes)
84				AC_DEFINE(HAVE_GET_INODE_ACL, 1, [has iops->get_inode_acl()])
85			],[
86				ZFS_LINUX_TEST_ERROR([iops->get_acl() or iops->get_inode_acl()])
87			])
88		])
89	])
90])
91
92dnl #
93dnl # 5.12 API change,
94dnl # set_acl() added a user_namespace* parameter first
95dnl #
96dnl # 6.2 API change,
97dnl # set_acl() second paramter changed to a struct dentry *
98dnl #
99dnl # 6.3 API change,
100dnl # set_acl() first parameter changed to struct mnt_idmap *
101dnl #
102AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_SET_ACL], [
103	ZFS_LINUX_TEST_SRC([inode_operations_set_acl_mnt_idmap_dentry], [
104		#include <linux/fs.h>
105
106		static int set_acl_fn(struct mnt_idmap *idmap,
107		    struct dentry *dent, struct posix_acl *acl,
108		    int type) { return 0; }
109
110		static const struct inode_operations
111		    iops __attribute__ ((unused)) = {
112			.set_acl = set_acl_fn,
113		};
114	],[])
115	ZFS_LINUX_TEST_SRC([inode_operations_set_acl_userns_dentry], [
116		#include <linux/fs.h>
117
118		static int set_acl_fn(struct user_namespace *userns,
119		    struct dentry *dent, struct posix_acl *acl,
120		    int type) { return 0; }
121
122		static const struct inode_operations
123		    iops __attribute__ ((unused)) = {
124			.set_acl = set_acl_fn,
125		};
126	],[])
127	ZFS_LINUX_TEST_SRC([inode_operations_set_acl_userns], [
128		#include <linux/fs.h>
129
130		static int set_acl_fn(struct user_namespace *userns,
131		    struct inode *inode, struct posix_acl *acl,
132		    int type) { return 0; }
133
134		static const struct inode_operations
135		    iops __attribute__ ((unused)) = {
136			.set_acl = set_acl_fn,
137		};
138	],[])
139	ZFS_LINUX_TEST_SRC([inode_operations_set_acl], [
140		#include <linux/fs.h>
141
142		static int set_acl_fn(struct inode *inode, struct posix_acl *acl,
143		    int type) { return 0; }
144
145		static const struct inode_operations
146		    iops __attribute__ ((unused)) = {
147			.set_acl = set_acl_fn,
148		};
149	],[])
150])
151
152AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL], [
153	AC_MSG_CHECKING([whether iops->set_acl() with 4 args exists])
154	ZFS_LINUX_TEST_RESULT([inode_operations_set_acl_userns], [
155		AC_MSG_RESULT(yes)
156		AC_DEFINE(HAVE_SET_ACL_USERNS, 1, [iops->set_acl() takes 4 args])
157	],[
158		ZFS_LINUX_TEST_RESULT([inode_operations_set_acl_mnt_idmap_dentry], [
159			AC_MSG_RESULT(yes)
160			AC_DEFINE(HAVE_SET_ACL_IDMAP_DENTRY, 1,
161			    [iops->set_acl() takes 4 args, arg1 is struct mnt_idmap *])
162		],[
163			ZFS_LINUX_TEST_RESULT([inode_operations_set_acl_userns_dentry], [
164				AC_MSG_RESULT(yes)
165				AC_DEFINE(HAVE_SET_ACL_USERNS_DENTRY_ARG2, 1,
166				    [iops->set_acl() takes 4 args, arg2 is struct dentry *])
167			],[
168				AC_MSG_RESULT(no)
169			])
170		])
171	])
172])
173
174AC_DEFUN([ZFS_AC_KERNEL_SRC_ACL], [
175	ZFS_AC_KERNEL_SRC_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T
176	ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_GET_ACL
177	ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_SET_ACL
178])
179
180AC_DEFUN([ZFS_AC_KERNEL_ACL], [
181	ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T
182	ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL
183	ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL
184])
185