+AC_DEFUN([LC_STRUCT_STATFS],
+[AC_MSG_CHECKING([if struct statfs has a f_namelen field])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/vfs.h>
+],[
+ struct statfs sfs;
+ sfs.f_namelen = 1;
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_STATFS_NAMELEN, 1, [struct statfs has a namelen field])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
+# LC_READLINK_SSIZE_T
+#
+AC_DEFUN([LC_READLINK_SSIZE_T],
+[AC_MSG_CHECKING([if readlink returns ssize_t])
+AC_TRY_COMPILE([
+ #include <unistd.h>
+],[
+ ssize_t readlink(const char *, char *, size_t);
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+AC_DEFUN([LC_FUNC_PAGE_MAPPED],
+[AC_MSG_CHECKING([if kernel offers page_mapped])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/mm.h>
+],[
+ page_mapped(NULL);
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_PAGE_MAPPED, 1, [page_mapped found])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+AC_DEFUN([LC_STRUCT_FILE_OPS_UNLOCKED_IOCTL],
+[AC_MSG_CHECKING([if struct file_operations has an unlocked_ioctl field])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+],[
+ struct file_operations fops;
+ &fops.unlocked_ioctl;
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_UNLOCKED_IOCTL, 1, [struct file_operations has an unlock ed_ioctl field])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+AC_DEFUN([LC_FILEMAP_POPULATE],
+[AC_MSG_CHECKING([for exported filemap_populate])
+LB_LINUX_TRY_COMPILE([
+ #include <asm/page.h>
+ #include <linux/mm.h>
+],[
+ filemap_populate(NULL, 0, 0, __pgprot(0), 0, 0);
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_FILEMAP_POPULATE, 1, [Kernel exports filemap_populate])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+AC_DEFUN([LC_D_ADD_UNIQUE],
+[AC_MSG_CHECKING([for d_add_unique])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/dcache.h>
+],[
+ d_add_unique(NULL, NULL);
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_D_ADD_UNIQUE, 1, [Kernel has d_add_unique])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+AC_DEFUN([LC_BIT_SPINLOCK_H],
+[LB_CHECK_FILE([$LINUX/include/linux/bit_spinlock.h],[
+ AC_MSG_CHECKING([if bit_spinlock.h can be compiled])
+ LB_LINUX_TRY_COMPILE([
+ #include <asm/processor.h>
+ #include <linux/spinlock.h>
+ #include <linux/bit_spinlock.h>
+ ],[],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_BIT_SPINLOCK_H, 1, [Kernel has bit_spinlock.h])
+ ],[
+ AC_MSG_RESULT([no])
+ ])
+],
+[])
+])
+
+#
+# LC_POSIX_ACL_XATTR
+#
+# If we have xattr_acl.h
+#
+AC_DEFUN([LC_XATTR_ACL],
+[LB_CHECK_FILE([$LINUX/include/linux/xattr_acl.h],[
+ AC_MSG_CHECKING([if xattr_acl.h can be compiled])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/xattr_acl.h>
+ ],[],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_XATTR_ACL, 1, [Kernel has xattr_acl])
+ ],[
+ AC_MSG_RESULT([no])
+ ])
+],
+[])
+])
+
+AC_DEFUN([LC_STRUCT_INTENT_FILE],
+[AC_MSG_CHECKING([if struct open_intent has a file field])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+ #include <linux/namei.h>
+],[
+ struct open_intent intent;
+ &intent.file;
+],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_FILE_IN_STRUCT_INTENT, 1, [struct open_intent has a file field])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+
+AC_DEFUN([LC_POSIX_ACL_XATTR_H],
+[LB_CHECK_FILE([$LINUX/include/linux/posix_acl_xattr.h],[
+ AC_MSG_CHECKING([if linux/posix_acl_xattr.h can be compiled])
+ LB_LINUX_TRY_COMPILE([
+ #include <linux/posix_acl_xattr.h>
+ ],[],[
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_LINUX_POSIX_ACL_XATTR_H, 1, [linux/posix_acl_xattr.h found])
+
+ ],[
+ AC_MSG_RESULT([no])
+ ])
+$1
+],[
+AC_MSG_RESULT([no])
+])
+])
+
+AC_DEFUN([LC_LUSTRE_VERSION_H],
+[LB_CHECK_FILE([$LINUX/include/linux/lustre_version.h],[
+ rm -f "$LUSTRE/include/linux/lustre_version.h"
+],[
+ touch "$LUSTRE/include/linux/lustre_version.h"
+ if test x$enable_server = xyes ; then
+ AC_MSG_WARN([Unpatched kernel detected.])
+ AC_MSG_WARN([Lustre servers cannot be built with an unpatched kernel;])
+ AC_MSG_WARN([disabling server build])
+ enable_server='no'
+ fi
+])
+])
+
+AC_DEFUN([LC_FUNC_SET_FS_PWD],
+[AC_MSG_CHECKING([if kernel exports show_task])
+have_show_task=0
+ if grep -q "EXPORT_SYMBOL(show_task)" \
+ "$LINUX/fs/namespace.c" 2>/dev/null ; then
+ AC_DEFINE(HAVE_SET_FS_PWD, 1, [set_fs_pwd is exported])
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+])
+
+
+#
+# LC_FUNC_MS_FLOCK_LOCK
+#
+# SLES9 kernel has MS_FLOCK_LOCK sb flag
+#
+AC_DEFUN([LC_FUNC_MS_FLOCK_LOCK],
+[AC_MSG_CHECKING([if kernel has MS_FLOCK_LOCK sb flag])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+],[
+ int flags = MS_FLOCK_LOCK;
+],[
+ AC_DEFINE(HAVE_MS_FLOCK_LOCK, 1,
+ [kernel has MS_FLOCK_LOCK flag])
+ AC_MSG_RESULT([yes])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
+# LC_FUNC_HAVE_CAN_SLEEP_ARG
+#
+# SLES9 kernel has third arg can_sleep
+# in fs/locks.c: flock_lock_file_wait()
+#
+AC_DEFUN([LC_FUNC_HAVE_CAN_SLEEP_ARG],
+[AC_MSG_CHECKING([if kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+],[
+ int cansleep;
+ struct file *file;
+ struct file_lock *file_lock;
+ flock_lock_file_wait(file, file_lock, cansleep);
+],[
+ AC_DEFINE(HAVE_CAN_SLEEP_ARG, 1,
+ [kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
+ AC_MSG_RESULT([yes])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
+# LC_FUNC_F_OP_FLOCK
+#
+# rhel4.2 kernel has f_op->flock field
+#
+AC_DEFUN([LC_FUNC_F_OP_FLOCK],
+[AC_MSG_CHECKING([if struct file_operations has flock field])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+],[
+ struct file_operations ll_file_operations_flock;
+ ll_file_operations_flock.flock = NULL;
+],[
+ AC_DEFINE(HAVE_F_OP_FLOCK, 1,
+ [struct file_operations has flock field])
+ AC_MSG_RESULT([yes])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
+# LC_FUNC_MS_FLOCK_LOCK
+#
+# SLES9 kernel has MS_FLOCK_LOCK sb flag
+#
+AC_DEFUN([LC_FUNC_MS_FLOCK_LOCK],
+[AC_MSG_CHECKING([if kernel has MS_FLOCK_LOCK sb flag])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+],[
+ int flags = MS_FLOCK_LOCK;
+],[
+ AC_DEFINE(HAVE_MS_FLOCK_LOCK, 1,
+ [kernel has MS_FLOCK_LOCK flag])
+ AC_MSG_RESULT([yes])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
+# LC_FUNC_HAVE_CAN_SLEEP_ARG
+#
+# SLES9 kernel has third arg can_sleep
+# in fs/locks.c: flock_lock_file_wait()
+#
+AC_DEFUN([LC_FUNC_HAVE_CAN_SLEEP_ARG],
+[AC_MSG_CHECKING([if kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+],[
+ int cansleep;
+ struct file *file;
+ struct file_lock *file_lock;
+ flock_lock_file_wait(file, file_lock, cansleep);
+],[
+ AC_DEFINE(HAVE_CAN_SLEEP_ARG, 1,
+ [kernel has third arg can_sleep in fs/locks.c: flock_lock_file_wait()])
+ AC_MSG_RESULT([yes])
+],[
+ AC_MSG_RESULT([no])
+])