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