The kstrtoul() function was only added to the upstream kernel in
commit v2.6.38-6934-g33ee3b2. While it is backported to RHEL6 2.6.32
kernels, it does not exist for vanilla kernels before that point.
The patch http://review.whamcloud.com/5700 added uses of kstrtoul()
to Lustre that break the build for older kernels. While it would be
possible to convert those calls to simple_strtoul(), that function
is deprecated in newer kernels, and checkpatch.pl will generate a
warning, so using kstrtoul() is the right thing for newer kernels.
Add a wrapper function for kstrtoul() for older kernels. There are
other kstrto*() functions in newer kernel not added by this patch.
Only the one function call is currently used, though it would be good
to convert Lustre over to using this family of functions instead of
simple_strtoul() in the future.
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Id30313e51b8d240aacc09a6e86a22460fa2540e5
Reviewed-on: http://review.whamcloud.com/13820
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
]) # LC_SK_SLEEP
#
+# LIBCFS_KSTRTOUL
+#
+# 2.6.38 kstrtoul is added
+#
+AC_DEFUN([LIBCFS_KSTRTOUL], [
+LB_CHECK_COMPILE([if Linux kernel has 'kstrtoul'],
+kstrtoul, [
+ #include <linux/kernel.h>
+],[
+ unsigned long result;
+ return kstrtoul("12345", 0, &result);
+],[
+ AC_DEFINE(HAVE_KSTRTOUL, 1,
+ [kernel has kstrtoul])
+])
+]) # LIBCFS_KSTRTOUL
+
+#
# LIBCFS_DUMP_TRACE_ADDRESS
#
# 2.6.39 adds a base pointer address argument to dump_trace
LIBCFS_SYSCTL_CTLNAME
# 2.6.35
LC_SK_SLEEP
+# 2.6.38
+LIBCFS_KSTRTOUL
# 2.6.39
LIBCFS_DUMP_TRACE_ADDRESS
# 2.6.40 fc15
#include <linux/sched.h> /* THREAD_SIZE */
#include <linux/rbtree.h>
#include <linux/bitops.h>
+#include <linux/capability.h>
#if !defined(__x86_64__)
# ifdef __ia64__
int (*handler)(void *data, int write,
loff_t pos, void __user *buffer, int len));
-#include <linux/capability.h>
+#ifndef HAVE_KSTRTOUL
+static inline int kstrtoul(const char *s, unsigned int base, unsigned long *res)
+{
+ char *end = (char *)s;
+
+ *res = simple_strtoul(s, &end, base);
+ if (end - s == 0)
+ return -EINVAL;
+ return 0;
+}
+#endif /* !HAVE_KSTRTOUL */
/*
* No stack-back-tracing in Linux for now.