cf82056759797f12425f0460c040da49bfb65fe4
[openafs.git] / src / cf / linux-test4.m4
1
2 AC_DEFUN([LINUX_AIO_NONVECTOR],
3  [AC_CHECK_LINUX_BUILD([for non-vectorized aio kernel functions],
4                        [ac_cv_linux_aio_nonvector],
5                        [#include <linux/fs.h>],
6                        [extern ssize_t
7                         generic_file_aio_read(struct kiocb *, char __user *,
8                                               size_t, loff_t);],
9                        [LINUX_HAS_NONVECTOR_AIO],
10                        [define if kernel functions like generic_file_aio_read use
11                         non-vectorized i/o],
12                        [])
13  ])
14
15 AC_DEFUN([LINUX_EXPORTS_TASKLIST_LOCK], [
16   AC_CHECK_LINUX_BUILD([for exported tasklist_lock],
17                        [ac_cv_linux_exports_tasklist_lock],
18 [#include <linux/sched.h>],
19 [
20 extern rwlock_t tasklist_lock __attribute__((weak)); 
21 read_lock(&tasklist_lock);
22 ],
23                        [EXPORTED_TASKLIST_LOCK],
24                        [define if tasklist_lock exported],
25                        [])
26 ])
27
28
29 AC_DEFUN([LINUX_EXPORTS_INIT_MM], [
30   AC_CHECK_LINUX_BUILD([for exported init_mm],
31                        [ac_cv_linux_exports_init_mm],
32                        [extern struct mm_struct init_mm;],
33                        [void *address = &init_mm; printk("%p\n", address);],
34                        [EXPORTED_INIT_MM],
35                        [define if your kernel exports init_mm],
36                        [])
37   ])
38
39
40 AC_DEFUN([LINUX_EXPORTS_KALLSYMS_ADDRESS], [
41   AC_CHECK_LINUX_BUILD([for exported kallsyms_address_to_symbol],
42                        [ac_cv_linux_exports_kallsyms_address],
43                        [#include <linux/modversions.h>],
44 [#ifndef __ver_kallsyms_address_to_symbol
45 #error kallsyms_address_to_symbol not exported
46 #endif],
47                        [EXPORTED_KALLSYMS_ADDRESS],
48                        [define if your linux kernel exports kallsyms address],
49                        [])
50 ])
51
52
53 AC_DEFUN([LINUX_EXPORTS_KALLSYMS_SYMBOL], [
54   AC_CHECK_LINUX_BUILD([for exported kallsyms_symbol_to_address],
55                        [ac_cv_linux_exports_kallsyms_symbol],
56                        [#include <linux/modversions.h>],
57 [#ifndef __ver_kallsyms_symbol_to_address
58 #error kallsyms_symbol_to_address not exported
59 #endif],
60                        [EXPORTED_KALLSYMS_SYMBOL],
61                        [define if your linux kernel exports kallsyms],
62                        [])
63 ])
64
65
66 AC_DEFUN([LINUX_EXPORTS_SYS_CALL_TABLE], [
67   AC_CHECK_LINUX_BUILD([for exported sys_call_table],
68                        [ac_cv_linux_exports_sys_call_table],
69                        [#include <linux/modversions.h>],
70 [#ifndef __ver_sys_call_table
71 #error sys_call_table not exported
72 #endif],
73                        [EXPORTED_SYS_CALL_TABLE],
74                        [define if your linux kernel exports sys_call_table],
75                        [])
76 ])
77
78
79 AC_DEFUN([LINUX_EXPORTS_IA32_SYS_CALL_TABLE], [
80   AC_CHECK_LINUX_BUILD([for exported ia32_sys_call_table],
81                        [ac_cv_linux_exports_ia32_sys_call_table],
82                        [#include <linux/modversions.h>],
83 [#ifndef __ver_ia32_sys_call_table
84 #error ia32_sys_call_table not exported
85 #endif],
86                        [EXPORTED_IA32_SYS_CALL_TABLE],
87                        [define if your linux kernel exports ia32_sys_call_table],
88                        [])
89 ])
90
91
92 AC_DEFUN([LINUX_EXPORTS_SYS_CHDIR], [
93   AC_CHECK_LINUX_BUILD([for exported sys_chdir],
94                        [ac_cv_linux_exports_sys_chdir],
95                        [extern asmlinkage long sys_chdir(void) __attribute__((weak));],
96                        [void *address = &sys_chdir; printk("%p\n", address);],
97                        [EXPORTED_SYS_CHDIR],
98                        [define if your linux kernel exports sys_chdir],
99                        [])
100 ])
101
102
103 AC_DEFUN([LINUX_EXPORTS_SYS_OPEN], [
104   AC_CHECK_LINUX_BUILD([for exported sys_open],
105                        [ac_cv_linux_exports_sys_open],
106                        [extern asmlinkage long sys_open(void) __attribute__((weak));],
107                        [void *address = &sys_open; printk("%p\n", address);],
108                        [EXPORTED_SYS_OPEN],
109                        [define if your linux kernel exports sys_open],
110                        [])
111 ])
112
113
114 AC_DEFUN([LINUX_RECALC_SIGPENDING_ARG_TYPE], [
115   AC_CHECK_LINUX_BUILD([for recalc_sigpending arg type],
116                        [ac_cv_linux_func_recalc_sigpending_takes_void],
117 [#include <linux/sched.h>
118 #ifdef HAVE_LINUX_SCHED_SIGNAL_H
119 #include <linux/sched/signal.h>
120 #endif],
121                        [recalc_sigpending();],
122                        [RECALC_SIGPENDING_TAKES_VOID],
123                        [define if your recalc_sigpending takes void],
124                        [])
125 ])
126
127
128 AC_DEFUN([LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_SIGNAL_RLIM], [
129   AC_CHECK_LINUX_BUILD([for signal->rlim in struct task_struct],
130                        [ac_cv_linux_sched_struct_task_struct_has_signal_rlim],
131 [#include <linux/sched.h>
132 #ifdef HAVE_LINUX_SCHED_SIGNAL_H
133 #include <linux/sched/signal.h>
134 #endif],
135                        [struct task_struct _tsk; printk("%d\n", _tsk.signal->rlim);],
136                        [STRUCT_TASK_STRUCT_HAS_SIGNAL_RLIM],
137                        [define if your struct task_struct has signal->rlim],
138                        [])
139 ])
140
141
142 AC_DEFUN([LINUX_KERNEL_POSIX_LOCK_FILE_WAIT_ARG], [
143   AC_CHECK_LINUX_BUILD([for 3rd argument in posix_lock_file found in new kernels],
144                        [ac_cv_linux_kernel_posix_lock_file_wait_arg],
145                        [#include <linux/fs.h>],
146                        [posix_lock_file(0,0,0);],
147                        [POSIX_LOCK_FILE_WAIT_ARG],
148                        [define if your kernel uses 3 arguments for posix_lock_file],
149                        [])
150 ])
151
152 AC_DEFUN([LINUX_KERNEL_PAGEVEC_INIT_COLD_ARG], [
153   AC_CHECK_LINUX_BUILD([for 2nd argument in pagevec_init found in pre-4.15 kernels],
154                        [ac_cv_linux_kernel_pagevec_init_cold_arg],
155                        [#include <linux/pagevec.h>],
156                        [pagevec_init(0,0);],
157                        [PAGEVEC_INIT_COLD_ARG],
158                        [define if your kernel uses 2 arguments for pagevec_init],
159                        [])
160 ])
161
162 AC_DEFUN([LINUX_KERNEL_SOCK_CREATE], [
163   AC_CHECK_LINUX_BUILD([for 5th argument in sock_create found in some SELinux kernels],
164                        [ac_cv_linux_kernel_sock_create_v],
165                        [#include <linux/net.h>],
166                        [sock_create(0,0,0,0,0);],
167                        [LINUX_KERNEL_SOCK_CREATE_V],
168                        [define if your linux kernel uses 5 arguments for sock_create],
169                        [])
170 ])
171
172
173 AC_DEFUN([LINUX_INODE_SETATTR_RETURN_TYPE], [
174   AC_CHECK_LINUX_BUILD([for inode_setattr return type],
175                        [ac_cv_linux_func_inode_setattr_returns_int],
176                        [#include <linux/fs.h>],
177                        [struct inode _inode;
178                         struct iattr _iattr;
179                         int i;
180                         i = inode_setattr(&_inode, &_iattr);],
181                        [INODE_SETATTR_NOT_VOID],
182                        [define if your setattr return return non-void],
183                        [])
184 ])
185
186 AC_DEFUN([LINUX_IATTR_64BIT_TIME], [
187   AC_CHECK_LINUX_BUILD([whether struct iattr->ia_ctime takes struct timespec64 or 32-bit struct timespec],
188                        [ac_cv_linux_func_iattr_ctime_takes_timespec64],
189                        [#include <linux/fs.h>
190                         #include <linux/timekeeping.h>],
191                        [struct iattr _attrs;
192                        #if defined(HAVE_LINUX_KTIME_GET_COARSE_REAL_TS64)
193                         ktime_get_coarse_real_ts64(&_attrs.ia_ctime);
194                        #else
195                         _attrs.ia_ctime = current_kernel_time64();
196                        #endif
197                        ],
198                        [IATTR_TAKES_64BIT_TIME],
199                        [define if struct iattr->ia_ctime takes struct timespec64],
200                        [])
201 ])
202
203 AC_DEFUN([LINUX_AOP_WRITEBACK_CONTROL], [
204   AC_CHECK_LINUX_BUILD([whether aop.writepage takes a writeback_control],
205                        [ac_cv_linux_func_a_writepage_takes_writeback_control],
206 [#include <linux/fs.h>
207 #include <linux/mm.h>
208 #include <linux/writeback.h>],
209 [struct address_space_operations _aops;
210 struct page _page;
211 struct writeback_control _writeback_control;
212 (void)_aops.writepage(&_page, &_writeback_control);],
213                        [AOP_WRITEPAGE_TAKES_WRITEBACK_CONTROL],
214                        [define if aops.writepage takes a struct writeback_control],
215                        [])
216 ])
217
218
219 AC_DEFUN([LINUX_REFRIGERATOR], [
220   AC_CHECK_LINUX_BUILD([whether refrigerator takes PF_FREEZE],
221                        [ac_cv_linux_func_refrigerator_takes_pf_freeze],
222 [#include <linux/sched.h>
223 #ifdef HAVE_LINUX_FREEZER_H
224 #include <linux/freezer.h>
225 #endif],
226                        [refrigerator(PF_FREEZE);],
227                        [LINUX_REFRIGERATOR_TAKES_PF_FREEZE],
228                        [define if your refrigerator takes PF_FREEZE],
229                        [])
230 ])
231
232
233 AC_DEFUN([LINUX_IOP_I_CREATE_TAKES_NAMEIDATA], [
234   AC_CHECK_LINUX_BUILD([whether inode_operations.create takes a nameidata],
235                        [ac_cv_linux_func_i_create_takes_nameidata],
236 [#include <linux/fs.h>
237 #include <linux/namei.h>],
238 [struct inode _inode;
239 struct dentry _dentry;
240 struct nameidata _nameidata;
241 (void)_inode.i_op->create(&_inode, &_dentry, 0, &_nameidata);],
242
243                        [IOP_CREATE_TAKES_NAMEIDATA],
244                        [define if your iops.create takes a nameidata argument],
245                        [])
246 ])
247
248
249 AC_DEFUN([LINUX_IOP_I_LOOKUP_TAKES_NAMEIDATA], [
250   AC_CHECK_LINUX_BUILD([whether inode_operations.lookup takes a nameidata],
251                        [ac_cv_linux_func_i_lookup_takes_nameidata],
252 [#include <linux/fs.h>
253 #include <linux/namei.h>],
254 [struct inode _inode;
255 struct dentry _dentry;
256 struct nameidata _nameidata;
257 (void)_inode.i_op->lookup(&_inode, &_dentry, &_nameidata);],
258                        [IOP_LOOKUP_TAKES_NAMEIDATA],
259                        [define if your iops.lookup takes a nameidata argument],
260                        [])
261 ])
262
263
264 AC_DEFUN([LINUX_IOP_I_PERMISSION_TAKES_NAMEIDATA], [
265   AC_CHECK_LINUX_BUILD([whether inode_operations.permission takes a nameidata],
266                        [ac_cv_linux_func_i_permission_takes_nameidata],
267 [#include <linux/fs.h>
268 #include <linux/namei.h>],
269 [struct inode _inode;
270 struct nameidata _nameidata;
271 (void)_inode.i_op->permission(&_inode, 0, &_nameidata);],
272                        [IOP_PERMISSION_TAKES_NAMEIDATA],
273                        [define if your iops.permission takes a nameidata argument],
274                        [-Werror])
275 ])
276
277
278 AC_DEFUN([LINUX_IOP_I_PERMISSION_TAKES_FLAGS], [
279   AC_CHECK_LINUX_BUILD([whether inode_operations.permission takes flags],
280                         [ac_cv_linux_func_i_permission_takes_flags],
281                         [#include <linux/fs.h>],
282                         [struct inode _inode = {0};
283                         unsigned int flags = 0;
284                         (void)_inode.i_op->permission(&_inode, 0, flags);],
285                        [IOP_PERMISSION_TAKES_FLAGS],
286                        [define if your iops.permission takes a flags argument],
287                        [-Werror])
288 ])
289
290
291 AC_DEFUN([LINUX_IOP_I_PUT_LINK_TAKES_COOKIE], [
292   AC_CHECK_LINUX_BUILD([whether inode_operations.put_link takes an opaque cookie],
293                        [ac_cv_linux_func_i_put_link_takes_cookie],
294 [#include <linux/fs.h>
295 #include <linux/namei.h>],
296 [struct inode _inode;
297 struct dentry _dentry;
298 struct nameidata *_nameidata;
299 void *cookie;
300 (void)_inode.i_op->put_link(&_dentry, _nameidata, cookie);],
301                        [IOP_PUT_LINK_TAKES_COOKIE],
302                        [define if your iops.put_link takes a cookie],
303                        [])
304 ])
305
306
307 AC_DEFUN([LINUX_DOP_D_REVALIDATE_TAKES_NAMEIDATA], [
308   AC_CHECK_LINUX_BUILD([whether dentry_operations.d_revalidate takes a nameidata],
309                        [ac_cv_linux_func_d_revalidate_takes_nameidata],
310                         [#include <linux/fs.h>
311                         #include <linux/namei.h>
312                         static int reval(struct dentry *d, struct nameidata *nd) { return 0; }
313                         struct dentry_operations dops;],
314                         [dops.d_revalidate = reval;],
315                        [DOP_REVALIDATE_TAKES_NAMEIDATA],
316                        [define if your dops.d_revalidate takes a nameidata argument],
317                        [-Werror])
318 ])
319
320
321 AC_DEFUN([LINUX_GET_SB_HAS_STRUCT_VFSMOUNT], [
322   AC_CHECK_LINUX_BUILD([for struct vfsmount * in get_sb_nodev()],
323                        [ac_cv_linux_get_sb_has_struct_vfsmount],
324                        [#include <linux/fs.h>],
325                        [get_sb_nodev(0,0,0,0,0);],
326                        [GET_SB_HAS_STRUCT_VFSMOUNT],
327                        [define if your get_sb_nodev needs a struct vfsmount argument],
328                        [])
329 ])
330
331
332 AC_DEFUN([LINUX_STATFS_TAKES_DENTRY], [
333   AC_CHECK_LINUX_BUILD([for dentry in statfs],
334                        [ac_cv_linux_statfs_takes_dentry],
335 [#include <linux/fs.h>
336 #include <linux/statfs.h>],
337 [extern int simple_statfs(struct dentry *, struct kstatfs *);],
338                        [STATFS_TAKES_DENTRY],
339                        [define if your statfs takes a dentry argument],
340                        [])
341 ])
342
343
344 AC_DEFUN([LINUX_LINUX_KEYRING_SUPPORT], [
345   AC_CHECK_LINUX_BUILD([for linux kernel keyring support],
346                        [ac_cv_linux_keyring_support],
347 [#include <linux/rwsem.h>
348 #ifdef HAVE_LINUX_KEY_TYPE_H
349 #include <linux/key-type.h>
350 #endif
351 #include <linux/key.h>
352 #include <linux/keyctl.h>],
353 [#ifdef CONFIG_KEYS
354 request_key(NULL, NULL, NULL);
355 #if !defined(KEY_POS_VIEW) || !defined(KEY_POS_SEARCH) || !defined(KEY_POS_SETATTR) 
356 #error "Your linux/key.h does not contain KEY_POS_VIEW or KEY_POS_SEARCH or KEY_POS_SETATTR"
357 #endif
358 #else
359 #error rebuild your kernel with CONFIG_KEYS
360 #endif],
361                        [LINUX_KEYRING_SUPPORT],
362                        [define if your kernel has keyring support],
363                        [])
364 ])
365
366
367 AC_DEFUN([LINUX_KEY_ALLOC_NEEDS_STRUCT_TASK], [
368   AC_CHECK_LINUX_BUILD([if key_alloc() takes a struct task *],
369                         [ac_cv_key_alloc_needs_struct_task],
370                         [#include <linux/rwsem.h>
371                         #include <linux/key.h> ],
372                         [struct task_struct *t=NULL;
373                         struct key k = {};
374                         (void) key_alloc(NULL, NULL, k.uid, k.gid, t, 0, 0);],
375                         [KEY_ALLOC_NEEDS_STRUCT_TASK],
376                         [define if key_alloc takes a struct task *],
377                         [-Werror -Wno-pointer-arith])
378 ])
379
380
381 AC_DEFUN([LINUX_KEY_ALLOC_NEEDS_CRED], [
382   AC_CHECK_LINUX_BUILD([if key_alloc() takes credentials],
383                         [ac_cv_key_alloc_needs_cred],
384                         [#include <linux/rwsem.h>
385                         #include <linux/key.h>],
386                         [struct cred *c = NULL;
387                         struct key k = {};
388                         (void) key_alloc(NULL, NULL, k.uid, k.gid, c, 0, 0);],
389                         [KEY_ALLOC_NEEDS_CRED],
390                         [define if key_alloc takes credentials],
391                         [-Werror -Wno-pointer-arith])
392 ])
393
394
395 AC_DEFUN([LINUX_INIT_WORK_HAS_DATA], [
396   AC_CHECK_LINUX_BUILD([whether INIT_WORK has a _data argument],
397                        [ac_cv_linux_init_work_has_data],
398 [#include <linux/kernel.h>
399 #include <linux/workqueue.h>],
400
401 void f(struct work_struct *w) {}
402 struct work_struct *w;
403 int *i;
404 INIT_WORK(w,f,i);],
405                        [INIT_WORK_HAS_DATA],
406                        [define if INIT_WORK takes a data (3rd) argument],
407                        [])
408 ])
409
410
411 AC_DEFUN([LINUX_REGISTER_SYSCTL_TABLE_NOFLAG], [
412   AC_CHECK_LINUX_BUILD([whether register_sysctl_table has an insert_at_head argument],
413                        [ac_cv_linux_register_sysctl_table_noflag],
414                        [#include <linux/sysctl.h>],
415                        [struct ctl_table *t; register_sysctl_table (t);],
416                        [REGISTER_SYSCTL_TABLE_NOFLAG],
417                        [define if register_sysctl_table has no insert_at head flag],
418                        [])
419 ])
420
421
422 AC_DEFUN([LINUX_FOP_F_FLUSH_TAKES_FL_OWNER_T], [
423   AC_CHECK_LINUX_BUILD([whether file_operations.flush takes a fl_owner_t],
424                        [ac_cv_linux_func_f_flush_takes_fl_owner_t],
425                        [#include <linux/fs.h>],
426 [struct inode _inode;
427 struct file _file;
428 fl_owner_t id;
429 (void)_inode.i_fop->flush(&_file, &id);],
430                        [FOP_FLUSH_TAKES_FL_OWNER_T],
431                        [define if your fops.flush takes an fl_owner_t argument],
432                        [])
433 ])
434
435
436 AC_DEFUN([LINUX_FOP_F_FSYNC_TAKES_DENTRY], [
437   AC_CHECK_LINUX_BUILD([whether file_operations.fsync takes a dentry argument],
438                        [ac_cv_linux_func_f_fsync_takes_dentry],
439                        [#include <linux/fs.h>],
440 [struct inode _inode;
441 struct file _file;
442 struct dentry _d;
443 (void)_inode.i_fop->fsync(&_file, &_d, 0);],
444                        [FOP_FSYNC_TAKES_DENTRY],
445                        [define if your fops.fsync takes an dentry argument],
446                        [])
447 ])
448
449
450 int (*fsync) (struct file *, loff_t start, loff_t end, int datasync);
451
452 AC_DEFUN([LINUX_FOP_F_FSYNC_TAKES_RANGE], [
453   AC_CHECK_LINUX_BUILD([whether file_operations.fsync takes a range],
454                        [ac_cv_linux_func_f_fsync_takes_range],
455                        [#include <linux/fs.h>],
456 [struct inode _inode;
457 struct file _file;
458 loff_t start, end;
459 (void)_inode.i_fop->fsync(&_file, start, end, 0);],
460                        [FOP_FSYNC_TAKES_RANGE],
461                        [define if your fops.fsync takes range arguments],
462                        [])
463 ])
464
465
466 AC_DEFUN([LINUX_HAVE_KMEM_CACHE_T], [
467   AC_CHECK_LINUX_BUILD([whether kmem_cache_t exists],
468                        [ac_cv_linux_have_kmem_cache_t],
469                        [#include <linux/slab.h>],
470                        [kmem_cache_t *k;],
471                        [HAVE_KMEM_CACHE_T],
472                        [define if kmem_cache_t exists],
473                        [])
474 ])
475
476
477 AC_DEFUN([LINUX_KMEM_CACHE_CREATE_TAKES_DTOR], [
478   AC_CHECK_LINUX_BUILD([whether kmem_cache_create takes a destructor argument],
479                        [ac_cv_linux_kmem_cache_create_takes_dtor],
480                        [#include <linux/slab.h>],
481                        [kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);],
482                        [KMEM_CACHE_TAKES_DTOR],
483                        [define if kmem_cache_create takes a destructor argument],
484                        [])
485 ])
486
487
488 AC_DEFUN([LINUX_KMEM_CACHE_CREATE_CTOR_TAKES_VOID],[
489   AC_CHECK_LINUX_BUILD([whether kmem_cache_create constructor takes a void pointer],
490                         [ac_cv_linux_kmem_cache_create_ctor_takes_void],
491                         [#include <linux/slab.h>],
492                         [void _ctor(void *v) { }; kmem_cache_create(NULL, 0, 0, 0, _ctor);],
493                         [KMEM_CACHE_CTOR_TAKES_VOID],
494                         [define if kmem_cache_create constructor takes a single void ptr],
495                         [-Werror])
496 ])
497
498
499 dnl This function checks not just the existence of the splice functions,
500 dnl but also that the signature matches (they gained an extra argument
501 dnl around 2.6.17)
502 AC_DEFUN([LINUX_FS_STRUCT_FOP_HAS_SPLICE], [
503   AC_CHECK_LINUX_BUILD([for splice_write and splice_read in struct file_operations],
504                        [ac_cv_linux_fs_struct_fop_has_splice],
505                        [#include <linux/fs.h>],
506                        [struct file_operations _fop;
507                         _fop.splice_write(NULL, NULL, NULL, 0, 0);
508                         _fop.splice_read(NULL, NULL, NULL, 0, 0);],
509                        [STRUCT_FILE_OPERATIONS_HAS_SPLICE],
510                        [define if struct file_operations has splice functions],
511                        [])
512 ])
513
514
515 AC_DEFUN([LINUX_KMEM_CACHE_INIT], [
516   AC_CHECK_LINUX_BUILD([for new kmem_cache init function parameters],
517                        [ac_cv_linux_kmem_cache_init],
518                        [#include <linux/slab.h>],
519                        [extern struct kmem_cache *
520                         kmem_cache_create(const char *, size_t, size_t,
521                                           unsigned long,
522                                           void (*)(struct kmem_cache *, void *));
523                         return;],
524                        [KMEM_CACHE_INIT],
525                        [define for new kmem_cache init function parameters],
526                        [])
527 ])
528
529
530 AC_DEFUN([LINUX_EXPORTS_PROC_ROOT_FS], [
531   AC_CHECK_LINUX_BUILD([if proc_root_fs is defined and exported],
532                        [ac_cv_linux_exports_proc_root_fs],
533                        [#include <linux/proc_fs.h>],
534                        [struct proc_dir_entry *p = proc_root_fs;],
535                        [EXPORTED_PROC_ROOT_FS],
536                        [define if proc_root_fs is exported],
537                        [])
538 ])
539
540
541 AC_DEFUN([LINUX_D_PATH_TAKES_STRUCT_PATH], [
542   AC_CHECK_LINUX_BUILD([if d_path() takes a struct path argument],
543                        [ac_cv_linux_d_path_takes_struct_path],
544                        [#include <linux/fs.h>],
545                        [struct path *p; d_path(p, NULL, 0);],
546                        [D_PATH_TAKES_STRUCT_PATH],
547                        [define if d_path() takes a struct path argument],
548                        [])
549 ])
550
551
552 AC_DEFUN([LINUX_NEW_EXPORT_OPS], [
553   AC_CHECK_LINUX_BUILD([if kernel uses new export ops],
554                        [ac_cv_linux_new_export_ops],
555                        [#include <linux/exportfs.h>],
556                        [struct export_operations _eops;
557                         _eops.fh_to_parent(NULL, NULL, 0, 0);],
558                        [NEW_EXPORT_OPS],
559                        [define if kernel uses new export ops],
560                        [])
561 ])
562
563
564 AC_DEFUN([LINUX_POSIX_TEST_LOCK_RETURNS_CONFLICT], [
565   AC_CHECK_LINUX_BUILD([if posix_test_lock returns a struct file_lock],
566                        [ac_cv_linux_posix_test_lock_returns_conflict],
567                        [#include <linux/fs.h>],
568                        [struct file_lock *lock;
569                         struct file * file;
570                         lock = posix_test_lock(file, lock);],
571                        [POSIX_TEST_LOCK_RETURNS_CONFLICT],
572                        [define if posix_test_lock returns the conflicting lock],
573                        [])
574 ])
575
576
577 AC_DEFUN([LINUX_POSIX_TEST_LOCK_CONFLICT_ARG], [
578   AC_CHECK_LINUX_BUILD([if posix_test_lock takes a conflict argument],
579                        [ac_cv_linux_posix_test_lock_conflict_arg],
580                        [#include <linux/fs.h>],
581                        [struct file_lock *lock;
582                         struct file *file;
583                         posix_test_lock(file, lock, lock);],
584                        [POSIX_TEST_LOCK_CONFLICT_ARG],
585                        [define if posix_test_lock takes a conflict argument],
586                        [])
587 ])
588
589
590 AC_DEFUN([LINUX_EXPORTS_KEY_TYPE_KEYRING], [
591   AC_CHECK_LINUX_BUILD([for exported key_type_keyring],
592                        [ac_cv_linux_exports_key_type_keyring],
593 [
594 #ifdef HAVE_LINUX_KEY_TYPE_H
595 #include <linux/key-type.h>
596 #endif
597 #include <linux/key.h>
598 ],
599                        [printk("%s", key_type_keyring.name);],
600                        [EXPORTED_KEY_TYPE_KEYRING],
601                        [define if key_type_keyring is exported],
602                        [])
603 ])
604
605
606 AC_DEFUN([LINUX_HAVE_TRY_TO_FREEZE], [
607   AC_CHECK_LINUX_BUILD([for try_to_freeze],
608                        [ac_cv_linux_have_try_to_freeze],
609 [#include <linux/sched.h>
610 #ifdef HAVE_LINUX_FREEZER_H
611 #include <linux/freezer.h>
612 #endif],
613 [#ifdef LINUX_REFRIGERATOR_TAKES_PF_FREEZE
614    try_to_freeze(PF_FREEZE);
615 #else
616    try_to_freeze();
617 #endif],
618                        [HAVE_TRY_TO_FREEZE],
619                        [define if your kernel has the try_to_freeze function],
620                        [])
621 ])
622
623
624 AC_DEFUN([LINUX_HAVE_DCACHE_LOCK], [
625   AC_CHECK_LINUX_BUILD([for dcache_lock],
626                         [ac_cv_linux_have_dcache_lock],
627                         [#include <linux/fs.h> ],
628                         [printk("%p", &dcache_lock);],
629                         [HAVE_DCACHE_LOCK],
630                         [define if dcache_lock exists],
631                         [])
632 ])
633
634
635 AC_DEFUN([LINUX_D_COUNT_IS_INT], [
636   AC_CHECK_LINUX_BUILD([if dentry->d_count is an int],
637                         [ac_cv_linux_d_count_int],
638                         [#include <linux/fs.h> ],
639                         [struct dentry _d;
640                         dget(&_d);
641                         _d.d_count = 1;],
642                         [D_COUNT_INT],
643                         [define if dentry->d_count is an int],
644                         [-Werror])
645 ])
646
647
648 AC_DEFUN([LINUX_DOP_D_DELETE_TAKES_CONST], [
649   AC_CHECK_LINUX_BUILD([whether dentry.d_op->d_delete takes a const argument],
650                         [ac_cv_linux_dop_d_delete_takes_const],
651                         [#include <linux/fs.h>
652                         #include <linux/dcache.h>
653                         static int _d_del(const struct dentry *de) { return 0; }
654                         struct dentry_operations _d_ops;],
655                         [_d_ops.d_delete = _d_del;],
656                         [DOP_D_DELETE_TAKES_CONST],
657                         [define if dentry.d_op->d_delete takes a const argument],
658                         [-Werror])
659 ])
660
661 AC_DEFUN([LINUX_IOP_GETATTR_TAKES_PATH_STRUCT], [
662   AC_CHECK_LINUX_BUILD([whether 4.11+ inode.i_op->getattr takes a struct path argument],
663                         [ac_cv_linux_iop_getattr_takes_path_struct],
664                         [#include <linux/fs.h>
665                         int _getattr(const struct path *path, struct kstat *stat, u32 request_mask,
666                           unsigned int sync_mode) {return 0;};
667                         struct inode_operations _i_ops;],
668                         [_i_ops.getattr = _getattr;],
669                         [IOP_GETATTR_TAKES_PATH_STRUCT],
670                         [define if 4.11+ inode.i_op->getattr takes a struct path argument],
671                         [-Werror])
672 ])
673
674 AC_DEFUN([LINUX_IOP_MKDIR_TAKES_UMODE_T], [
675   AC_CHECK_LINUX_BUILD([whether inode.i_op->mkdir takes a umode_t argument],
676                         [ac_cv_linux_iop_mkdir_takes_umode_t],
677                         [#include <linux/fs.h>
678                         static int _mkdir(struct inode *i, struct dentry *d, umode_t m) { return 0; }
679                         struct inode_operations _i_ops;],
680                         [_i_ops.mkdir = _mkdir;],
681                         [IOP_MKDIR_TAKES_UMODE_T],
682                         [define if inode.i_op->mkdir takes a umode_t argument],
683                         [-Werror])
684 ])
685
686
687 AC_DEFUN([LINUX_IOP_CREATE_TAKES_UMODE_T], [
688   AC_CHECK_LINUX_BUILD([whether inode.i_op->create takes a umode_t argument],
689                         [ac_cv_linux_iop_create_takes_umode_t],
690                         [#include <linux/fs.h>],
691                         [struct inode_operations _i_ops;
692                         int _create(struct inode *i, struct dentry *d, umode_t m, struct nameidata *n)
693                                 {return 0;};
694                         _i_ops.create = _create;],
695                         [IOP_CREATE_TAKES_UMODE_T],
696                         [define if inode.i_op->create takes a umode_t argument],
697                         [-Werror])
698 ])
699
700
701 AC_DEFUN([LINUX_EXPORT_OP_ENCODE_FH_TAKES_INODES], [
702   AC_CHECK_LINUX_BUILD([whether export operation encode_fh takes inode arguments],
703                         [ac_cv_linux_export_op_encode_fh__takes_inodes],
704                         [#include <linux/exportfs.h>
705                         static int _encode_fh(struct inode *i, __u32 *fh, int *len, struct inode *p) { return 0; }
706                         struct export_operations _exp_ops;],
707                         [_exp_ops.encode_fh = _encode_fh;],
708                         [EXPORT_OP_ENCODE_FH_TAKES_INODES],
709                         [define if encode_fh export op takes inode arguments],
710                         [-Werror])
711 ])
712
713
714 AC_DEFUN([LINUX_KMAP_ATOMIC_TAKES_NO_KM_TYPE], [
715   AC_CHECK_LINUX_BUILD([whether kmap_atomic takes no km_type argument],
716                         [ac_cv_linux_kma_atomic_takes_no_km_type],
717                         [#include <linux/highmem.h>],
718                         [struct page *p = NULL;
719                         kmap_atomic(p);],
720                         [KMAP_ATOMIC_TAKES_NO_KM_TYPE],
721                         [define if kmap_atomic takes no km_type argument],
722                         [-Werror])
723 ])
724
725
726 AC_DEFUN([LINUX_DENTRY_OPEN_TAKES_PATH], [
727   AC_CHECK_LINUX_BUILD([whether dentry_open takes a path argument],
728                         [ac_cv_linux_dentry_open_takes_path],
729                         [#include <linux/fs.h>],
730                         [struct path p;
731                         dentry_open(&p, 0, NULL);],
732                         [DENTRY_OPEN_TAKES_PATH],
733                         [define if dentry_open takes a path argument],
734                         [-Werror])
735 ])
736
737
738 AC_DEFUN([LINUX_D_ALIAS_IS_HLIST], [
739   AC_CHECK_LINUX_BUILD([whether dentry->d_alias is an hlist],
740                         [ac_cv_linux_d_alias_is_hlist],
741                         [#include <linux/fs.h>],
742                         [struct dentry *d = NULL;
743                         struct hlist_node *hn = NULL;
744                         #if defined(STRUCT_DENTRY_HAS_D_U_D_ALIAS)
745                         d->d_u.d_alias = *hn;
746                         #else
747                         d->d_alias = *hn;
748                         #endif],
749                         [D_ALIAS_IS_HLIST],
750                         [define if dentry->d_alias is an hlist],
751                         [])
752 ])
753
754
755 AC_DEFUN([LINUX_HLIST_ITERATOR_NO_NODE], [
756   AC_CHECK_LINUX_BUILD([whether hlist iterators don't need a node parameter],
757                         [ac_cv_linux_hlist_takes_no_node],
758                         [#include <linux/list.h>
759                         #include <linux/fs.h>],
760                         [struct dentry *d = NULL, *cur;
761                         struct inode *ip;
762                         #if defined(STRUCT_DENTRY_HAS_D_U_D_ALIAS)
763                         # define d_alias d_u.d_alias
764                         #endif
765                         hlist_for_each_entry(cur, &ip->i_dentry, d_alias) { }
766                         ],
767                         [HLIST_ITERATOR_NO_NODE],
768                         [define if hlist iterators don't need a node parameter],
769                         [])
770 ])
771
772
773 AC_DEFUN([LINUX_IOP_I_CREATE_TAKES_BOOL], [
774   AC_CHECK_LINUX_BUILD([whether inode_operations.create takes a bool],
775                         [ac_cv_linux_func_i_create_takes_bool],
776                         [#include <linux/fs.h>
777                         #include <linux/namei.h>],
778                         [struct inode _inode = {};
779                         struct dentry _dentry;
780                         bool b = true;
781                         (void)_inode.i_op->create(&_inode, &_dentry, 0, b);],
782                        [IOP_CREATE_TAKES_BOOL],
783                        [define if your iops.create takes a bool argument],
784                        [-Werror])
785 ])
786
787
788 AC_DEFUN([LINUX_DOP_D_REVALIDATE_TAKES_UNSIGNED], [
789   AC_CHECK_LINUX_BUILD([whether dentry_operations.d_revalidate takes an unsigned int],
790                         [ac_cv_linux_func_d_revalidate_takes_unsigned],
791                         [#include <linux/fs.h>
792                         #include <linux/namei.h>
793                         static int reval(struct dentry *d, unsigned int i) { return 0; }
794                         struct dentry_operations _d_ops;],
795                         [_d_ops.d_revalidate = reval;],
796                        [DOP_REVALIDATE_TAKES_UNSIGNED],
797                        [define if your dops.d_revalidate takes an unsigned int argument],
798                        [-Werror])
799 ])
800
801
802 AC_DEFUN([LINUX_IOP_LOOKUP_TAKES_UNSIGNED], [
803   AC_CHECK_LINUX_BUILD([whether inode operation lookup takes an unsigned int],
804                         [ac_cv_linux_func_lookup_takes_unsigned],
805                         [#include <linux/fs.h>
806                         #include <linux/namei.h>
807                         static struct dentry *look(struct inode *i, struct dentry *d, unsigned int j) { return NULL; }
808                         struct inode_operations _i_ops;],
809                         [_i_ops.lookup = look;],
810                        [IOP_LOOKUP_TAKES_UNSIGNED],
811                        [define if your iops.lookup takes an unsigned int argument],
812                        [-Werror])
813 ])
814
815
816 AC_DEFUN([LINUX_D_INVALIDATE_IS_VOID], [
817   AC_CHECK_LINUX_BUILD([whether d_invalidate returns void],
818                         [ac_cv_linux_func_d_invalidate_returns_void],
819                         [#include <linux/fs.h>],
820                         [
821                         void d_invalidate(struct dentry *);
822                         ],
823                        [D_INVALIDATE_IS_VOID],
824                        [define if your d_invalidate returns void],
825                        [])
826 ])
827
828 AC_DEFUN([LINUX_KERNEL_READ_OFFSET_IS_LAST], [
829   AC_CHECK_LINUX_BUILD([whether offset is the last argument to kernel_read],
830                        [ac_cv_linux_func_kernel_read_offset_is_last],
831                        [#include <linux/fs.h>],
832                        [
833                        ssize_t kernel_read(struct file *, void *, size_t, loff_t *);
834                        ],
835                        [KERNEL_READ_OFFSET_IS_LAST],
836                        [define if your kernel_read has offset as the last argument],
837                        [])
838 ])