]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - config/kernel-acl.m4
Revert "Develop tests for issues #5866 and #8858"
[FreeBSD/FreeBSD.git] / 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                 #include <linux/sched.h>
188
189                 int permission_fn(struct inode *inode, int mask,
190                     struct nameidata *nd) { return 0; }
191
192                 static const struct inode_operations
193                     iops __attribute__ ((unused)) = {
194                         .permission = permission_fn,
195                 };
196         ],[
197         ],[
198                 AC_MSG_RESULT(yes)
199                 AC_DEFINE(HAVE_PERMISSION, 1, [iops->permission() exists])
200                 AC_DEFINE(HAVE_PERMISSION_WITH_NAMEIDATA, 1,
201                     [iops->permission() with nameidata exists])
202         ],[
203                 AC_MSG_RESULT(no)
204         ])
205 ])
206
207 dnl #
208 dnl # 2.6.32 API change,
209 dnl # Check if inode_operations contains the function check_acl
210 dnl #
211 AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL], [
212         AC_MSG_CHECKING([whether iops->check_acl() exists])
213         ZFS_LINUX_TRY_COMPILE([
214                 #include <linux/fs.h>
215
216                 int check_acl_fn(struct inode *inode, int mask) { return 0; }
217
218                 static const struct inode_operations
219                     iops __attribute__ ((unused)) = {
220                         .check_acl = check_acl_fn,
221                 };
222         ],[
223         ],[
224                 AC_MSG_RESULT(yes)
225                 AC_DEFINE(HAVE_CHECK_ACL, 1, [iops->check_acl() exists])
226         ],[
227                 AC_MSG_RESULT(no)
228         ])
229 ])
230
231 dnl #
232 dnl # 2.6.38 API change,
233 dnl # The function check_acl gained a new parameter: flags
234 dnl #
235 AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_CHECK_ACL_WITH_FLAGS], [
236         AC_MSG_CHECKING([whether iops->check_acl() wants flags])
237         ZFS_LINUX_TRY_COMPILE([
238                 #include <linux/fs.h>
239
240                 int check_acl_fn(struct inode *inode, int mask,
241                     unsigned int flags) { return 0; }
242
243                 static const struct inode_operations
244                     iops __attribute__ ((unused)) = {
245                         .check_acl = check_acl_fn,
246                 };
247         ],[
248         ],[
249                 AC_MSG_RESULT(yes)
250                 AC_DEFINE(HAVE_CHECK_ACL, 1, [iops->check_acl() exists])
251                 AC_DEFINE(HAVE_CHECK_ACL_WITH_FLAGS, 1,
252                     [iops->check_acl() wants flags])
253         ],[
254                 AC_MSG_RESULT(no)
255         ])
256 ])
257
258 dnl #
259 dnl # 3.1 API change,
260 dnl # Check if inode_operations contains the function get_acl
261 dnl #
262 AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_GET_ACL], [
263         AC_MSG_CHECKING([whether iops->get_acl() exists])
264         ZFS_LINUX_TRY_COMPILE([
265                 #include <linux/fs.h>
266
267                 struct posix_acl *get_acl_fn(struct inode *inode, int type)
268                     { return NULL; }
269
270                 static const struct inode_operations
271                     iops __attribute__ ((unused)) = {
272                         .get_acl = get_acl_fn,
273                 };
274         ],[
275         ],[
276                 AC_MSG_RESULT(yes)
277                 AC_DEFINE(HAVE_GET_ACL, 1, [iops->get_acl() exists])
278         ],[
279                 AC_MSG_RESULT(no)
280         ])
281 ])
282
283 dnl #
284 dnl # 3.14 API change,
285 dnl # Check if inode_operations contains the function set_acl
286 dnl #
287 AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL], [
288         AC_MSG_CHECKING([whether iops->set_acl() exists])
289         ZFS_LINUX_TRY_COMPILE([
290                 #include <linux/fs.h>
291
292                 int set_acl_fn(struct inode *inode, struct posix_acl *acl, int type)
293                     { return 0; }
294
295                 static const struct inode_operations
296                     iops __attribute__ ((unused)) = {
297                         .set_acl = set_acl_fn,
298                 };
299         ],[
300         ],[
301                 AC_MSG_RESULT(yes)
302                 AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists])
303         ],[
304                 AC_MSG_RESULT(no)
305         ])
306 ])
307
308 dnl #
309 dnl # 4.7 API change,
310 dnl # The kernel get_acl will now check cache before calling i_op->get_acl and
311 dnl # do set_cached_acl after that, so i_op->get_acl don't need to do that
312 dnl # anymore.
313 dnl #
314 AC_DEFUN([ZFS_AC_KERNEL_GET_ACL_HANDLE_CACHE], [
315         AC_MSG_CHECKING([whether uncached_acl_sentinel() exists])
316         ZFS_LINUX_TRY_COMPILE([
317                 #include <linux/fs.h>
318         ],[
319                 void *sentinel __attribute__ ((unused)) = uncached_acl_sentinel(NULL);
320         ],[
321                 AC_MSG_RESULT(yes)
322                 AC_DEFINE(HAVE_KERNEL_GET_ACL_HANDLE_CACHE, 1, [uncached_acl_sentinel() exists])
323         ],[
324                 AC_MSG_RESULT(no)
325         ])
326 ])