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