Handle possible null pointers from malloc/strdup/strndup()
[zfs.git] / config / kernel-rename.m4
blob302db43f57488ccc0fea41d3e394cc592062e8f4
1 AC_DEFUN([ZFS_AC_KERNEL_SRC_RENAME], [
2         dnl #
3         dnl # 4.9 API change,
4         dnl # iops->rename2() merged into iops->rename(), and iops->rename() now wants
5         dnl # flags.
6         dnl #
7         ZFS_LINUX_TEST_SRC([inode_operations_rename_flags], [
8                 #include <linux/fs.h>
9                 int rename_fn(struct inode *sip, struct dentry *sdp,
10                         struct inode *tip, struct dentry *tdp,
11                         unsigned int flags) { return 0; }
13                 static const struct inode_operations
14                     iops __attribute__ ((unused)) = {
15                         .rename = rename_fn,
16                 };
17         ],[])
19         dnl #
20         dnl # 5.12 API change,
21         dnl #
22         dnl # Linux 5.12 introduced passing struct user_namespace* as the first argument
23         dnl # of the rename() and other inode_operations members.
24         dnl #
25         ZFS_LINUX_TEST_SRC([inode_operations_rename_userns], [
26                 #include <linux/fs.h>
27                 int rename_fn(struct user_namespace *user_ns, struct inode *sip,
28                         struct dentry *sdp, struct inode *tip, struct dentry *tdp,
29                         unsigned int flags) { return 0; }
31                 static const struct inode_operations
32                     iops __attribute__ ((unused)) = {
33                         .rename = rename_fn,
34                 };
35         ],[])
38 AC_DEFUN([ZFS_AC_KERNEL_RENAME], [
39         AC_MSG_CHECKING([whether iops->rename() takes struct user_namespace*])
40         ZFS_LINUX_TEST_RESULT([inode_operations_rename_userns], [
41                 AC_MSG_RESULT(yes)
42                 AC_DEFINE(HAVE_IOPS_RENAME_USERNS, 1,
43                     [iops->rename() takes struct user_namespace*])
44         ],[
45                 AC_MSG_RESULT(no)
47                 AC_MSG_CHECKING([whether iop->rename() wants flags])
48                 ZFS_LINUX_TEST_RESULT([inode_operations_rename_flags], [
49                         AC_MSG_RESULT(yes)
50                         AC_DEFINE(HAVE_RENAME_WANTS_FLAGS, 1,
51                                 [iops->rename() wants flags])
52                 ],[
53                         AC_MSG_RESULT(no)
54                 ])
55         ])