From: pravin Date: Thu, 24 Jun 2010 21:13:16 +0000 (+0530) Subject: b=20563 libcfs_cfs_curproc_is_32bit() function X-Git-Tag: v1_8_3_55~2 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=1575cefbabe3dd143c1accc0869a7830e51062a3;p=fs%2Flustre-release.git b=20563 libcfs_cfs_curproc_is_32bit() function i=johann i=rahul adds function cfs_curproc_is_32bit() to check compatibility. --- diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index 855baf3..4b138d6 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -1535,6 +1535,26 @@ LB_LINUX_TRY_COMPILE([ ]) # +# LN_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([LN_HAVE_IS_COMPAT_TASK], +[AC_MSG_CHECKING([if is_compat_task() is declared]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + 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]) +]) +]) + +# # LN_PROG_LINUX # # LNet linux kernel checks @@ -1568,6 +1588,7 @@ LN_LE_TYPES LN_TASK_RCU # 2.6.18 LN_TASKLIST_LOCK +LN_HAVE_IS_COMPAT_TASK # 2.6.19 LN_KMEM_CACHE_DESTROY_INT LN_ATOMIC_PANIC_NOTIFIER diff --git a/lnet/include/libcfs/curproc.h b/lnet/include/libcfs/curproc.h index 38492a9..e7aa3a8 100644 --- a/lnet/include/libcfs/curproc.h +++ b/lnet/include/libcfs/curproc.h @@ -76,6 +76,9 @@ char *cfs_curproc_comm(void); typedef __u32 cfs_cap_t; +/* check if task is running in compat mode.*/ +int cfs_curproc_is_32bit(void); + #define CFS_CAP_CHOWN 0 #define CFS_CAP_DAC_OVERRIDE 1 #define CFS_CAP_DAC_READ_SEARCH 2 diff --git a/lnet/libcfs/linux/linux-curproc.c b/lnet/libcfs/linux/linux-curproc.c index 7282b86..5f1201c 100644 --- a/lnet/libcfs/linux/linux-curproc.c +++ b/lnet/libcfs/linux/linux-curproc.c @@ -42,6 +42,8 @@ #include #include +#include +#include #define DEBUG_SUBSYSTEM S_LNET @@ -207,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); @@ -227,6 +245,7 @@ EXPORT_SYMBOL(cfs_kernel_cap_unpack); EXPORT_SYMBOL(cfs_curproc_cap_pack); EXPORT_SYMBOL(cfs_curproc_cap_unpack); EXPORT_SYMBOL(cfs_capable); +EXPORT_SYMBOL(cfs_curproc_is_32bit); /* * Local variables: