xref: /freebsd/sys/contrib/openzfs/config/kernel-inode-getattr.m4 (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_GETATTR], [
2	dnl #
3	dnl # Linux 5.12 API
4	dnl # The getattr I/O operations handler type was extended to require
5	dnl # a struct user_namespace* as its first arg, to support idmapped
6	dnl # mounts.
7	dnl #
8	ZFS_LINUX_TEST_SRC([inode_operations_getattr_userns], [
9		#include <linux/fs.h>
10
11		int test_getattr(
12			struct user_namespace *userns,
13		    const struct path *p, struct kstat *k,
14		    u32 request_mask, unsigned int query_flags)
15		    { return 0; }
16
17		static const struct inode_operations
18		    iops __attribute__ ((unused)) = {
19			.getattr = test_getattr,
20		};
21	],[])
22
23	dnl #
24	dnl # Linux 4.11 API
25	dnl # See torvalds/linux@a528d35
26	dnl #
27	ZFS_LINUX_TEST_SRC([inode_operations_getattr_path], [
28		#include <linux/fs.h>
29
30		int test_getattr(
31		    const struct path *p, struct kstat *k,
32		    u32 request_mask, unsigned int query_flags)
33		    { return 0; }
34
35		static const struct inode_operations
36		    iops __attribute__ ((unused)) = {
37			.getattr = test_getattr,
38		};
39	],[])
40
41	ZFS_LINUX_TEST_SRC([inode_operations_getattr_vfsmount], [
42		#include <linux/fs.h>
43
44		int test_getattr(
45		    struct vfsmount *mnt, struct dentry *d,
46		    struct kstat *k)
47		    { return 0; }
48
49		static const struct inode_operations
50		    iops __attribute__ ((unused)) = {
51			.getattr = test_getattr,
52		};
53	],[])
54])
55
56AC_DEFUN([ZFS_AC_KERNEL_INODE_GETATTR], [
57	dnl #
58	dnl # Kernel 5.12 test
59	dnl #
60	AC_MSG_CHECKING([whether iops->getattr() takes user_namespace])
61	ZFS_LINUX_TEST_RESULT([inode_operations_getattr_userns], [
62		AC_MSG_RESULT(yes)
63		AC_DEFINE(HAVE_USERNS_IOPS_GETATTR, 1,
64		    [iops->getattr() takes struct user_namespace*])
65	],[
66		AC_MSG_RESULT(no)
67
68		dnl #
69		dnl # Kernel 4.11 test
70		dnl #
71		AC_MSG_CHECKING([whether iops->getattr() takes a path])
72		ZFS_LINUX_TEST_RESULT([inode_operations_getattr_path], [
73			AC_MSG_RESULT(yes)
74			AC_DEFINE(HAVE_PATH_IOPS_GETATTR, 1,
75				[iops->getattr() takes a path])
76		],[
77			AC_MSG_RESULT(no)
78
79			dnl #
80			dnl # Kernel < 4.11 test
81			dnl #
82			AC_MSG_CHECKING([whether iops->getattr() takes a vfsmount])
83			ZFS_LINUX_TEST_RESULT([inode_operations_getattr_vfsmount], [
84				AC_MSG_RESULT(yes)
85				AC_DEFINE(HAVE_VFSMOUNT_IOPS_GETATTR, 1,
86					[iops->getattr() takes a vfsmount])
87			],[
88				AC_MSG_RESULT(no)
89			])
90		])
91	])
92])
93