xref: /src/sys/contrib/openzfs/config/kernel-inode-permission.m4 (revision 8a62a2a5659d1839d8799b4274c04469d7f17c78)
1dnl # SPDX-License-Identifier: CDDL-1.0
2AC_DEFUN([ZFS_AC_KERNEL_SRC_PERMISSION], [
3	dnl #
4	dnl # 6.3 API change
5	dnl # iops->permission() now takes struct mnt_idmap*
6	dnl # as its first arg
7	dnl #
8	ZFS_LINUX_TEST_SRC([permission_mnt_idmap], [
9		#include <linux/fs.h>
10		#include <linux/sched.h>
11
12		static int test_permission(struct mnt_idmap *idmap,
13		    struct inode *inode, int mask) { return 0; }
14
15		static const struct inode_operations
16			iops __attribute__ ((unused)) = {
17			.permission             = test_permission,
18		};
19	],[])
20
21	dnl #
22	dnl # 5.12 API change that added the struct user_namespace* arg
23	dnl # to the front of this function type's arg list.
24	dnl #
25	ZFS_LINUX_TEST_SRC([permission_userns], [
26		#include <linux/fs.h>
27		#include <linux/sched.h>
28
29		static int test_permission(struct user_namespace *userns,
30		    struct inode *inode, int mask) { return 0; }
31
32		static const struct inode_operations
33			iops __attribute__ ((unused)) = {
34			.permission		= test_permission,
35		};
36	],[])
37])
38
39AC_DEFUN([ZFS_AC_KERNEL_PERMISSION], [
40	AC_MSG_CHECKING([whether iops->permission() takes struct mnt_idmap*])
41	ZFS_LINUX_TEST_RESULT([permission_mnt_idmap], [
42		AC_MSG_RESULT(yes)
43		AC_DEFINE(HAVE_IOPS_PERMISSION_IDMAP, 1,
44		   [iops->permission() takes struct mnt_idmap*])
45	],[
46		AC_MSG_RESULT(no)
47
48		AC_MSG_CHECKING([whether iops->permission() takes struct user_namespace*])
49		ZFS_LINUX_TEST_RESULT([permission_userns], [
50			AC_MSG_RESULT(yes)
51			AC_DEFINE(HAVE_IOPS_PERMISSION_USERNS, 1,
52			   [iops->permission() takes struct user_namespace*])
53		],[
54			AC_MSG_RESULT(no)
55		])
56	])
57])
58