aboutsummaryrefslogtreecommitdiff
path: root/drivers/md/dm-vdo/string-utils.c
diff options
context:
space:
mode:
authorMatthew Sakai <[email protected]>2023-11-16 19:44:01 -0500
committerMike Snitzer <[email protected]>2024-02-20 13:43:13 -0500
commit03d1089e1dc7f05afb2bfc76bffc71de17e4297e (patch)
treeef710d43041426d0d231556db3936bbab6ddfcf4 /drivers/md/dm-vdo/string-utils.c
parent46766d4888ffdfd2bce91a6879bd6285a92a4881 (diff)
dm vdo: add basic logging and support utilities
Add various support utilities for the vdo target and deduplication index, including logging utilities, string and time management, and index-specific error codes. Co-developed-by: J. corwin Coburn <[email protected]> Signed-off-by: J. corwin Coburn <[email protected]> Co-developed-by: Michael Sclafani <[email protected]> Signed-off-by: Michael Sclafani <[email protected]> Co-developed-by: Thomas Jaskiewicz <[email protected]> Signed-off-by: Thomas Jaskiewicz <[email protected]> Co-developed-by: Ken Raeburn <[email protected]> Signed-off-by: Ken Raeburn <[email protected]> Signed-off-by: Matthew Sakai <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
Diffstat (limited to 'drivers/md/dm-vdo/string-utils.c')
-rw-r--r--drivers/md/dm-vdo/string-utils.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/md/dm-vdo/string-utils.c b/drivers/md/dm-vdo/string-utils.c
new file mode 100644
index 000000000000..a584b37bb70c
--- /dev/null
+++ b/drivers/md/dm-vdo/string-utils.c
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright 2023 Red Hat
+ */
+
+#include "string-utils.h"
+
+#include "errors.h"
+#include "logger.h"
+#include "memory-alloc.h"
+#include "permassert.h"
+#include "uds.h"
+
+char *uds_append_to_buffer(char *buffer, char *buf_end, const char *fmt, ...)
+{
+ va_list args;
+ size_t n;
+
+ va_start(args, fmt);
+ n = vsnprintf(buffer, buf_end - buffer, fmt, args);
+ if (n >= (size_t) (buf_end - buffer))
+ buffer = buf_end;
+ else
+ buffer += n;
+ va_end(args);
+
+ return buffer;
+}