xref: /freebsd/sys/contrib/openzfs/config/kernel-xattr-handler.m4 (revision dd21556857e8d40f66bf5ad54754d9d52669ebf7)
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_CHECKING(
58	    [whether xattr_handler->get() wants dentry and inode and flags])
59	ZFS_LINUX_TEST_RESULT([xattr_handler_get_dentry_inode_flags], [
60		AC_MSG_RESULT(yes)
61		AC_DEFINE(HAVE_XATTR_GET_DENTRY_INODE_FLAGS, 1,
62		    [xattr_handler->get() wants dentry and inode and flags])
63	],[
64		AC_MSG_RESULT(no)
65	])
66])
67
68dnl #
69dnl # Supported xattr handler set() interfaces checked newest to oldest.
70dnl #
71AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_SET], [
72	ZFS_LINUX_TEST_SRC([xattr_handler_set_mnt_idmap], [
73		#include <linux/xattr.h>
74
75		static int set(const struct xattr_handler *handler,
76			struct mnt_idmap *idmap,
77			struct dentry *dentry, struct inode *inode,
78			const char *name, const void *buffer,
79			size_t size, int flags)
80			{ return 0; }
81		static const struct xattr_handler
82			xops __attribute__ ((unused)) = {
83			.set = set,
84		};
85	],[])
86
87	ZFS_LINUX_TEST_SRC([xattr_handler_set_userns], [
88		#include <linux/xattr.h>
89
90		static int set(const struct xattr_handler *handler,
91			struct user_namespace *mnt_userns,
92			struct dentry *dentry, struct inode *inode,
93			const char *name, const void *buffer,
94			size_t size, int flags)
95			{ return 0; }
96		static const struct xattr_handler
97			xops __attribute__ ((unused)) = {
98			.set = set,
99		};
100	],[])
101
102	ZFS_LINUX_TEST_SRC([xattr_handler_set_dentry_inode], [
103		#include <linux/xattr.h>
104
105		static int set(const struct xattr_handler *handler,
106		    struct dentry *dentry, struct inode *inode,
107		    const char *name, const void *buffer,
108		    size_t size, int flags)
109		    { return 0; }
110		static const struct xattr_handler
111		    xops __attribute__ ((unused)) = {
112			.set = set,
113		};
114	],[])
115])
116
117AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [
118	dnl #
119	dnl # 5.12 API change,
120	dnl # The xattr_handler->set() callback was changed to 8 arguments, and
121	dnl # struct user_namespace* was inserted as arg #2
122	dnl #
123	dnl # 6.3 API change,
124	dnl # The xattr_handler->set() callback 2nd arg is now struct mnt_idmap *
125	dnl #
126	AC_MSG_CHECKING([whether xattr_handler->set() wants dentry, inode, and mnt_idmap])
127	ZFS_LINUX_TEST_RESULT([xattr_handler_set_mnt_idmap], [
128		AC_MSG_RESULT(yes)
129		AC_DEFINE(HAVE_XATTR_SET_IDMAP, 1,
130		    [xattr_handler->set() takes mnt_idmap])
131	], [
132		AC_MSG_RESULT(no)
133		AC_MSG_CHECKING([whether xattr_handler->set() wants dentry, inode, and user_namespace])
134		ZFS_LINUX_TEST_RESULT([xattr_handler_set_userns], [
135			AC_MSG_RESULT(yes)
136			AC_DEFINE(HAVE_XATTR_SET_USERNS, 1,
137			    [xattr_handler->set() takes user_namespace])
138		],[
139			dnl #
140			dnl # 4.7 API change,
141			dnl # The xattr_handler->set() callback was changed to take both
142			dnl # dentry and inode.
143			dnl #
144			AC_MSG_RESULT(no)
145			AC_MSG_CHECKING([whether xattr_handler->set() wants dentry and inode])
146			ZFS_LINUX_TEST_RESULT([xattr_handler_set_dentry_inode], [
147				AC_MSG_RESULT(yes)
148				AC_DEFINE(HAVE_XATTR_SET_DENTRY_INODE, 1,
149				    [xattr_handler->set() wants both dentry and inode])
150			],[
151				ZFS_LINUX_TEST_ERROR([xattr set()])
152			])
153		])
154	])
155])
156
157dnl #
158dnl # 4.9 API change,
159dnl # iops->{set,get,remove}xattr and generic_{set,get,remove}xattr are
160dnl # removed. xattr operations will directly go through sb->s_xattr.
161dnl #
162AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_SETXATTR], [
163	ZFS_LINUX_TEST_SRC([have_generic_setxattr], [
164		#include <linux/fs.h>
165		#include <linux/xattr.h>
166
167		static const struct inode_operations
168		    iops __attribute__ ((unused)) = {
169			.setxattr = generic_setxattr
170		};
171	],[])
172])
173
174AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR], [
175	ZFS_AC_KERNEL_SRC_CONST_XATTR_HANDLER
176	ZFS_AC_KERNEL_SRC_XATTR_HANDLER_GET_DENTRY_INODE_FLAGS
177	ZFS_AC_KERNEL_SRC_XATTR_HANDLER_SET
178])
179
180AC_DEFUN([ZFS_AC_KERNEL_XATTR], [
181	ZFS_AC_KERNEL_CONST_XATTR_HANDLER
182	ZFS_AC_KERNEL_XATTR_HANDLER_GET_DENTRY_INODE_FLAGS
183	ZFS_AC_KERNEL_XATTR_HANDLER_SET
184])
185