xref: /freebsd/sys/contrib/openzfs/config/kernel-rename.m4 (revision 7ab1a32cd43cbae61ad4dd435d6a482bbf61cb52)
1AC_DEFUN([ZFS_AC_KERNEL_SRC_RENAME], [
2	dnl #
3	dnl # 4.9 API change,
4	dnl #
5	dnl # iops->rename2() merged into iops->rename(), and iops->rename() now
6	dnl # wants flags.
7	dnl #
8	ZFS_LINUX_TEST_SRC([inode_operations_rename_flags], [
9		#include <linux/fs.h>
10		static int rename_fn(struct inode *sip, struct dentry *sdp,
11			struct inode *tip, struct dentry *tdp,
12			unsigned int flags) { return 0; }
13
14		static const struct inode_operations
15		    iops __attribute__ ((unused)) = {
16			.rename = rename_fn,
17		};
18	],[])
19
20	dnl #
21	dnl # 5.12 API change,
22	dnl #
23	dnl # Linux 5.12 introduced passing struct user_namespace* as the first
24	dnl # argument of the rename() and other inode_operations members.
25	dnl #
26	ZFS_LINUX_TEST_SRC([inode_operations_rename_userns], [
27		#include <linux/fs.h>
28		static int rename_fn(struct user_namespace *user_ns, struct inode *sip,
29			struct dentry *sdp, struct inode *tip, struct dentry *tdp,
30			unsigned int flags) { return 0; }
31
32		static const struct inode_operations
33		    iops __attribute__ ((unused)) = {
34			.rename = rename_fn,
35		};
36	],[])
37
38	dnl #
39	dnl # 6.3 API change - the first arg is now struct mnt_idmap*
40	dnl #
41	ZFS_LINUX_TEST_SRC([inode_operations_rename_mnt_idmap], [
42		#include <linux/fs.h>
43		static int rename_fn(struct mnt_idmap *idmap, struct inode *sip,
44			struct dentry *sdp, struct inode *tip, struct dentry *tdp,
45			unsigned int flags) { return 0; }
46
47		static const struct inode_operations
48		    iops __attribute__ ((unused)) = {
49			.rename = rename_fn,
50		};
51	],[])
52])
53
54AC_DEFUN([ZFS_AC_KERNEL_RENAME], [
55	AC_MSG_CHECKING([whether iops->rename() takes struct mnt_idmap*])
56	ZFS_LINUX_TEST_RESULT([inode_operations_rename_mnt_idmap], [
57		AC_MSG_RESULT(yes)
58		AC_DEFINE(HAVE_IOPS_RENAME_IDMAP, 1,
59		    [iops->rename() takes struct mnt_idmap*])
60	],[
61		AC_MSG_RESULT(no)
62
63		AC_MSG_CHECKING([whether iops->rename() takes struct user_namespace*])
64		ZFS_LINUX_TEST_RESULT([inode_operations_rename_userns], [
65			AC_MSG_RESULT(yes)
66			AC_DEFINE(HAVE_IOPS_RENAME_USERNS, 1,
67			    [iops->rename() takes struct user_namespace*])
68		],[
69			AC_MSG_RESULT(no)
70
71			AC_MSG_CHECKING([whether iops->rename() wants flags])
72			ZFS_LINUX_TEST_RESULT([inode_operations_rename_flags], [
73				AC_MSG_RESULT(yes)
74				AC_DEFINE(HAVE_RENAME_WANTS_FLAGS, 1,
75					[iops->rename() wants flags])
76			],[
77				AC_MSG_RESULT(no)
78			])
79		])
80	])
81])
82