xref: /freebsd/sys/contrib/openzfs/config/kernel-inode-setattr.m4 (revision 7a7741af18d6c8a804cc643cb7ecda9d730c6aa6)
1AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_SETATTR], [
2	dnl #
3	dnl # Linux 6.3 API
4	dnl # The first arg of setattr I/O operations handler type
5	dnl # is changed to struct mnt_idmap*
6	dnl #
7	ZFS_LINUX_TEST_SRC([inode_operations_setattr_mnt_idmap], [
8		#include <linux/fs.h>
9
10		static int test_setattr(
11		    struct mnt_idmap *idmap,
12		    struct dentry *de, struct iattr *ia)
13		    { return 0; }
14
15		static const struct inode_operations
16		    iops __attribute__ ((unused)) = {
17			.setattr = test_setattr,
18		};
19	],[])
20
21	dnl #
22	dnl # Linux 5.12 API
23	dnl # The setattr I/O operations handler type was extended to require
24	dnl # a struct user_namespace* as its first arg, to support idmapped
25	dnl # mounts.
26	dnl #
27	ZFS_LINUX_TEST_SRC([inode_operations_setattr_userns], [
28		#include <linux/fs.h>
29
30		static int test_setattr(
31		    struct user_namespace *userns,
32		    struct dentry *de, struct iattr *ia)
33		    { return 0; }
34
35		static const struct inode_operations
36		    iops __attribute__ ((unused)) = {
37			.setattr = test_setattr,
38		};
39	],[])
40])
41
42AC_DEFUN([ZFS_AC_KERNEL_INODE_SETATTR], [
43	dnl #
44	dnl # Kernel 6.3 test
45	dnl #
46	AC_MSG_CHECKING([whether iops->setattr() takes mnt_idmap])
47	ZFS_LINUX_TEST_RESULT([inode_operations_setattr_mnt_idmap], [
48		AC_MSG_RESULT(yes)
49		AC_DEFINE(HAVE_IDMAP_IOPS_SETATTR, 1,
50		    [iops->setattr() takes struct mnt_idmap*])
51	],[
52		AC_MSG_RESULT(no)
53		dnl #
54		dnl # Kernel 5.12 test
55		dnl #
56		AC_MSG_CHECKING([whether iops->setattr() takes user_namespace])
57		ZFS_LINUX_TEST_RESULT([inode_operations_setattr_userns], [
58			AC_MSG_RESULT(yes)
59			AC_DEFINE(HAVE_USERNS_IOPS_SETATTR, 1,
60			    [iops->setattr() takes struct user_namespace*])
61		],[
62			AC_MSG_RESULT(no)
63		])
64	])
65])
66