xref: /freebsd/sys/contrib/openzfs/config/kernel-xattr-handler.m4 (revision 7a7741af18d6c8a804cc643cb7ecda9d730c6aa6)
1dnl #
2dnl # 2.6.35 API change,
3dnl # The 'struct xattr_handler' was constified in the generic
4dnl # super_block structure.
5dnl #
6AC_DEFUN([ZFS_AC_KERNEL_SRC_CONST_XATTR_HANDLER], [
7	ZFS_LINUX_TEST_SRC([const_xattr_handler], [
8		#include <linux/fs.h>
9		#include <linux/xattr.h>
10
11		const struct xattr_handler xattr_test_handler = {
12			.prefix	= "test",
13			.get	= NULL,
14			.set	= NULL,
15		};
16
17		const struct xattr_handler *xattr_handlers[] = {
18			&xattr_test_handler,
19		};
20
21		const struct super_block sb __attribute__ ((unused)) = {
22			.s_xattr = xattr_handlers,
23		};
24	],[])
25])
26
27AC_DEFUN([ZFS_AC_KERNEL_CONST_XATTR_HANDLER], [
28	AC_MSG_CHECKING([whether super_block uses const struct xattr_handler])
29	ZFS_LINUX_TEST_RESULT([const_xattr_handler], [
30		AC_MSG_RESULT([yes])
31	],[
32		ZFS_LINUX_TEST_ERROR([const xattr_handler])
33	])
34])
35
36dnl #
37dnl # Android API change,
38dnl # The xattr_handler->get() callback was
39dnl # changed to take dentry, inode and flags.
40dnl #
41AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET_DENTRY_INODE_FLAGS], [
42	ZFS_LINUX_TEST_SRC([xattr_handler_get_dentry_inode_flags], [
43		#include <linux/xattr.h>
44
45		static int get(const struct xattr_handler *handler,
46		    struct dentry *dentry, struct inode *inode,
47		    const char *name, void *buffer,
48		    size_t size, int flags) { return 0; }
49		static const struct xattr_handler
50		    xops __attribute__ ((unused)) = {
51			.get = get,
52		};
53	],[])
54])
55
56AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_GET_DENTRY_INODE_FLAGS], [
57	AC_MSG_RESULT(no)
58	AC_MSG_CHECKING(
59	    [whether xattr_handler->get() wants dentry and inode and flags])
60	ZFS_LINUX_TEST_RESULT([xattr_handler_get_dentry_inode_flags], [
61		AC_MSG_RESULT(yes)
62		AC_DEFINE(HAVE_XATTR_GET_DENTRY_INODE_FLAGS, 1,
63		    [xattr_handler->get() wants dentry and inode and flags])
64	],[
65		AC_MSG_RESULT(no)
66	])
67])
68
69dnl #
70dnl # Supported xattr handler set() interfaces checked newest to oldest.
71dnl #
72AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_SET], [
73	ZFS_LINUX_TEST_SRC([xattr_handler_set_mnt_idmap], [
74		#include <linux/xattr.h>
75
76		static int set(const struct xattr_handler *handler,
77			struct mnt_idmap *idmap,
78			struct dentry *dentry, struct inode *inode,
79			const char *name, const void *buffer,
80			size_t size, int flags)
81			{ return 0; }
82		static const struct xattr_handler
83			xops __attribute__ ((unused)) = {
84			.set = set,
85		};
86	],[])
87
88	ZFS_LINUX_TEST_SRC([xattr_handler_set_userns], [
89		#include <linux/xattr.h>
90
91		static int set(const struct xattr_handler *handler,
92			struct user_namespace *mnt_userns,
93			struct dentry *dentry, struct inode *inode,
94			const char *name, const void *buffer,
95			size_t size, int flags)
96			{ return 0; }
97		static const struct xattr_handler
98			xops __attribute__ ((unused)) = {
99			.set = set,
100		};
101	],[])
102
103	ZFS_LINUX_TEST_SRC([xattr_handler_set_dentry_inode], [
104		#include <linux/xattr.h>
105
106		static int set(const struct xattr_handler *handler,
107		    struct dentry *dentry, struct inode *inode,
108		    const char *name, const void *buffer,
109		    size_t size, int flags)
110		    { return 0; }
111		static const struct xattr_handler
112		    xops __attribute__ ((unused)) = {
113			.set = set,
114		};
115	],[])
116])
117
118AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [
119	dnl #
120	dnl # 5.12 API change,
121	dnl # The xattr_handler->set() callback was changed to 8 arguments, and
122	dnl # struct user_namespace* was inserted as arg #2
123	dnl #
124	dnl # 6.3 API change,
125	dnl # The xattr_handler->set() callback 2nd arg is now struct mnt_idmap *
126	dnl #
127	AC_MSG_CHECKING([whether xattr_handler->set() wants dentry, inode, and mnt_idmap])
128	ZFS_LINUX_TEST_RESULT([xattr_handler_set_mnt_idmap], [
129		AC_MSG_RESULT(yes)
130		AC_DEFINE(HAVE_XATTR_SET_IDMAP, 1,
131		    [xattr_handler->set() takes mnt_idmap])
132	], [
133		AC_MSG_RESULT(no)
134		AC_MSG_CHECKING([whether xattr_handler->set() wants dentry, inode, and user_namespace])
135		ZFS_LINUX_TEST_RESULT([xattr_handler_set_userns], [
136			AC_MSG_RESULT(yes)
137			AC_DEFINE(HAVE_XATTR_SET_USERNS, 1,
138			    [xattr_handler->set() takes user_namespace])
139		],[
140			dnl #
141			dnl # 4.7 API change,
142			dnl # The xattr_handler->set() callback was changed to take both
143			dnl # dentry and inode.
144			dnl #
145			AC_MSG_RESULT(no)
146			AC_MSG_CHECKING([whether xattr_handler->set() wants dentry and inode])
147			ZFS_LINUX_TEST_RESULT([xattr_handler_set_dentry_inode], [
148				AC_MSG_RESULT(yes)
149				AC_DEFINE(HAVE_XATTR_SET_DENTRY_INODE, 1,
150				    [xattr_handler->set() wants both dentry and inode])
151			],[
152				ZFS_LINUX_TEST_ERROR([xattr set()])
153			])
154		])
155	])
156])
157
158dnl #
159dnl # 4.9 API change,
160dnl # iops->{set,get,remove}xattr and generic_{set,get,remove}xattr are
161dnl # removed. xattr operations will directly go through sb->s_xattr.
162dnl #
163AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_SETXATTR], [
164	ZFS_LINUX_TEST_SRC([have_generic_setxattr], [
165		#include <linux/fs.h>
166		#include <linux/xattr.h>
167
168		static const struct inode_operations
169		    iops __attribute__ ((unused)) = {
170			.setxattr = generic_setxattr
171		};
172	],[])
173])
174
175AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR], [
176	ZFS_AC_KERNEL_SRC_CONST_XATTR_HANDLER
177	ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET_DENTRY_INODE_FLAGS
178	ZFS_AC_KERNEL_SRC_XATTR_HANDLER_SET
179])
180
181AC_DEFUN([ZFS_AC_KERNEL_XATTR], [
182	ZFS_AC_KERNEL_CONST_XATTR_HANDLER
183	ZFS_AC_KERNEL_XATTR_HANDLER_GET_DENTRY_INODE_FLAGS
184	ZFS_AC_KERNEL_XATTR_HANDLER_SET
185])
186