xref: /freebsd/sys/contrib/openzfs/config/kernel-inode-times.m4 (revision a90b9d0159070121c221b966469c3e36d912bf82)
1AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_TIMES], [
2
3	dnl #
4	dnl # 5.6 API change
5	dnl # timespec64_trunc() replaced by timestamp_truncate() interface.
6	dnl #
7	ZFS_LINUX_TEST_SRC([timestamp_truncate], [
8		#include <linux/fs.h>
9	],[
10		struct timespec64 ts;
11		struct inode ip;
12
13		memset(&ts, 0, sizeof(ts));
14		ts = timestamp_truncate(ts, &ip);
15	])
16
17	dnl #
18	dnl # 4.18 API change
19	dnl # i_atime, i_mtime, and i_ctime changed from timespec to timespec64.
20	dnl #
21	ZFS_LINUX_TEST_SRC([inode_times], [
22		#include <linux/fs.h>
23	],[
24		struct inode ip;
25		struct timespec ts;
26
27		memset(&ip, 0, sizeof(ip));
28		ts = ip.i_mtime;
29	])
30
31	dnl #
32	dnl # 6.6 API change
33	dnl # i_ctime no longer directly accessible, must use
34	dnl # inode_get_ctime(ip), inode_set_ctime*(ip) to
35	dnl # read/write.
36	dnl #
37	ZFS_LINUX_TEST_SRC([inode_get_ctime], [
38		#include <linux/fs.h>
39	],[
40		struct inode ip;
41
42		memset(&ip, 0, sizeof(ip));
43		inode_get_ctime(&ip);
44	])
45
46	ZFS_LINUX_TEST_SRC([inode_set_ctime_to_ts], [
47		#include <linux/fs.h>
48	],[
49		struct inode ip;
50		struct timespec64 ts = {0};
51
52		memset(&ip, 0, sizeof(ip));
53		inode_set_ctime_to_ts(&ip, ts);
54	])
55
56	dnl #
57	dnl # 6.7 API change
58	dnl # i_atime/i_mtime no longer directly accessible, must use
59	dnl # inode_get_mtime(ip), inode_set_mtime*(ip) to
60	dnl # read/write.
61	dnl #
62	ZFS_LINUX_TEST_SRC([inode_get_atime], [
63		#include <linux/fs.h>
64	],[
65		struct inode ip;
66
67		memset(&ip, 0, sizeof(ip));
68		inode_get_atime(&ip);
69	])
70	ZFS_LINUX_TEST_SRC([inode_get_mtime], [
71		#include <linux/fs.h>
72	],[
73		struct inode ip;
74
75		memset(&ip, 0, sizeof(ip));
76		inode_get_mtime(&ip);
77	])
78
79	ZFS_LINUX_TEST_SRC([inode_set_atime_to_ts], [
80		#include <linux/fs.h>
81	],[
82		struct inode ip;
83		struct timespec64 ts = {0};
84
85		memset(&ip, 0, sizeof(ip));
86		inode_set_atime_to_ts(&ip, ts);
87	])
88	ZFS_LINUX_TEST_SRC([inode_set_mtime_to_ts], [
89		#include <linux/fs.h>
90	],[
91		struct inode ip;
92		struct timespec64 ts = {0};
93
94		memset(&ip, 0, sizeof(ip));
95		inode_set_mtime_to_ts(&ip, ts);
96	])
97])
98
99AC_DEFUN([ZFS_AC_KERNEL_INODE_TIMES], [
100	AC_MSG_CHECKING([whether timestamp_truncate() exists])
101	ZFS_LINUX_TEST_RESULT([timestamp_truncate], [
102		AC_MSG_RESULT(yes)
103		AC_DEFINE(HAVE_INODE_TIMESTAMP_TRUNCATE, 1,
104		    [timestamp_truncate() exists])
105	],[
106		AC_MSG_RESULT(no)
107	])
108
109	AC_MSG_CHECKING([whether inode->i_*time's are timespec64])
110	ZFS_LINUX_TEST_RESULT([inode_times], [
111		AC_MSG_RESULT(no)
112	],[
113		AC_MSG_RESULT(yes)
114		AC_DEFINE(HAVE_INODE_TIMESPEC64_TIMES, 1,
115		    [inode->i_*time's are timespec64])
116	])
117
118	AC_MSG_CHECKING([whether inode_get_ctime() exists])
119	ZFS_LINUX_TEST_RESULT([inode_get_ctime], [
120		AC_MSG_RESULT(yes)
121		AC_DEFINE(HAVE_INODE_GET_CTIME, 1,
122		    [inode_get_ctime() exists in linux/fs.h])
123	],[
124		AC_MSG_RESULT(no)
125	])
126
127	AC_MSG_CHECKING([whether inode_set_ctime_to_ts() exists])
128	ZFS_LINUX_TEST_RESULT([inode_set_ctime_to_ts], [
129		AC_MSG_RESULT(yes)
130		AC_DEFINE(HAVE_INODE_SET_CTIME_TO_TS, 1,
131		    [inode_set_ctime_to_ts() exists in linux/fs.h])
132	],[
133		AC_MSG_RESULT(no)
134	])
135
136	AC_MSG_CHECKING([whether inode_get_atime() exists])
137	ZFS_LINUX_TEST_RESULT([inode_get_atime], [
138		AC_MSG_RESULT(yes)
139		AC_DEFINE(HAVE_INODE_GET_ATIME, 1,
140		    [inode_get_atime() exists in linux/fs.h])
141	],[
142		AC_MSG_RESULT(no)
143	])
144
145	AC_MSG_CHECKING([whether inode_set_atime_to_ts() exists])
146	ZFS_LINUX_TEST_RESULT([inode_set_atime_to_ts], [
147		AC_MSG_RESULT(yes)
148		AC_DEFINE(HAVE_INODE_SET_ATIME_TO_TS, 1,
149		    [inode_set_atime_to_ts() exists in linux/fs.h])
150	],[
151		AC_MSG_RESULT(no)
152	])
153
154	AC_MSG_CHECKING([whether inode_get_mtime() exists])
155	ZFS_LINUX_TEST_RESULT([inode_get_mtime], [
156		AC_MSG_RESULT(yes)
157		AC_DEFINE(HAVE_INODE_GET_MTIME, 1,
158		    [inode_get_mtime() exists in linux/fs.h])
159	],[
160		AC_MSG_RESULT(no)
161	])
162
163	AC_MSG_CHECKING([whether inode_set_mtime_to_ts() exists])
164	ZFS_LINUX_TEST_RESULT([inode_set_mtime_to_ts], [
165		AC_MSG_RESULT(yes)
166		AC_DEFINE(HAVE_INODE_SET_MTIME_TO_TS, 1,
167		    [inode_set_mtime_to_ts() exists in linux/fs.h])
168	],[
169		AC_MSG_RESULT(no)
170	])
171])
172