SHA256
1
0
forked from pool/systemtap
systemtap/pr31373-deal-with-the-removal-of-strlcpy-from-linux-6.8.patch

41 lines
1.5 KiB
Diff
Raw Normal View History

From: William Cohen <wcohen@redhat.com>
Date: Wed Feb 14 09:33:30 2024 -0500
Subject: PR31373: Deal with the removal of strlcpy() from linux 6.8
Git-commit: 60c3d8b1c90c58ca7c048ef24e1b03c6c04b36ad
References: bsc#1222249
Signed-off-by: Tony Jones <tonyj@suse.de>
PR31373: Deal with the removal of strlcpy() from linux 6.8
The Linux 6.8 kernels removed strlcpy() with git commit d26270061a in
January 2024. All the kernel's strlcpy() uses were converted to
strscpy(). Systemtap needed to do the same. This is implemented in
systemtap with a strlcpy macro in the runtime that translates the
strscpy() return value into the equivalent strlcpy() value.
diff --git a/runtime/linux/runtime.h b/runtime/linux/runtime.h
index 1fa62c7ed..0e9fe3fea 100644
--- a/runtime/linux/runtime.h
+++ b/runtime/linux/runtime.h
@@ -48,6 +48,20 @@
#include <generated/compile.h>
#endif
+// PR31373: Linux 6.8 kernel removed strlcpy
+// This provides equivalent to strlcpy using strscpy
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,8,0)
+#define strlcpy(dest, src, count) ({ \
+ size_t size=(count); \
+ ssize_t retval = strscpy((dest), (src), size);\
+ if (retval<0) \
+ retval = size; /* was truncated */ \
+ else \
+ retval++; /* count the NULL */ \
+ retval; \
+})
+#endif
+
// PR26811: Replace some declarations after set_fs() removal in kernel 5.10+.
// Should use the STP_* prefixed defines outside of STAPCONF_SET_FS.
#if defined(STAPCONF_SET_FS)