Whamcloud - gitweb
LU-6266 libcfs: add kstrtoul() compat function
[fs/lustre-release.git] / libcfs / include / libcfs / linux / libcfs.h
index 162f86b..51991cb 100644 (file)
@@ -61,6 +61,7 @@
 #include <linux/sched.h> /* THREAD_SIZE */
 #include <linux/rbtree.h>
 #include <linux/bitops.h>
+#include <linux/capability.h>
 
 #if !defined(__x86_64__)
 # ifdef  __ia64__
@@ -106,7 +107,17 @@ int lprocfs_call_handler(void *data, int write, loff_t *ppos,
                         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.