Replace forbidden / character by _ for session name
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 4 Mar 2021 17:13:57 +0000 (12:13 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 4 Mar 2021 17:13:57 +0000 (12:13 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/lttng-trace.c

index aa6dcb7674c5fc769e0c86ee1c184d7647852854..29fb4a558cb655e2781ba5272cd3fd0299274740 100644 (file)
@@ -581,6 +581,27 @@ void sighandler(int signo, siginfo_t *siginfo __unused, void *context __unused)
        }
 }
 
+/*
+ * Replace forbidden session name characters by '_'.
+ */
+static
+void replace_session_chars(char *session_name)
+{
+       size_t len, i;
+
+       len = strlen(session_name);
+       for (i = 0; i < len; i++) {
+               char *p = &session_name[i];
+               switch (*p) {
+               case '/':
+                       *p = '_';
+                       break;
+               default:
+                       break;
+               }
+       }
+}
+
 static
 int lttng_trace_ctx_init(struct lttng_trace_ctx *ctx, const char *cmd_name)
 {
@@ -612,6 +633,7 @@ int lttng_trace_ctx_init(struct lttng_trace_ctx *ctx, const char *cmd_name)
                strcat(ctx->session_name, "-");
                strcat(ctx->session_name, datetime);
        }
+       replace_session_chars(ctx->session_name);
 
        if (opt_output) {
                if (strlen(output_path) > PATH_MAX - 1) {
This page took 0.02417 seconds and 4 git commands to generate.