xref: /src/sys/contrib/openzfs/config/kernel-tmpfile.m4 (revision 8a62a2a5659d1839d8799b4274c04469d7f17c78)
1dnl # SPDX-License-Identifier: CDDL-1.0
2dnl #
3dnl # 3.11 API change
4dnl # Add support for i_op->tmpfile
5dnl #
6AC_DEFUN([ZFS_AC_KERNEL_SRC_TMPFILE], [
7	dnl #
8	dnl # 6.3 API change
9	dnl # The first arg is now struct mnt_idmap *
10	dnl #
11	ZFS_LINUX_TEST_SRC([inode_operations_tmpfile_mnt_idmap], [
12		#include <linux/fs.h>
13		static int tmpfile(struct mnt_idmap *idmap,
14		    struct inode *inode, struct file *file,
15		    umode_t mode) { return 0; }
16		static struct inode_operations
17		    iops __attribute__ ((unused)) = {
18			.tmpfile = tmpfile,
19		};
20	],[])
21	dnl # 6.1 API change
22	dnl # use struct file instead of struct dentry
23	dnl #
24	ZFS_LINUX_TEST_SRC([inode_operations_tmpfile], [
25		#include <linux/fs.h>
26		static int tmpfile(struct user_namespace *userns,
27		    struct inode *inode, struct file *file,
28		    umode_t mode) { return 0; }
29		static struct inode_operations
30		    iops __attribute__ ((unused)) = {
31			.tmpfile = tmpfile,
32		};
33	],[])
34	dnl #
35	dnl # 5.11 API change
36	dnl # add support for userns parameter to tmpfile
37	dnl #
38	ZFS_LINUX_TEST_SRC([inode_operations_tmpfile_dentry_userns], [
39		#include <linux/fs.h>
40		static int tmpfile(struct user_namespace *userns,
41		    struct inode *inode, struct dentry *dentry,
42		    umode_t mode) { return 0; }
43		static struct inode_operations
44		    iops __attribute__ ((unused)) = {
45			.tmpfile = tmpfile,
46		};
47	],[])
48	ZFS_LINUX_TEST_SRC([inode_operations_tmpfile_dentry], [
49			#include <linux/fs.h>
50			static int tmpfile(struct inode *inode, struct dentry *dentry,
51			    umode_t mode) { return 0; }
52			static struct inode_operations
53			    iops __attribute__ ((unused)) = {
54				.tmpfile = tmpfile,
55			};
56	],[])
57])
58
59AC_DEFUN([ZFS_AC_KERNEL_TMPFILE], [
60	AC_MSG_CHECKING([whether i_op->tmpfile() exists])
61	ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile_mnt_idmap], [
62		AC_MSG_RESULT(yes)
63		AC_DEFINE(HAVE_TMPFILE_IDMAP, 1, [i_op->tmpfile() has mnt_idmap])
64	], [
65		ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile], [
66			AC_MSG_RESULT(yes)
67			AC_DEFINE(HAVE_TMPFILE_USERNS, 1, [i_op->tmpfile() has userns])
68		],[
69			ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile_dentry_userns], [
70				AC_MSG_RESULT(yes)
71				AC_DEFINE(HAVE_TMPFILE_USERNS, 1, [i_op->tmpfile() has userns])
72				AC_DEFINE(HAVE_TMPFILE_DENTRY, 1, [i_op->tmpfile() uses old dentry signature])
73			],[
74				ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile_dentry], [
75					AC_MSG_RESULT(yes)
76					AC_DEFINE(HAVE_TMPFILE_DENTRY, 1, [i_op->tmpfile() uses old dentry signature])
77				],[
78					ZFS_LINUX_REQUIRE_API([i_op->tmpfile()], [3.11])
79				])
80			])
81		])
82	])
83])
84