Whamcloud - gitweb
LU-16520 build: Move strscpy to libcfs common header 63/49863/3
authorShaun Tancheff <shaun.tancheff@hpe.com>
Fri, 3 Feb 2023 08:17:16 +0000 (02:17 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 14 Feb 2023 06:05:45 +0000 (06:05 +0000)
Ensure strscpy is available to lustre

Test-Parameters: trivial
Fixes: 0b406c91d17 ("LU-13642 lnet: modify lnet_inetdev to work with large NIDS")
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I0c3673c2aa7e6b61671521a8cabde8a364f7f6f8
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49863
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: jsimmons <jsimmons@infradead.org>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/linux/linux-misc.h
lnet/autoconf/lustre-lnet.m4
lnet/lnet/config.c

index 0757b4e..eb6dac2 100644 (file)
@@ -598,6 +598,29 @@ AC_DEFUN([LIBCFS_KERNEL_PARAM_LOCK],[
 ]) # LIBCFS_KERNEL_PARAM_LOCK
 
 #
+# LIBCFS_STRSCPY_EXISTS
+#
+# Linux commit v4.2-rc1-2-g30035e45753b
+#  string: provide strscpy()
+#
+# If strscpy exists, prefer it over strlcpy
+#
+AC_DEFUN([LIBCFS_SRC_STRSCPY_EXISTS], [
+       LB2_LINUX_TEST_SRC([strscpy_exists], [
+               #include <linux/string.h>
+       ],[
+               strscpy((char *)NULL, (const char *)NULL, 0);
+       ],[-Werror])
+])
+AC_DEFUN([LIBCFS_STRSCPY_EXISTS], [
+       AC_MSG_CHECKING([if kernel strscpy is available])
+       LB2_LINUX_TEST_RESULT([strscpy_exists], [
+               AC_DEFINE(HAVE_STRSCPY, 1,
+                       [kernel strscpy is available])
+       ])
+]) # LIBCFS_STRSCPY_EXISTS
+
+#
 # Kernel version 4.2 changed topology_thread_cpumask
 # to topology_sibling_cpumask
 #
@@ -2281,9 +2304,10 @@ AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [
        LIBCFS_SRC_WAIT_WOKEN
        # 4.0
        LIBCFS_SRC_KTIME_MS_DELTA
-       # 4.2
+       # 4.1
        LIBCFS_SRC_KERNEL_PARAM_LOCK
        # 4.2
+       LIBCFS_SRC_STRSCPY_EXISTS
        LIBCFS_SRC_HAVE_TOPOLOGY_SIBLING_CPUMASK
        # 4.4
        LIBCFS_SRC_KSTRTOBOOL_FROM_USER
@@ -2425,6 +2449,7 @@ AC_DEFUN([LIBCFS_PROG_LINUX_RESULTS], [
        # 4.1
        LIBCFS_KERNEL_PARAM_LOCK
        # 4.2
+       LIBCFS_STRSCPY_EXISTS
        LIBCFS_HAVE_TOPOLOGY_SIBLING_CPUMASK
        # 4.4
        LIBCFS_KSTRTOBOOL_FROM_USER
index 841db69..7d854e7 100644 (file)
@@ -177,6 +177,10 @@ static inline void *cfs_kallsyms_lookup_name(const char *name)
 }
 #endif
 
+#ifndef HAVE_STRSCPY
+#define strscpy(s1, s2, sz)    strlcpy((s1), (s2), (sz))
+#endif
+
 #ifndef HAVE_KOBJ_TYPE_DEFAULT_GROUPS
 #define default_groups                 default_attrs
 #define KOBJ_ATTR_GROUPS(_name)                _name##_attrs
index 6aff70a..7421cfb 100644 (file)
@@ -724,25 +724,6 @@ AC_SUBST(KFILND)
 AC_SUBST(EXTRA_SYMBOLS)
 ]) # LN_CONFIG_KFILND
 
-# LN_CONFIG_STRSCPY_EXISTS
-#
-# If strscpy exists, prefer it over strlcpy
-#
-AC_DEFUN([LN_CONFIG_STRSCPY_EXISTS], [
-tmp_flags="$EXTRA_KCFLAGS"
-EXTRA_KCFLAGS="-Werror"
-LB_CHECK_COMPILE([kernel strscpy is available],
-strscpy_exists, [
-       #include <linux/string.h>
-],[
-       strscpy((char *)NULL, (const char *)NULL, 0);
-],[
-       AC_DEFINE(HAVE_STRSCPY, 1,
-               [kernel strscpy is available])
-])
-EXTRA_KCFLAGS="$tmp_flags"
-]) # LN_CONFIG_STRSCPY_EXISTS
-
 # LN_CONFIG_SOCK_CREATE_KERN
 #
 # 4.x sock_create_kern() added a first parameter as 'struct net *'
@@ -969,7 +950,6 @@ AC_MSG_NOTICE([LNet kernel checks
 LN_CONFIG_BACKOFF
 LN_CONFIG_O2IB
 LN_CONFIG_GNILND
-LN_CONFIG_STRSCPY_EXISTS
 LN_CONFIG_KFILND
 # 3.10
 LN_EXPORT_KMAP_TO_PAGE
index fdc1aa4..81eaa39 100644 (file)
@@ -52,10 +52,6 @@ static int lnet_tbnob = 0;                   /* track text buf allocation */
 #define SPACESTR " \t\v\r\n"
 #define DELIMITERS ":()[]"
 
-#ifndef HAVE_STRSCPY
-#define strscpy(s1, s2, sz)    strlcpy((s1), (s2), (sz))
-#endif
-
 static void
 lnet_syntax(const char *name, const char *str, int offset, int width)
 {