Whamcloud - gitweb
b=20563 add cfs_curproc_is_32bit() function to check binary compatibility.
authorpravin <Pravin.Shelar@sun.com>
Thu, 10 Jun 2010 03:50:50 +0000 (09:20 +0530)
committerRobert Read <robert.read@oracle.com>
Thu, 10 Jun 2010 04:29:56 +0000 (21:29 -0700)
i=rahul
i=andreas

libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/curproc.h
libcfs/libcfs/linux/linux-curproc.c

index 49c5a21..d764b23 100644 (file)
@@ -675,6 +675,26 @@ EXTRA_KCFLAGS="$tmp_flags"
 ])
 
 #
+# LIBCFS_HAVE_IS_COMPAT_TASK
+#
+# Added in 2.6.17, it wasn't until 2.6.29 that all
+# Linux architectures have is_compat_task()
+#
+AC_DEFUN([LIBCFS_HAVE_IS_COMPAT_TASK],
+[AC_MSG_CHECKING([if is_compat_task() is declared])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/compat.h>
+],[
+        int i = is_compat_task();
+],[
+        AC_MSG_RESULT([yes])
+        AC_DEFINE(HAVE_IS_COMPAT_TASK, 1, [is_compat_task() is available])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#
 # LIBCFS_PROG_LINUX
 #
 # LNet linux kernel checks
@@ -693,6 +713,7 @@ LIBCFS_U64_LONG_LONG
 LIBCFS_TASK_RCU
 # 2.6.18
 LIBCFS_TASKLIST_LOCK
+LIBCFS_HAVE_IS_COMPAT_TASK
 # 2.6.19
 LIBCFS_NETLINK
 LIBCFS_NLMSG_MULTICAST
index 332799b..7d75c6f 100644 (file)
@@ -72,6 +72,9 @@ char  *cfs_curproc_comm(void);
  *
  * cfs_kernel_cap_t
  */
+
+/* check if task is running in compat mode.*/
+int cfs_curproc_is_32bit(void);
 #endif
 
 typedef __u32 cfs_cap_t;
index 9223366..4bfcca3 100644 (file)
@@ -43,6 +43,9 @@
 #include <linux/sched.h>
 #include <linux/fs_struct.h>
 
+#include <linux/compat.h>
+#include <linux/thread_info.h>
+
 #define DEBUG_SUBSYSTEM S_LNET
 
 #include <libcfs/libcfs.h>
@@ -206,6 +209,22 @@ int cfs_capable(cfs_cap_t cap)
         return capable(cfs_cap_unpack(cap));
 }
 
+/* Check if task is running in 32-bit API mode, for the purpose of
+ * userspace binary interfaces.  On 32-bit Linux this is (unfortunately)
+ * always true, even if the application is using LARGEFILE64 and 64-bit
+ * APIs, because Linux provides no way for the filesystem to know if it
+ * is called via 32-bit or 64-bit APIs.  Other clients may vary.  On
+ * 64-bit systems, this will only be true if the binary is calling a
+ * 32-bit system call. */
+int cfs_curproc_is_32bit(void)
+{
+#ifdef HAVE_IS_COMPAT_TASK
+        return is_compat_task();
+#else
+        return (BITS_PER_LONG == 32);
+#endif
+}
+
 EXPORT_SYMBOL(cfs_curproc_uid);
 EXPORT_SYMBOL(cfs_curproc_pid);
 EXPORT_SYMBOL(cfs_curproc_euid);
@@ -224,6 +243,7 @@ EXPORT_SYMBOL(cfs_cap_raised);
 EXPORT_SYMBOL(cfs_curproc_cap_pack);
 EXPORT_SYMBOL(cfs_curproc_cap_unpack);
 EXPORT_SYMBOL(cfs_capable);
+EXPORT_SYMBOL(cfs_curproc_is_32bit);
 
 /*
  * Local variables: