50b8a0ede4ff852f782c8e1ee60e6f3726633662
[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                         _attrs.ia_ctime = current_kernel_time64();],
193                        [IATTR_TAKES_64BIT_TIME],
194                        [define if struct iattr->ia_ctime takes struct timespec64],
195                        [])
196 ])
197
198 AC_DEFUN([LINUX_AOP_WRITEBACK_CONTROL], [
199   AC_CHECK_LINUX_BUILD([whether aop.writepage takes a writeback_control],
200                        [ac_cv_linux_func_a_writepage_takes_writeback_control],
201 [#include <linux/fs.h>
202 #include <linux/mm.h>
203 #include <linux/writeback.h>],
204 [struct address_space_operations _aops;
205 struct page _page;
206 struct writeback_control _writeback_control;
207 (void)_aops.writepage(&_page, &_writeback_control);],
208                        [AOP_WRITEPAGE_TAKES_WRITEBACK_CONTROL],
209                        [define if aops.writepage takes a struct writeback_control],
210                        [])
211 ])
212
213
214 AC_DEFUN([LINUX_REFRIGERATOR], [
215   AC_CHECK_LINUX_BUILD([whether refrigerator takes PF_FREEZE],
216                        [ac_cv_linux_func_refrigerator_takes_pf_freeze],
217 [#include <linux/sched.h>
218 #ifdef HAVE_LINUX_FREEZER_H
219 #include <linux/freezer.h>
220 #endif],
221                        [refrigerator(PF_FREEZE);],
222                        [LINUX_REFRIGERATOR_TAKES_PF_FREEZE],
223                        [define if your refrigerator takes PF_FREEZE],
224                        [])
225 ])
226
227
228 AC_DEFUN([LINUX_IOP_I_CREATE_TAKES_NAMEIDATA], [
229   AC_CHECK_LINUX_BUILD([whether inode_operations.create takes a nameidata],
230                        [ac_cv_linux_func_i_create_takes_nameidata],
231 [#include <linux/fs.h>
232 #include <linux/namei.h>],
233 [struct inode _inode;
234 struct dentry _dentry;
235 struct nameidata _nameidata;
236 (void)_inode.i_op->create(&_inode, &_dentry, 0, &_nameidata);],
237
238                        [IOP_CREATE_TAKES_NAMEIDATA],
239                        [define if your iops.create takes a nameidata argument],
240                        [])
241 ])
242
243
244 AC_DEFUN([LINUX_IOP_I_LOOKUP_TAKES_NAMEIDATA], [
245   AC_CHECK_LINUX_BUILD([whether inode_operations.lookup takes a nameidata],
246                        [ac_cv_linux_func_i_lookup_takes_nameidata],
247 [#include <linux/fs.h>
248 #include <linux/namei.h>],
249 [struct inode _inode;
250 struct dentry _dentry;
251 struct nameidata _nameidata;
252 (void)_inode.i_op->lookup(&_inode, &_dentry, &_nameidata);],
253                        [IOP_LOOKUP_TAKES_NAMEIDATA],
254                        [define if your iops.lookup takes a nameidata argument],
255                        [])
256 ])
257
258
259 AC_DEFUN([LINUX_IOP_I_PERMISSION_TAKES_NAMEIDATA], [
260   AC_CHECK_LINUX_BUILD([whether inode_operations.permission takes a nameidata],
261                        [ac_cv_linux_func_i_permission_takes_nameidata],
262 [#include <linux/fs.h>
263 #include <linux/namei.h>],
264 [struct inode _inode;
265 struct nameidata _nameidata;
266 (void)_inode.i_op->permission(&_inode, 0, &_nameidata);],
267                        [IOP_PERMISSION_TAKES_NAMEIDATA],
268                        [define if your iops.permission takes a nameidata argument],
269                        [-Werror])
270 ])
271
272
273 AC_DEFUN([LINUX_IOP_I_PERMISSION_TAKES_FLAGS], [
274   AC_CHECK_LINUX_BUILD([whether inode_operations.permission takes flags],
275                         [ac_cv_linux_func_i_permission_takes_flags],
276                         [#include <linux/fs.h>],
277                         [struct inode _inode = {0};
278                         unsigned int flags = 0;
279                         (void)_inode.i_op->permission(&_inode, 0, flags);],
280                        [IOP_PERMISSION_TAKES_FLAGS],
281                        [define if your iops.permission takes a flags argument],
282                        [-Werror])
283 ])
284
285
286 AC_DEFUN([LINUX_IOP_I_PUT_LINK_TAKES_COOKIE], [
287   AC_CHECK_LINUX_BUILD([whether inode_operations.put_link takes an opaque cookie],
288                        [ac_cv_linux_func_i_put_link_takes_cookie],
289 [#include <linux/fs.h>
290 #include <linux/namei.h>],
291 [struct inode _inode;
292 struct dentry _dentry;
293 struct nameidata *_nameidata;
294 void *cookie;
295 (void)_inode.i_op->put_link(&_dentry, _nameidata, cookie);],
296                        [IOP_PUT_LINK_TAKES_COOKIE],
297                        [define if your iops.put_link takes a cookie],
298                        [])
299 ])
300
301
302 AC_DEFUN([LINUX_DOP_D_REVALIDATE_TAKES_NAMEIDATA], [
303   AC_CHECK_LINUX_BUILD([whether dentry_operations.d_revalidate takes a nameidata],
304                        [ac_cv_linux_func_d_revalidate_takes_nameidata],
305                         [#include <linux/fs.h>
306                         #include <linux/namei.h>
307                         static int reval(struct dentry *d, struct nameidata *nd) { return 0; }
308                         struct dentry_operations dops;],
309                         [dops.d_revalidate = reval;],
310                        [DOP_REVALIDATE_TAKES_NAMEIDATA],
311                        [define if your dops.d_revalidate takes a nameidata argument],
312                        [-Werror])
313 ])
314
315
316 AC_DEFUN([LINUX_GET_SB_HAS_STRUCT_VFSMOUNT], [
317   AC_CHECK_LINUX_BUILD([for struct vfsmount * in get_sb_nodev()],
318                        [ac_cv_linux_get_sb_has_struct_vfsmount],
319                        [#include <linux/fs.h>],
320                        [get_sb_nodev(0,0,0,0,0);],
321                        [GET_SB_HAS_STRUCT_VFSMOUNT],
322                        [define if your get_sb_nodev needs a struct vfsmount argument],
323                        [])
324 ])
325
326
327 AC_DEFUN([LINUX_STATFS_TAKES_DENTRY], [
328   AC_CHECK_LINUX_BUILD([for dentry in statfs],
329                        [ac_cv_linux_statfs_takes_dentry],
330 [#include <linux/fs.h>
331 #include <linux/statfs.h>],
332 [extern int simple_statfs(struct dentry *, struct kstatfs *);],
333                        [STATFS_TAKES_DENTRY],
334                        [define if your statfs takes a dentry argument],
335                        [])
336 ])
337
338
339 AC_DEFUN([LINUX_LINUX_KEYRING_SUPPORT], [
340   AC_CHECK_LINUX_BUILD([for linux kernel keyring support],
341                        [ac_cv_linux_keyring_support],
342 [#include <linux/rwsem.h>
343 #ifdef HAVE_LINUX_KEY_TYPE_H
344 #include <linux/key-type.h>
345 #endif
346 #include <linux/key.h>
347 #include <linux/keyctl.h>],
348 [#ifdef CONFIG_KEYS
349 request_key(NULL, NULL, NULL);
350 #if !defined(KEY_POS_VIEW) || !defined(KEY_POS_SEARCH) || !defined(KEY_POS_SETATTR) 
351 #error "Your linux/key.h does not contain KEY_POS_VIEW or KEY_POS_SEARCH or KEY_POS_SETATTR"
352 #endif
353 #else
354 #error rebuild your kernel with CONFIG_KEYS
355 #endif],
356                        [LINUX_KEYRING_SUPPORT],
357                        [define if your kernel has keyring support],
358                        [])
359 ])
360
361
362 AC_DEFUN([LINUX_KEY_ALLOC_NEEDS_STRUCT_TASK], [
363   AC_CHECK_LINUX_BUILD([if key_alloc() takes a struct task *],
364                         [ac_cv_key_alloc_needs_struct_task],
365                         [#include <linux/rwsem.h>
366                         #include <linux/key.h> ],
367                         [struct task_struct *t=NULL;
368                         struct key k = {};
369                         (void) key_alloc(NULL, NULL, k.uid, k.gid, t, 0, 0);],
370                         [KEY_ALLOC_NEEDS_STRUCT_TASK],
371                         [define if key_alloc takes a struct task *],
372                         [-Werror -Wno-pointer-arith])
373 ])
374
375
376 AC_DEFUN([LINUX_KEY_ALLOC_NEEDS_CRED], [
377   AC_CHECK_LINUX_BUILD([if key_alloc() takes credentials],
378                         [ac_cv_key_alloc_needs_cred],
379                         [#include <linux/rwsem.h>
380                         #include <linux/key.h>],
381                         [struct cred *c = NULL;
382                         struct key k = {};
383                         (void) key_alloc(NULL, NULL, k.uid, k.gid, c, 0, 0);],
384                         [KEY_ALLOC_NEEDS_CRED],
385                         [define if key_alloc takes credentials],
386                         [-Werror -Wno-pointer-arith])
387 ])
388
389
390 AC_DEFUN([LINUX_INIT_WORK_HAS_DATA], [
391   AC_CHECK_LINUX_BUILD([whether INIT_WORK has a _data argument],
392                        [ac_cv_linux_init_work_has_data],
393 [#include <linux/kernel.h>
394 #include <linux/workqueue.h>],
395
396 void f(struct work_struct *w) {}
397 struct work_struct *w;
398 int *i;
399 INIT_WORK(w,f,i);],
400                        [INIT_WORK_HAS_DATA],
401                        [define if INIT_WORK takes a data (3rd) argument],
402                        [])
403 ])
404
405
406 AC_DEFUN([LINUX_REGISTER_SYSCTL_TABLE_NOFLAG], [
407   AC_CHECK_LINUX_BUILD([whether register_sysctl_table has an insert_at_head argument],
408                        [ac_cv_linux_register_sysctl_table_noflag],
409                        [#include <linux/sysctl.h>],
410                        [struct ctl_table *t; register_sysctl_table (t);],
411                        [REGISTER_SYSCTL_TABLE_NOFLAG],
412                        [define if register_sysctl_table has no insert_at head flag],
413                        [])
414 ])
415
416
417 AC_DEFUN([LINUX_FOP_F_FLUSH_TAKES_FL_OWNER_T], [
418   AC_CHECK_LINUX_BUILD([whether file_operations.flush takes a fl_owner_t],
419                        [ac_cv_linux_func_f_flush_takes_fl_owner_t],
420                        [#include <linux/fs.h>],
421 [struct inode _inode;
422 struct file _file;
423 fl_owner_t id;
424 (void)_inode.i_fop->flush(&_file, &id);],
425                        [FOP_FLUSH_TAKES_FL_OWNER_T],
426                        [define if your fops.flush takes an fl_owner_t argument],
427                        [])
428 ])
429
430
431 AC_DEFUN([LINUX_FOP_F_FSYNC_TAKES_DENTRY], [
432   AC_CHECK_LINUX_BUILD([whether file_operations.fsync takes a dentry argument],
433                        [ac_cv_linux_func_f_fsync_takes_dentry],
434                        [#include <linux/fs.h>],
435 [struct inode _inode;
436 struct file _file;
437 struct dentry _d;
438 (void)_inode.i_fop->fsync(&_file, &_d, 0);],
439                        [FOP_FSYNC_TAKES_DENTRY],
440                        [define if your fops.fsync takes an dentry argument],
441                        [])
442 ])
443
444
445 int (*fsync) (struct file *, loff_t start, loff_t end, int datasync);
446
447 AC_DEFUN([LINUX_FOP_F_FSYNC_TAKES_RANGE], [
448   AC_CHECK_LINUX_BUILD([whether file_operations.fsync takes a range],
449                        [ac_cv_linux_func_f_fsync_takes_range],
450                        [#include <linux/fs.h>],
451 [struct inode _inode;
452 struct file _file;
453 loff_t start, end;
454 (void)_inode.i_fop->fsync(&_file, start, end, 0);],
455                        [FOP_FSYNC_TAKES_RANGE],
456                        [define if your fops.fsync takes range arguments],
457                        [])
458 ])
459
460
461 AC_DEFUN([LINUX_HAVE_KMEM_CACHE_T], [
462   AC_CHECK_LINUX_BUILD([whether kmem_cache_t exists],
463                        [ac_cv_linux_have_kmem_cache_t],
464                        [#include <linux/slab.h>],
465                        [kmem_cache_t *k;],
466                        [HAVE_KMEM_CACHE_T],
467                        [define if kmem_cache_t exists],
468                        [])
469 ])
470
471
472 AC_DEFUN([LINUX_KMEM_CACHE_CREATE_TAKES_DTOR], [
473   AC_CHECK_LINUX_BUILD([whether kmem_cache_create takes a destructor argument],
474                        [ac_cv_linux_kmem_cache_create_takes_dtor],
475                        [#include <linux/slab.h>],
476                        [kmem_cache_create(NULL, 0, 0, 0, NULL, NULL);],
477                        [KMEM_CACHE_TAKES_DTOR],
478                        [define if kmem_cache_create takes a destructor argument],
479                        [])
480 ])
481
482
483 AC_DEFUN([LINUX_KMEM_CACHE_CREATE_CTOR_TAKES_VOID],[
484   AC_CHECK_LINUX_BUILD([whether kmem_cache_create constructor takes a void pointer],
485                         [ac_cv_linux_kmem_cache_create_ctor_takes_void],
486                         [#include <linux/slab.h>],
487                         [void _ctor(void *v) { }; kmem_cache_create(NULL, 0, 0, 0, _ctor);],
488                         [KMEM_CACHE_CTOR_TAKES_VOID],
489                         [define if kmem_cache_create constructor takes a single void ptr],
490                         [-Werror])
491 ])
492
493
494 dnl This function checks not just the existence of the splice functions,
495 dnl but also that the signature matches (they gained an extra argument
496 dnl around 2.6.17)
497 AC_DEFUN([LINUX_FS_STRUCT_FOP_HAS_SPLICE], [
498   AC_CHECK_LINUX_BUILD([for splice_write and splice_read in struct file_operations],
499                        [ac_cv_linux_fs_struct_fop_has_splice],
500                        [#include <linux/fs.h>],
501                        [struct file_operations _fop;
502                         _fop.splice_write(NULL, NULL, NULL, 0, 0);
503                         _fop.splice_read(NULL, NULL, NULL, 0, 0);],
504                        [STRUCT_FILE_OPERATIONS_HAS_SPLICE],
505                        [define if struct file_operations has splice functions],
506                        [])
507 ])
508
509
510 AC_DEFUN([LINUX_KMEM_CACHE_INIT], [
511   AC_CHECK_LINUX_BUILD([for new kmem_cache init function parameters],
512                        [ac_cv_linux_kmem_cache_init],
513                        [#include <linux/slab.h>],
514                        [extern struct kmem_cache *
515                         kmem_cache_create(const char *, size_t, size_t,
516                                           unsigned long,
517                                           void (*)(struct kmem_cache *, void *));
518                         return;],
519                        [KMEM_CACHE_INIT],
520                        [define for new kmem_cache init function parameters],
521                        [])
522 ])
523
524
525 AC_DEFUN([LINUX_EXPORTS_PROC_ROOT_FS], [
526   AC_CHECK_LINUX_BUILD([if proc_root_fs is defined and exported],
527                        [ac_cv_linux_exports_proc_root_fs],
528                        [#include <linux/proc_fs.h>],
529                        [struct proc_dir_entry *p = proc_root_fs;],
530                        [EXPORTED_PROC_ROOT_FS],
531                        [define if proc_root_fs is exported],
532                        [])
533 ])
534
535
536 AC_DEFUN([LINUX_D_PATH_TAKES_STRUCT_PATH], [
537   AC_CHECK_LINUX_BUILD([if d_path() takes a struct path argument],
538                        [ac_cv_linux_d_path_takes_struct_path],
539                        [#include <linux/fs.h>],
540                        [struct path *p; d_path(p, NULL, 0);],
541                        [D_PATH_TAKES_STRUCT_PATH],
542                        [define if d_path() takes a struct path argument],
543                        [])
544 ])
545
546
547 AC_DEFUN([LINUX_NEW_EXPORT_OPS], [
548   AC_CHECK_LINUX_BUILD([if kernel uses new export ops],
549                        [ac_cv_linux_new_export_ops],
550                        [#include <linux/exportfs.h>],
551                        [struct export_operations _eops;
552                         _eops.fh_to_parent(NULL, NULL, 0, 0);],
553                        [NEW_EXPORT_OPS],
554                        [define if kernel uses new export ops],
555                        [])
556 ])
557
558
559 AC_DEFUN([LINUX_POSIX_TEST_LOCK_RETURNS_CONFLICT], [
560   AC_CHECK_LINUX_BUILD([if posix_test_lock returns a struct file_lock],
561                        [ac_cv_linux_posix_test_lock_returns_conflict],
562                        [#include <linux/fs.h>],
563                        [struct file_lock *lock;
564                         struct file * file;
565                         lock = posix_test_lock(file, lock);],
566                        [POSIX_TEST_LOCK_RETURNS_CONFLICT],
567                        [define if posix_test_lock returns the conflicting lock],
568                        [])
569 ])
570
571
572 AC_DEFUN([LINUX_POSIX_TEST_LOCK_CONFLICT_ARG], [
573   AC_CHECK_LINUX_BUILD([if posix_test_lock takes a conflict argument],
574                        [ac_cv_linux_posix_test_lock_conflict_arg],
575                        [#include <linux/fs.h>],
576                        [struct file_lock *lock;
577                         struct file *file;
578                         posix_test_lock(file, lock, lock);],
579                        [POSIX_TEST_LOCK_CONFLICT_ARG],
580                        [define if posix_test_lock takes a conflict argument],
581                        [])
582 ])
583
584
585 AC_DEFUN([LINUX_EXPORTS_KEY_TYPE_KEYRING], [
586   AC_CHECK_LINUX_BUILD([for exported key_type_keyring],
587                        [ac_cv_linux_exports_key_type_keyring],
588 [
589 #ifdef HAVE_LINUX_KEY_TYPE_H
590 #include <linux/key-type.h>
591 #endif
592 #include <linux/key.h>
593 ],
594                        [printk("%s", key_type_keyring.name);],
595                        [EXPORTED_KEY_TYPE_KEYRING],
596                        [define if key_type_keyring is exported],
597                        [])
598 ])
599
600
601 AC_DEFUN([LINUX_HAVE_TRY_TO_FREEZE], [
602   AC_CHECK_LINUX_BUILD([for try_to_freeze],
603                        [ac_cv_linux_have_try_to_freeze],
604 [#include <linux/sched.h>
605 #ifdef HAVE_LINUX_FREEZER_H
606 #include <linux/freezer.h>
607 #endif],
608 [#ifdef LINUX_REFRIGERATOR_TAKES_PF_FREEZE
609    try_to_freeze(PF_FREEZE);
610 #else
611    try_to_freeze();
612 #endif],
613                        [HAVE_TRY_TO_FREEZE],
614                        [define if your kernel has the try_to_freeze function],
615                        [])
616 ])
617
618
619 AC_DEFUN([LINUX_HAVE_DCACHE_LOCK], [
620   AC_CHECK_LINUX_BUILD([for dcache_lock],
621                         [ac_cv_linux_have_dcache_lock],
622                         [#include <linux/fs.h> ],
623                         [printk("%p", &dcache_lock);],
624                         [HAVE_DCACHE_LOCK],
625                         [define if dcache_lock exists],
626                         [])
627 ])
628
629
630 AC_DEFUN([LINUX_D_COUNT_IS_INT], [
631   AC_CHECK_LINUX_BUILD([if dentry->d_count is an int],
632                         [ac_cv_linux_d_count_int],
633                         [#include <linux/fs.h> ],
634                         [struct dentry _d;
635                         dget(&_d);
636                         _d.d_count = 1;],
637                         [D_COUNT_INT],
638                         [define if dentry->d_count is an int],
639                         [-Werror])
640 ])
641
642
643 AC_DEFUN([LINUX_DOP_D_DELETE_TAKES_CONST], [
644   AC_CHECK_LINUX_BUILD([whether dentry.d_op->d_delete takes a const argument],
645                         [ac_cv_linux_dop_d_delete_takes_const],
646                         [#include <linux/fs.h>
647                         #include <linux/dcache.h>
648                         static int _d_del(const struct dentry *de) { return 0; }
649                         struct dentry_operations _d_ops;],
650                         [_d_ops.d_delete = _d_del;],
651                         [DOP_D_DELETE_TAKES_CONST],
652                         [define if dentry.d_op->d_delete takes a const argument],
653                         [-Werror])
654 ])
655
656 AC_DEFUN([LINUX_IOP_GETATTR_TAKES_PATH_STRUCT], [
657   AC_CHECK_LINUX_BUILD([whether 4.11+ inode.i_op->getattr takes a struct path argument],
658                         [ac_cv_linux_iop_getattr_takes_path_struct],
659                         [#include <linux/fs.h>
660                         int _getattr(const struct path *path, struct kstat *stat, u32 request_mask,
661                           unsigned int sync_mode) {return 0;};
662                         struct inode_operations _i_ops;],
663                         [_i_ops.getattr = _getattr;],
664                         [IOP_GETATTR_TAKES_PATH_STRUCT],
665                         [define if 4.11+ inode.i_op->getattr takes a struct path argument],
666                         [-Werror])
667 ])
668
669 AC_DEFUN([LINUX_IOP_MKDIR_TAKES_UMODE_T], [
670   AC_CHECK_LINUX_BUILD([whether inode.i_op->mkdir takes a umode_t argument],
671                         [ac_cv_linux_iop_mkdir_takes_umode_t],
672                         [#include <linux/fs.h>
673                         static int _mkdir(struct inode *i, struct dentry *d, umode_t m) { return 0; }
674                         struct inode_operations _i_ops;],
675                         [_i_ops.mkdir = _mkdir;],
676                         [IOP_MKDIR_TAKES_UMODE_T],
677                         [define if inode.i_op->mkdir takes a umode_t argument],
678                         [-Werror])
679 ])
680
681
682 AC_DEFUN([LINUX_IOP_CREATE_TAKES_UMODE_T], [
683   AC_CHECK_LINUX_BUILD([whether inode.i_op->create takes a umode_t argument],
684                         [ac_cv_linux_iop_create_takes_umode_t],
685                         [#include <linux/fs.h>],
686                         [struct inode_operations _i_ops;
687                         int _create(struct inode *i, struct dentry *d, umode_t m, struct nameidata *n)
688                                 {return 0;};
689                         _i_ops.create = _create;],
690                         [IOP_CREATE_TAKES_UMODE_T],
691                         [define if inode.i_op->create takes a umode_t argument],
692                         [-Werror])
693 ])
694
695
696 AC_DEFUN([LINUX_EXPORT_OP_ENCODE_FH_TAKES_INODES], [
697   AC_CHECK_LINUX_BUILD([whether export operation encode_fh takes inode arguments],
698                         [ac_cv_linux_export_op_encode_fh__takes_inodes],
699                         [#include <linux/exportfs.h>
700                         static int _encode_fh(struct inode *i, __u32 *fh, int *len, struct inode *p) { return 0; }
701                         struct export_operations _exp_ops;],
702                         [_exp_ops.encode_fh = _encode_fh;],
703                         [EXPORT_OP_ENCODE_FH_TAKES_INODES],
704                         [define if encode_fh export op takes inode arguments],
705                         [-Werror])
706 ])
707
708
709 AC_DEFUN([LINUX_KMAP_ATOMIC_TAKES_NO_KM_TYPE], [
710   AC_CHECK_LINUX_BUILD([whether kmap_atomic takes no km_type argument],
711                         [ac_cv_linux_kma_atomic_takes_no_km_type],
712                         [#include <linux/highmem.h>],
713                         [struct page *p = NULL;
714                         kmap_atomic(p);],
715                         [KMAP_ATOMIC_TAKES_NO_KM_TYPE],
716                         [define if kmap_atomic takes no km_type argument],
717                         [-Werror])
718 ])
719
720
721 AC_DEFUN([LINUX_DENTRY_OPEN_TAKES_PATH], [
722   AC_CHECK_LINUX_BUILD([whether dentry_open takes a path argument],
723                         [ac_cv_linux_dentry_open_takes_path],
724                         [#include <linux/fs.h>],
725                         [struct path p;
726                         dentry_open(&p, 0, NULL);],
727                         [DENTRY_OPEN_TAKES_PATH],
728                         [define if dentry_open takes a path argument],
729                         [-Werror])
730 ])
731
732
733 AC_DEFUN([LINUX_D_ALIAS_IS_HLIST], [
734   AC_CHECK_LINUX_BUILD([whether dentry->d_alias is an hlist],
735                         [ac_cv_linux_d_alias_is_hlist],
736                         [#include <linux/fs.h>],
737                         [struct dentry *d = NULL;
738                         struct hlist_node *hn = NULL;
739                         #if defined(STRUCT_DENTRY_HAS_D_U_D_ALIAS)
740                         d->d_u.d_alias = *hn;
741                         #else
742                         d->d_alias = *hn;
743                         #endif],
744                         [D_ALIAS_IS_HLIST],
745                         [define if dentry->d_alias is an hlist],
746                         [])
747 ])
748
749
750 AC_DEFUN([LINUX_HLIST_ITERATOR_NO_NODE], [
751   AC_CHECK_LINUX_BUILD([whether hlist iterators don't need a node parameter],
752                         [ac_cv_linux_hlist_takes_no_node],
753                         [#include <linux/list.h>
754                         #include <linux/fs.h>],
755                         [struct dentry *d = NULL, *cur;
756                         struct inode *ip;
757                         #if defined(STRUCT_DENTRY_HAS_D_U_D_ALIAS)
758                         # define d_alias d_u.d_alias
759                         #endif
760                         hlist_for_each_entry(cur, &ip->i_dentry, d_alias) { }
761                         ],
762                         [HLIST_ITERATOR_NO_NODE],
763                         [define if hlist iterators don't need a node parameter],
764                         [])
765 ])
766
767
768 AC_DEFUN([LINUX_IOP_I_CREATE_TAKES_BOOL], [
769   AC_CHECK_LINUX_BUILD([whether inode_operations.create takes a bool],
770                         [ac_cv_linux_func_i_create_takes_bool],
771                         [#include <linux/fs.h>
772                         #include <linux/namei.h>],
773                         [struct inode _inode = {};
774                         struct dentry _dentry;
775                         bool b = true;
776                         (void)_inode.i_op->create(&_inode, &_dentry, 0, b);],
777                        [IOP_CREATE_TAKES_BOOL],
778                        [define if your iops.create takes a bool argument],
779                        [-Werror])
780 ])
781
782
783 AC_DEFUN([LINUX_DOP_D_REVALIDATE_TAKES_UNSIGNED], [
784   AC_CHECK_LINUX_BUILD([whether dentry_operations.d_revalidate takes an unsigned int],
785                         [ac_cv_linux_func_d_revalidate_takes_unsigned],
786                         [#include <linux/fs.h>
787                         #include <linux/namei.h>
788                         static int reval(struct dentry *d, unsigned int i) { return 0; }
789                         struct dentry_operations _d_ops;],
790                         [_d_ops.d_revalidate = reval;],
791                        [DOP_REVALIDATE_TAKES_UNSIGNED],
792                        [define if your dops.d_revalidate takes an unsigned int argument],
793                        [-Werror])
794 ])
795
796
797 AC_DEFUN([LINUX_IOP_LOOKUP_TAKES_UNSIGNED], [
798   AC_CHECK_LINUX_BUILD([whether inode operation lookup takes an unsigned int],
799                         [ac_cv_linux_func_lookup_takes_unsigned],
800                         [#include <linux/fs.h>
801                         #include <linux/namei.h>
802                         static struct dentry *look(struct inode *i, struct dentry *d, unsigned int j) { return NULL; }
803                         struct inode_operations _i_ops;],
804                         [_i_ops.lookup = look;],
805                        [IOP_LOOKUP_TAKES_UNSIGNED],
806                        [define if your iops.lookup takes an unsigned int argument],
807                        [-Werror])
808 ])
809
810
811 AC_DEFUN([LINUX_D_INVALIDATE_IS_VOID], [
812   AC_CHECK_LINUX_BUILD([whether d_invalidate returns void],
813                         [ac_cv_linux_func_d_invalidate_returns_void],
814                         [#include <linux/fs.h>],
815                         [
816                         void d_invalidate(struct dentry *);
817                         ],
818                        [D_INVALIDATE_IS_VOID],
819                        [define if your d_invalidate returns void],
820                        [])
821 ])
822
823 AC_DEFUN([LINUX_KERNEL_READ_OFFSET_IS_LAST], [
824   AC_CHECK_LINUX_BUILD([whether offset is the last argument to kernel_read],
825                        [ac_cv_linux_func_kernel_read_offset_is_last],
826                        [#include <linux/fs.h>],
827                        [
828                        ssize_t kernel_read(struct file *, void *, size_t, loff_t *);
829                        ],
830                        [KERNEL_READ_OFFSET_IS_LAST],
831                        [define if your kernel_read has offset as the last argument],
832                        [])
833 ])