Whamcloud - gitweb
LU-16520 build: Move strscpy to libcfs common header 66/56766/4
authorShaun Tancheff <shaun.tancheff@hpe.com>
Wed, 23 Oct 2024 06:25:55 +0000 (23:25 -0700)
committerOleg Drokin <green@whamcloud.com>
Tue, 5 Nov 2024 06:29:46 +0000 (06:29 +0000)
Ensure strscpy is available to lustre

Lustre-change: https://review.whamcloud.com/49863
Lustre-commit: 7fe7f4ca06b9c8d128f7ba36988e36f8141ed53d

Test-Parameters: trivial
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Change-Id: I0c3673c2aa7e6b61671521a8cabde8a364f7f6f8
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56766
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
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 37c2762..b777240 100644 (file)
@@ -614,6 +614,31 @@ 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>
+       ],[
+               char buf[129];
+
+               strscpy(buf, "something", sizeof(buf));
+       ],[-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
 #
@@ -2289,9 +2314,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
@@ -2434,6 +2460,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 c542c19..f8b19e1 100644 (file)
@@ -198,6 +198,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 e8fb1aa..5d90e64 100644 (file)
@@ -697,25 +697,6 @@ AC_SUBST(GNICPPFLAGS)
 AC_SUBST(GNILND)
 ]) # LN_CONFIG_GNILND
 
-# 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 *'
@@ -942,7 +923,6 @@ AC_MSG_NOTICE([LNet kernel checks
 LN_CONFIG_BACKOFF
 LN_CONFIG_O2IB
 LN_CONFIG_GNILND
-LN_CONFIG_STRSCPY_EXISTS
 # 3.10
 LN_EXPORT_KMAP_TO_PAGE
 # 3.15
index 09fe96d..01dd3d8 100644 (file)
@@ -51,10 +51,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)
 {