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