]> granicus.if.org Git - zfs/blob - config/kernel-acl.m4
Fix ZTS MMP tests and ztest -M behavior
[zfs] / config / kernel-acl.m4
1 dnl #
2 dnl # Check if posix_acl_release can be used from a ZFS_META_LICENSED
3 dnl # module.  The is_owner_or_cap macro was replaced by
4 dnl # inode_owner_or_capable
5 dnl #
6 AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_RELEASE], [
7         AC_MSG_CHECKING([whether posix_acl_release() is available])
8         ZFS_LINUX_TRY_COMPILE([
9                 #include <linux/cred.h>
10                 #include <linux/fs.h>
11                 #include <linux/posix_acl.h>
12         ],[
13                 struct posix_acl* tmp = posix_acl_alloc(1, 0);
14                 posix_acl_release(tmp);
15         ],[
16                 AC_MSG_RESULT(yes)
17                 AC_DEFINE(HAVE_POSIX_ACL_RELEASE, 1,
18                     [posix_acl_release() is available])
19
20                 AC_MSG_CHECKING([whether posix_acl_release() is GPL-only])
21                 ZFS_LINUX_TRY_COMPILE([
22                         #include <linux/module.h>
23                         #include <linux/cred.h>
24                         #include <linux/fs.h>
25                         #include <linux/posix_acl.h>
26
27                         MODULE_LICENSE("$ZFS_META_LICENSE");
28                 ],[
29                         struct posix_acl* tmp = posix_acl_alloc(1, 0);
30                         posix_acl_release(tmp);
31                 ],[
32                         AC_MSG_RESULT(no)
33                 ],[
34                         AC_MSG_RESULT(yes)
35                         AC_DEFINE(HAVE_POSIX_ACL_RELEASE_GPL_ONLY, 1,
36                             [posix_acl_release() is GPL-only])
37                 ])
38         ],[
39                 AC_MSG_RESULT(no)
40         ])
41 ])
42
43 dnl #
44 dnl # 3.14 API change,
45 dnl # set_cached_acl() and forget_cached_acl() changed from inline to
46 dnl # EXPORT_SYMBOL. In the former case, they may not be usable because of
47 dnl # posix_acl_release. In the latter case, we can always use them.
48 dnl #
49 AC_DEFUN([ZFS_AC_KERNEL_SET_CACHED_ACL_USABLE], [
50         AC_MSG_CHECKING([whether set_cached_acl() is usable])
51         ZFS_LINUX_TRY_COMPILE([
52                 #include <linux/module.h>
53                 #include <linux/cred.h>
54                 #include <linux/fs.h>
55                 #include <linux/posix_acl.h>
56
57                 MODULE_LICENSE("$ZFS_META_LICENSE");
58         ],[
59                 struct inode *ip = NULL;
60                 struct posix_acl *acl = posix_acl_alloc(1, 0);
61                 set_cached_acl(ip, ACL_TYPE_ACCESS, acl);
62                 forget_cached_acl(ip, ACL_TYPE_ACCESS);
63         ],[
64                 AC_MSG_RESULT(yes)
65                 AC_DEFINE(HAVE_SET_CACHED_ACL_USABLE, 1,
66                     [posix_acl_release() is usable])
67         ],[
68                 AC_MSG_RESULT(no)
69         ])
70 ])
71
72 dnl #
73 dnl # 3.1 API change,
74 dnl # posix_acl_chmod_masq() is not exported anymore and posix_acl_chmod()
75 dnl # was introduced to replace it.
76 dnl #
77 dnl # 3.14 API change,
78 dnl # posix_acl_chmod() is changed to __posix_acl_chmod()
79 dnl #
80 AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_CHMOD], [
81         AC_MSG_CHECKING([whether posix_acl_chmod exists])
82         ZFS_LINUX_TRY_COMPILE([
83                 #include <linux/fs.h>
84                 #include <linux/posix_acl.h>
85         ],[
86                 posix_acl_chmod(NULL, 0, 0)
87         ],[
88                 AC_MSG_RESULT(yes)
89                 AC_DEFINE(HAVE_POSIX_ACL_CHMOD, 1, [posix_acl_chmod() exists])
90         ],[
91                 AC_MSG_RESULT(no)
92         ])
93
94         AC_MSG_CHECKING([whether __posix_acl_chmod exists])
95         ZFS_LINUX_TRY_COMPILE([
96                 #include <linux/fs.h>
97                 #include <linux/posix_acl.h>
98         ],[
99                 __posix_acl_chmod(NULL, 0, 0)
100         ],[
101                 AC_MSG_RESULT(yes)
102                 AC_DEFINE(HAVE___POSIX_ACL_CHMOD, 1, [__posix_acl_chmod() exists])
103         ],[
104                 AC_MSG_RESULT(no)
105         ])
106 ])
107
108 dnl #
109 dnl # 3.1 API change,
110 dnl # posix_acl_equiv_mode now wants an umode_t* instead of a mode_t*
111 dnl #
112 AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_EQUIV_MODE_WANTS_UMODE_T], [
113         AC_MSG_CHECKING([whether posix_acl_equiv_mode() wants umode_t])
114         ZFS_LINUX_TRY_COMPILE([
115                 #include <linux/fs.h>
116                 #include <linux/posix_acl.h>
117         ],[
118                 umode_t tmp;
119                 posix_acl_equiv_mode(NULL,&tmp);
120         ],[
121                 AC_MSG_RESULT(yes)
122                 AC_DEFINE(HAVE_POSIX_ACL_EQUIV_MODE_UMODE_T, 1,
123                     [ posix_acl_equiv_mode wants umode_t*])
124         ],[
125                 AC_MSG_RESULT(no)
126         ])
127 ])
128
129 dnl #
130 dnl # 4.8 API change,
131 dnl # The function posix_acl_valid now must be passed a namespace.
132 dnl #
133 AC_DEFUN([ZFS_AC_KERNEL_POSIX_ACL_VALID_WITH_NS], [
134         AC_MSG_CHECKING([whether posix_acl_valid() wants user namespace])
135         ZFS_LINUX_TRY_COMPILE([
136                 #include <linux/fs.h>
137                 #include <linux/posix_acl.h>
138         ],[
139                 struct user_namespace *user_ns = NULL;
140                 const struct posix_acl *acl = NULL;
141                 int error;
142
143                 error = posix_acl_valid(user_ns, acl);
144         ],[
145                 AC_MSG_RESULT(yes)
146                 AC_DEFINE(HAVE_POSIX_ACL_VALID_WITH_NS, 1,
147                     [posix_acl_valid() wants user namespace])
148         ],[
149                 AC_MSG_RESULT(no)
150         ])
151 ])
152
153 dnl #
154 dnl # 2.6.27 API change,
155 dnl # Check if inode_operations contains the function permission
156 dnl # and expects the nameidata structure to have been removed.
157 dnl #
158 AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION], [
159         AC_MSG_CHECKING([whether iops->permission() exists])
160         ZFS_LINUX_TRY_COMPILE([
161                 #include <linux/fs.h>
162
163                 int permission_fn(struct inode *inode, int mask) { return 0; }
164
165                 static const struct inode_operations
166                     iops __attribute__ ((unused)) = {
167                         .permission = permission_fn,
168                 };
169         ],[
170         ],[
171                 AC_MSG_RESULT(yes)
172                 AC_DEFINE(HAVE_PERMISSION, 1, [iops->permission() exists])
173         ],[
174                 AC_MSG_RESULT(no)
175         ])
176 ])
177
178 dnl #
179 dnl # 2.6.26 API change,
180 dnl # Check if inode_operations contains the function permission
181 dnl # and expects the nameidata structure to be passed.
182 dnl #
183 AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_PERMISSION_WITH_NAMEIDATA], [
184         AC_MSG_CHECKING([whether iops->permission() wants nameidata])
185         ZFS_LINUX_TRY_COMPILE([
186                 #include <linux/fs.h>
187
188                 int permission_fn(struct inode *inode, int mask,
189                     struct nameidata *nd) { return 0; }
190
191                 static const struct inode_operations
192                     iops __attribute__ ((unused)) = {
193                         .permission = permission_fn,
194                 };
195         ],[
196         ],[
197                 AC_MSG_RESULT(yes)
198                 AC_DEFINE(HAVE_PERMISSION, 1, [iops->permission() exists])
199                 AC_DEFINE(HAVE_PERMISSION_WITH_NAMEIDATA, 1,
200                     [iops->permission() with nameidata exists])
201         ],[
202                 AC_MSG_RESULT(no)
203         ])
204 ])
205
206 dnl #
207 dnl # 2.6.32 API change,
208 dnl # Check if inode_operations contains the function check_acl
209 dnl #
210 AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL], [
211         AC_MSG_CHECKING([whether iops->check_acl() exists])
212         ZFS_LINUX_TRY_COMPILE([
213                 #include <linux/fs.h>
214
215                 int check_acl_fn(struct inode *inode, int mask) { return 0; }
216
217                 static const struct inode_operations
218                     iops __attribute__ ((unused)) = {
219                         .check_acl = check_acl_fn,
220                 };
221         ],[
222         ],[
223                 AC_MSG_RESULT(yes)
224                 AC_DEFINE(HAVE_CHECK_ACL, 1, [iops->check_acl() exists])
225         ],[
226                 AC_MSG_RESULT(no)
227         ])
228 ])
229
230 dnl #
231 dnl # 2.6.38 API change,
232 dnl # The function check_acl gained a new parameter: flags
233 dnl #
234 AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL_WITH_FLAGS], [
235         AC_MSG_CHECKING([whether iops->check_acl() wants flags])
236         ZFS_LINUX_TRY_COMPILE([
237                 #include <linux/fs.h>
238
239                 int check_acl_fn(struct inode *inode, int mask,
240                     unsigned int flags) { return 0; }
241
242                 static const struct inode_operations
243                     iops __attribute__ ((unused)) = {
244                         .check_acl = check_acl_fn,
245                 };
246         ],[
247         ],[
248                 AC_MSG_RESULT(yes)
249                 AC_DEFINE(HAVE_CHECK_ACL, 1, [iops->check_acl() exists])
250                 AC_DEFINE(HAVE_CHECK_ACL_WITH_FLAGS, 1,
251                     [iops->check_acl() wants flags])
252         ],[
253                 AC_MSG_RESULT(no)
254         ])
255 ])
256
257 dnl #
258 dnl # 3.1 API change,
259 dnl # Check if inode_operations contains the function get_acl
260 dnl #
261 AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL], [
262         AC_MSG_CHECKING([whether iops->get_acl() exists])
263         ZFS_LINUX_TRY_COMPILE([
264                 #include <linux/fs.h>
265
266                 struct posix_acl *get_acl_fn(struct inode *inode, int type)
267                     { return NULL; }
268
269                 static const struct inode_operations
270                     iops __attribute__ ((unused)) = {
271                         .get_acl = get_acl_fn,
272                 };
273         ],[
274         ],[
275                 AC_MSG_RESULT(yes)
276                 AC_DEFINE(HAVE_GET_ACL, 1, [iops->get_acl() exists])
277         ],[
278                 AC_MSG_RESULT(no)
279         ])
280 ])
281
282 dnl #
283 dnl # 3.14 API change,
284 dnl # Check if inode_operations contains the function set_acl
285 dnl #
286 AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL], [
287         AC_MSG_CHECKING([whether iops->set_acl() exists])
288         ZFS_LINUX_TRY_COMPILE([
289                 #include <linux/fs.h>
290
291                 int set_acl_fn(struct inode *inode, struct posix_acl *acl, int type)
292                     { return 0; }
293
294                 static const struct inode_operations
295                     iops __attribute__ ((unused)) = {
296                         .set_acl = set_acl_fn,
297                 };
298         ],[
299         ],[
300                 AC_MSG_RESULT(yes)
301                 AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists])
302         ],[
303                 AC_MSG_RESULT(no)
304         ])
305 ])
306
307 dnl #
308 dnl # 4.7 API change,
309 dnl # The kernel get_acl will now check cache before calling i_op->get_acl and
310 dnl # do set_cached_acl after that, so i_op->get_acl don't need to do that
311 dnl # anymore.
312 dnl #
313 AC_DEFUN([ZFS_AC_KERNEL_GET_ACL_HANDLE_CACHE], [
314         AC_MSG_CHECKING([whether uncached_acl_sentinel() exists])
315         ZFS_LINUX_TRY_COMPILE([
316                 #include <linux/fs.h>
317         ],[
318                 void *sentinel __attribute__ ((unused)) = uncached_acl_sentinel(NULL);
319         ],[
320                 AC_MSG_RESULT(yes)
321                 AC_DEFINE(HAVE_KERNEL_GET_ACL_HANDLE_CACHE, 1, [uncached_acl_sentinel() exists])
322         ],[
323                 AC_MSG_RESULT(no)
324         ])
325 ])