From 844721635c1c8e7e43fb546052a659bfc92ed99d Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sun, 6 Apr 2025 16:16:32 -0400 Subject: Update bcachefs sources to 2f9361370129 bcachefs: Improve opts.degraded Signed-off-by: Kent Overstreet --- include/linux/string_helpers.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/linux/string_helpers.h') diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h index af587706..d4b2f4d3 100644 --- a/include/linux/string_helpers.h +++ b/include/linux/string_helpers.h @@ -17,4 +17,15 @@ enum string_size_units { int string_get_size(u64 size, u64 blk_size, enum string_size_units units, char *buf, int len); +static inline void memcpy_and_pad(void *dest, size_t dest_len, const void *src, + size_t count, int pad) +{ + if (dest_len > count) { + memcpy(dest, src, count); + memset(dest + count, pad, dest_len - count); + } else { + memcpy(dest, src, dest_len); + } +} + #endif -- cgit v1.2.3