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