Fix: snapshot path have domain subdir duplicate "ust/ust" or "kernel/kernel"
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 1 Dec 2020 17:19:53 +0000 (12:19 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 13 May 2021 00:28:11 +0000 (20:28 -0400)
Observed issue
==============

lttng-ivc observed unexpected path generated for streamed snapshot:

  joraj-alpa/
   test-20190319-120000-20210113-110101/
    snapshot-1-20210113-110102-0/
*     ust/
*      ust/
        pid/
         app-ust-2362198-20210113-110101/
           channel_0
           channel_1
           metadata
           channel_2
           channel_3

"ust" the domain subdir is present two-time instead off only one time.

The same problem is seen for kernel snapshots.

Cause
=====

Based on dissection the problem was introduced by commit
5da88b0f58d7f838068037ea449ddfb25d3e85ad [1]

For snapshots, the consumer output object of the snapshot output and
information is fetched from the *original* consumer output.
(code block around src/bin/lttng-sessiond/cmd.c:4748)

The snapshot consumer output does not contains the necessary information
to populate domain_subdir on copy (domain_subdir is '\0').

This would lead to a len evaluation of 1 for the consumer_path_offset in
setup_channel_trace_path:70. This would end up not "skipping" the "ust"
and "kernel" part of the path.

Solution
========

Part of the solution is to copy the domain_subdir from the original
session consumer output to the snapshot output.

Still, the problem was still present since that now that the
domain_subdir was not "\0", the value was suffixed to the passed
session_path. In the snapshot code path, "ust/" and "kernel/" were
already present in the session_path passed to setup_channel_trace_path.

A quick modification at the caller level in the snapshot code path fixes
the issues once and for all.

Tests
=======

The test suit is augmented for certain key tests to validate the
complete path of a trace.

Path validation is based on crude bash pattern matching.

Known drawbacks
=========
None

References
==========
[1] https://github.com/lttng/lttng-tools/commit/5da88b0f58d7f838068037ea449ddfb25d3e85ad

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie7cd2d5471ee3a942fa511e2f4cab09e3aa499e4

14 files changed:
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/ust-app.c
tests/regression/kernel/test_event_basic
tests/regression/tools/base-path/test_ust
tests/regression/tools/live/test_lttng_kernel
tests/regression/tools/snapshots/test_kernel
tests/regression/tools/snapshots/test_kernel_streaming
tests/regression/tools/snapshots/test_ust_streaming
tests/regression/tools/snapshots/ust_test
tests/regression/tools/streaming/test_kernel
tests/regression/tools/streaming/test_ust
tests/regression/tools/tracefile-limits/test_tracefile_size
tests/utils/utils.sh

index 712b68089002fde4855e4de8278a5b6bec672035..9ae4d1974293a9197362f92b244eaca8f3543aff 100644 (file)
@@ -5028,6 +5028,11 @@ enum lttng_error_code snapshot_record(struct ltt_session *session,
                                consumer_copy_output(snapshot_output->consumer);
                strcpy(snapshot_kernel_consumer_output->chunk_path,
                        snapshot_chunk_name);
+
+               /* Copy the original domain subdir. */
+               strcpy(snapshot_kernel_consumer_output->domain_subdir,
+                               original_kernel_consumer_output->domain_subdir);
+
                ret = consumer_copy_sockets(snapshot_kernel_consumer_output,
                                original_kernel_consumer_output);
                if (ret < 0) {
@@ -5050,6 +5055,11 @@ enum lttng_error_code snapshot_record(struct ltt_session *session,
                                consumer_copy_output(snapshot_output->consumer);
                strcpy(snapshot_ust_consumer_output->chunk_path,
                        snapshot_chunk_name);
+
+               /* Copy the original domain subdir. */
+               strcpy(snapshot_ust_consumer_output->domain_subdir,
+                               original_ust_consumer_output->domain_subdir);
+
                ret = consumer_copy_sockets(snapshot_ust_consumer_output,
                                original_ust_consumer_output);
                if (ret < 0) {
index f1e61846d8a18911989b9b4a87120f9fbf9e7841..5afd87734c3ba09d5729e9a482a16b9163bb1b3a 100644 (file)
@@ -1699,7 +1699,7 @@ enum lttng_error_code kernel_snapshot_record(
        }
 
        trace_path = setup_channel_trace_path(ksess->consumer,
-                       DEFAULT_KERNEL_TRACE_DIR, &consumer_path_offset);
+                       "", &consumer_path_offset);
        if (!trace_path) {
                status = LTTNG_ERR_INVALID;
                goto error;
index d249762a4299ea8123e13240c786b243928c66d4..f8668d88c4be34c043e6aaa2c87c4eda6aa6c0ee 100644 (file)
@@ -6742,7 +6742,7 @@ enum lttng_error_code ust_app_snapshot_record(
 
                        memset(pathname, 0, sizeof(pathname));
                        ret = snprintf(pathname, sizeof(pathname),
-                                       DEFAULT_UST_TRACE_DIR "/" DEFAULT_UST_TRACE_UID_PATH,
+                                       DEFAULT_UST_TRACE_UID_PATH,
                                        reg->uid, reg->bits_per_long);
                        if (ret < 0) {
                                PERROR("snprintf snapshot path");
@@ -6806,7 +6806,7 @@ enum lttng_error_code ust_app_snapshot_record(
 
                        /* Add the UST default trace dir to path. */
                        memset(pathname, 0, sizeof(pathname));
-                       ret = snprintf(pathname, sizeof(pathname), DEFAULT_UST_TRACE_DIR "/%s",
+                       ret = snprintf(pathname, sizeof(pathname), "%s",
                                        ua_sess->path);
                        if (ret < 0) {
                                status = LTTNG_ERR_INVALID;
index b0ed0ea9021ae916fc219cadbda698d0bd2cdd23..f3a393eb8ed4ffbac581bc0cd729ff754499cbb8 100755 (executable)
@@ -9,7 +9,7 @@ TEST_DESC="Kernel tracer - Basic event"
 
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
-NUM_TESTS=20
+NUM_TESTS=21
 
 TESTCMD="/bin/true"
 
@@ -33,6 +33,7 @@ function test_event_basic()
        eval ${TESTCMD}
        stop_lttng_tracing_ok
 
+       validate_trace_path_kernel "$TRACE_PATH" ""
        validate_trace "sched_switch" $TRACE_PATH
        validate_trace "sched_process_exit" $TRACE_PATH
        validate_trace "sched_process_fork" $TRACE_PATH
index 26996b4ae902af69ec0c1ecb9633531675069ac9..51c954a881293f075a472d2283130faf86629c79 100755 (executable)
@@ -15,7 +15,7 @@ EVENT_NAME="tp:tptest"
 
 TRACE_PATH=$(mktemp -d)
 
-NUM_TESTS=37
+NUM_TESTS=42
 
 source "$TESTDIR/utils/utils.sh"
 
@@ -40,6 +40,7 @@ function ust_app_stream_base_path ()
        destroy_lttng_session_ok $session_name
 
        # validate test
+       validate_trace_path_ust_uid_network "$TRACE_PATH" "" "$base_path"
        if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then
                # only delete if successful
                rm -rf "$TRACE_PATH"
@@ -67,6 +68,7 @@ function ust_app_snapshot_create_base_path ()
        destroy_lttng_session_ok $session_name
 
        # validate test
+       validate_trace_path_ust_uid_snapshot_network "$TRACE_PATH" "" "snapshot-1" 0 "$base_path"
        if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then
                # only delete if successful
                rm -rf "$TRACE_PATH"
@@ -93,6 +95,7 @@ function ust_app_snapshot_base_path ()
        destroy_lttng_session_ok $session_name
 
        # validate test
+       validate_trace_path_ust_uid_snapshot_network "$TRACE_PATH" "" "snapshot-0" 0 "$base_path"
        if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then
                # only delete if successful
                rm -rf "$TRACE_PATH"
@@ -120,6 +123,7 @@ function ust_app_snapshot_add_output_base_path ()
        destroy_lttng_session_ok $session_name
 
        # validate test
+       validate_trace_path_ust_uid_snapshot_network "$TRACE_PATH" "" "snapshot-1" 0 "$base_path"
        if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then
                # only delete if successful
                rm -rf "$TRACE_PATH"
@@ -141,6 +145,7 @@ function ust_app_stream_base_path_via_load ()
        destroy_lttng_session_ok $session_name
 
        # validate test
+       validate_trace_path_ust_uid_network "$TRACE_PATH" "" "$base_path"
        if validate_trace $EVENT_NAME "$TRACE_PATH/$HOSTNAME/$base_path"; then
                # only delete if successful
                rm -rf "$TRACE_PATH"
index ea2a1e4e47c55e96a83e011f885560fe35cee755..010ff855ac141e33eaf8bb18cbc49ec096db0f8a 100755 (executable)
@@ -18,7 +18,7 @@ TRACE_PATH=$(mktemp -d)
 
 DIR=$(readlink -f $TESTDIR)
 
-NUM_TESTS=10
+NUM_TESTS=11
 
 source $TESTDIR/utils/utils.sh
 
@@ -64,6 +64,7 @@ skip $isroot "Root access is needed. Skipping all tests." $NUM_TESTS ||
 
        clean_live_tracing
 
+       validate_trace_path_kernel_network "$TRACE_PATH" "$SESSION_NAME"
        validate_trace $EVENT_NAME $TRACE_PATH
        rm -rf $TRACE_PATH
 
index 24b0ad4a2b6f43dc222cf42c6607807713718f50..d4e0008f9be279c860a39303c3d225acea4ea8aa 100755 (executable)
@@ -14,7 +14,7 @@ CHANNEL_NAME="snapchan"
 
 TRACE_PATH=$(mktemp -d)
 
-NUM_TESTS=2060
+NUM_TESTS=2061
 
 source $TESTDIR/utils/utils.sh
 
@@ -31,12 +31,11 @@ function test_kernel_local_snapshot ()
        destroy_lttng_session_ok $SESSION_NAME
 
        # Validate test
+       validate_trace_path_kernel_snapshot "$TRACE_PATH" "" "snapshot-1" 0 ""
        validate_trace $EVENT_NAME $TRACE_PATH/
        if [ $? -eq 0 ]; then
                # Only delete if successful
                rm -rf $TRACE_PATH
-       else
-               break
        fi
 }
 
index 544c2e4db1a4dfdea57654a97b8e9aa079e2fccc..273bcdd04d00222a25adc0e5c811273b455cec29 100755 (executable)
@@ -14,7 +14,7 @@ CHANNEL_NAME="chan1"
 
 TRACE_PATH=$(mktemp -d)
 
-NUM_TESTS=61
+NUM_TESTS=66
 
 source $TESTDIR/utils/utils.sh
 
@@ -127,6 +127,7 @@ function test_kernel_n_snapshot()
                start_lttng_tracing_ok $SESSION_NAME
                lttng_snapshot_record $SESSION_NAME
                stop_lttng_tracing_ok $SESSION_NAME
+               validate_trace_path_kernel_snapshot_network "$TRACE_PATH" "$SESSION_NAME" "snapshot-1" $(( i - 1 )) ""
                validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*/snapshot-1*
                if [ $? -ne 0 ]; then
                        return 1
index 38bbc71ff35630a641d8b29014e19cebf3bc8eb6..2b20ccaf0357ef68c43414aac589b4689d512d72 100755 (executable)
@@ -21,7 +21,7 @@ APPS_PID=
 
 TRACE_PATH=$(mktemp -d)
 
-NUM_TESTS=75
+NUM_TESTS=85
 
 source $TESTDIR/utils/utils.sh
 
@@ -89,6 +89,7 @@ function test_ust_default_name_with_del()
        lttng_snapshot_record $SESSION_NAME
 
        # Validate test
+       validate_trace_path_ust_uid_snapshot_network "$TRACE_PATH" "$SESSION_NAME" "snapshot-1" 0
        validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*/snapshot-1*
        if [ $? -ne 0 ]; then
                stop_test_apps
@@ -100,6 +101,7 @@ function test_ust_default_name_with_del()
        lttng_snapshot_record $SESSION_NAME
 
        # Validate test with the next ID since a del output was done prior.
+       validate_trace_path_ust_uid_snapshot_network "$TRACE_PATH" "$SESSION_NAME" "snapshot-2" 1
        validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*/snapshot-2*
        if [ $? -ne 0 ]; then
                stop_test_apps
@@ -130,6 +132,7 @@ function test_ust_default_name()
        stop_lttng_tracing_ok $SESSION_NAME
        destroy_lttng_session_ok $SESSION_NAME
        # Validate test
+       validate_trace_path_ust_uid_snapshot_network "$TRACE_PATH" "$SESSION_NAME" "snapshot-1" 0
        validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*/snapshot-1*
        out=$?
 
@@ -153,6 +156,7 @@ function test_ust_default_name_custom_uri()
        stop_lttng_tracing_ok $SESSION_NAME
        destroy_lttng_session_ok $SESSION_NAME
        # Validate test
+       validate_trace_path_ust_uid_snapshot_network "$TRACE_PATH" "$SESSION_NAME" "snapshot-1" 0
        validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*/snapshot-1*
        out=$?
 
@@ -183,6 +187,7 @@ function test_ust_custom_name()
        if ls $TRACE_PATH/$HOSTNAME/$SESSION_NAME*/$name* &> /dev/null; then
                ok 0 "Custom name snapshot exists"
                # Validate test
+               validate_trace_path_ust_uid_snapshot_network "$TRACE_PATH" "$SESSION_NAME" "$name" 0
                validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*/$name-*
                out=$?
        else
@@ -201,13 +206,14 @@ function test_ust_n_snapshot()
        create_lttng_session_no_output $SESSION_NAME
        enable_lttng_mmap_overwrite_ust_channel $SESSION_NAME $CHANNEL_NAME
        enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $CHANNEL_NAME
-       snapshot_add_output $SESSION_NAME "net://localhost" $name
+       snapshot_add_output $SESSION_NAME "net://localhost"
        start_test_app
-       for i in {1..5};
+       for i in {0..4};
        do
                start_lttng_tracing_ok $SESSION_NAME
                lttng_snapshot_record $SESSION_NAME
                stop_lttng_tracing_ok $SESSION_NAME
+               validate_trace_path_ust_uid_snapshot_network "$TRACE_PATH" "$SESSION_NAME" "snapshot-1" $i
                validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*/snapshot-1*
                if [ $? -ne 0 ]; then
                        return 1
index 37475d7fdd49c387242e5646fa62d0294a60c69d..8daaa045d125a5255f7e02ba36ff4c38488561e7 100755 (executable)
@@ -16,7 +16,7 @@ TESTAPP_NAME="gen-ust-events"
 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 APPS_PID=
 
-NUM_TESTS=100
+NUM_TESTS=105
 
 TRACE_PATH=$(mktemp -d)
 
@@ -32,7 +32,7 @@ if [ -z $1 ]; then
 fi
 NR_SNAPSHOT=$1
 
-NUM_TESTS=$(($NUM_TESTS + ($NR_SNAPSHOT * 2)))
+NUM_TESTS=$(($NUM_TESTS + ($NR_SNAPSHOT * 3)))
 
 function start_test_app()
 {
@@ -193,6 +193,7 @@ function test_ust_local_snapshot ()
        destroy_lttng_session_ok $SESSION_NAME
 
        # Validate test
+       validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0
        validate_trace $EVENT_NAME $TRACE_PATH/
        if [ $? -eq 0 ]; then
                # Only delete if successful
@@ -335,6 +336,7 @@ function test_ust_local_snapshot_max_size ()
        destroy_lttng_session_ok $SESSION_NAME
 
        # Validate test
+       validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0
        validate_trace $EVENT_NAME $TRACE_PATH/
 
        if [ $? -eq 0 ]; then
@@ -365,6 +367,7 @@ function test_ust_local_snapshot_large_metadata ()
        destroy_lttng_session_ok $SESSION_NAME
 
        # Validate test
+       validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0
        validate_trace $LM_EVENT $TRACE_PATH/
        if [ $? -eq 0 ]; then
                # Only delete if successful
@@ -400,6 +403,7 @@ function test_ust_per_uid_local_snapshot ()
        destroy_lttng_session_ok $SESSION_NAME
 
        # Validate test
+       validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0
        validate_trace $EVENT_NAME $TRACE_PATH/
        if [ $? -eq 0 ]; then
                # Only delete if successful
@@ -430,6 +434,7 @@ function test_ust_per_uid_local_snapshot_post_mortem ()
        destroy_lttng_session_ok $SESSION_NAME
 
        # Validate test
+       validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" 0
        validate_trace $EVENT_NAME $TRACE_PATH/
        if [ $? -eq 0 ]; then
                # Only delete if successful
@@ -457,6 +462,7 @@ function test_ust_local_snapshots ()
                rm -rf $TRACE_PATH/snapshot/* 2>/dev/null
                lttng_snapshot_record $SESSION_NAME
                # Validate test
+               validate_trace_path_ust_uid_snapshot "$TRACE_PATH" "" "snapshot-1" $((i - 1))
                validate_trace $EVENT_NAME $TRACE_PATH/
                if [ $? -eq 0 ]; then
                        # Only delete if successful
index 9ab43882c308ef88bc604f68e1671ed92a2eec43..a7069ccb8fb11247783705701aa80009da8ffee3 100755 (executable)
@@ -13,7 +13,7 @@ SESSION_NAME=""
 
 TRACE_PATH=$(mktemp -d)
 
-NUM_TESTS=10
+NUM_TESTS=11
 
 source $TESTDIR/utils/utils.sh
 
@@ -68,6 +68,7 @@ skip $isroot "Root access is needed. Skipping all kernel streaming tests." $NUM_
                ${fct_test}
 
                # Validate test
+               validate_trace_path_kernel_network "$TRACE_PATH" "$SESSION_NAME"
                validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
                if [ $? -eq 0 ]; then
                        # Only delete if successful
index e3fd9af42d1e5af8c27b9cfd7d402e5f2ff305a1..d030f165801278146a9aca9e34dc93c0eca4293f 100755 (executable)
@@ -18,7 +18,7 @@ EVENT_NAME="tp:tptest"
 
 TRACE_PATH=$(mktemp -d)
 
-NUM_TESTS=16
+NUM_TESTS=18
 
 source $TESTDIR/utils/utils.sh
 
@@ -91,6 +91,7 @@ do
        ${fct_test}
 
        # Validate test
+       validate_trace_path_ust_uid_network "$TRACE_PATH" "$SESSION_NAME"
        validate_trace $EVENT_NAME $TRACE_PATH/$HOSTNAME/$SESSION_NAME*
        if [ $? -eq 0 ]; then
                # Only delete if successful
index 5d4b035504512662eafbce0891f132462f7ff4c3..c07972b77f2cba31b3e4e2601d92496370adc1f1 100755 (executable)
@@ -17,7 +17,7 @@ TESTAPP_PATH="$TESTDIR/utils/testapp"
 TESTAPP_NAME="gen-ust-events"
 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 
-NUM_TESTS=66
+NUM_TESTS=74
 
 source $TESTDIR/utils/utils.sh
 
@@ -115,6 +115,7 @@ function test_tracefile_size_limit ()
 
        # Validate tracing data, we should at least have some events
 
+       validate_trace_path_ust_pid "$trace_path" "" "gen-ust-eve-ust"
        validate_trace $event_name $trace_path
 
        rm -rf $trace_path
@@ -153,6 +154,7 @@ function test_tracefile_size_limit_pagesize ()
 
        # Validate tracing data, we should at least have some events
 
+       validate_trace_path_ust_pid "$trace_path" "" "gen-ust-eve-ust"
        validate_trace $event_name $trace_path
 
        rm -rf $trace_path
index af125c9814ca07ad7b7abd3dc105018f645c1b0d..f3b4c68c1337720cc599cb534c5131d411bebe42 100644 (file)
@@ -16,6 +16,11 @@ BABELTRACE_BIN="babeltrace"
 OUTPUT_DEST=/dev/null
 ERROR_OUTPUT_DEST=/dev/null
 
+# To match 20201127-175802
+date_time_pattern="[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]"
+# The size of a long on this system
+system_long_bit_size=$(getconf LONG_BIT)
+
 # Minimal kernel version supported for session daemon tests
 KERNEL_MAJOR_VERSION=2
 KERNEL_MINOR_VERSION=6
@@ -2241,3 +2246,223 @@ function lttng_remove_trigger_ok()
 {
        lttng_remove_trigger 0 "$@"
 }
+
+function validate_path_pattern ()
+{
+       local message=$1
+       local pattern=$2
+       # Base path is only used in error case and is used to list the content
+       # of the base path.
+       local base_path=$3
+
+
+       [ -f $pattern ]
+       ret=$?
+       ok $ret "$message"
+
+       if [ "$ret" -ne "0" ]; then
+               diag "Path pattern expected: $pattern"
+               # List the tracepath for more info. We use find as a recursive
+               # directory lister.
+               diag "The base path content:"
+               find "$base_path" -print
+       fi
+}
+
+function validate_trace_path_ust_uid ()
+{
+       local trace_path=$1
+       local session_name=$2
+       local uid=$UID
+       local pattern="$trace_path/$session_name-$date_time_pattern/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
+
+       validate_path_pattern "UST per-uid trace path is valid" "$pattern" "$trace_path"
+}
+
+function validate_trace_path_ust_uid_network ()
+{
+       local trace_path=$1
+       local session_name=$2
+       local base_path=$3
+       local uid=$UID
+       local hostname=$HOSTNAME
+       local pattern
+       local ret
+
+       # If the session was given a network base path (e.g
+       # 127.0.0.1/my/custom/path on creation, there is no session name
+       # component to the path on the relayd side. Caller can simply not pass a
+       # session name for this scenario.
+       if [ -n "$session_name" ]; then
+               session_name="$session_name-$date_time_pattern"
+               if [ -n "$base_path" ]; then
+                       fail "Session name and base path are mutually exclusive"
+                       return
+               fi
+       fi
+
+       pattern="$trace_path/$hostname/$base_path/$session_name/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
+
+       validate_path_pattern "UST per-uid network trace path is valid" "$pattern" "$trace_path"
+}
+
+function validate_trace_path_ust_uid_snapshot_network ()
+{
+       local trace_path=$1
+       local session_name=$2
+       local snapshot_name=$3
+       local snapshot_number=$4
+       local base_path=$5
+       local hostname=$HOSTNAME
+       local uid=$UID
+       local pattern
+       local ret
+
+       # If the session/output was given a network base path (e.g
+       # 127.0.0.1/my/custom/path on creation, there is no session name
+       # component to the path on the relayd side. Caller can simply not pass a
+       # session name for this scenario.
+       if [ -n "$session_name" ]; then
+               session_name="$session_name-$date_time_pattern"
+               if [ -n "$base_path" ]; then
+                       fail "Session name and base path are mutually exclusive"
+                       return
+               fi
+       fi
+
+       pattern="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
+
+       validate_path_pattern "UST per-uid network snapshot trace path is valid" "$pattern" "$trace_path"
+}
+
+function validate_trace_path_ust_uid_snapshot ()
+{
+       local trace_path=$1
+       local session_name=$2
+       local snapshot_name=$3
+       local snapshot_number=$4
+       local base_path=$5
+       local uid=$UID
+       local pattern
+       local ret
+
+       # If the session/output was given a network base path (e.g
+       # 127.0.0.1/my/custom/path) on creation, there is no session name
+       # component to the path on the relayd side. Caller can simply not pass a
+       # session name for this scenario.
+       if [ -n "$session_name" ]; then
+               session_name="$session_name-$date_time_pattern"
+               if [ -n "$base_path" ]; then
+                       fail "Session name and base path are mutually exclusive"
+                       return
+               fi
+       fi
+
+       pattern="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/ust/uid/$uid/${system_long_bit_size}-bit/metadata"
+
+       validate_path_pattern "UST per-uid snapshot trace path is valid" "$pattern" "$trace_path"
+}
+
+function validate_trace_path_ust_pid ()
+{
+       local trace_path=$1
+       local session_name=$2
+       local app_string=$3
+       local pid=$4
+       local pattern
+       local ret
+
+       # If the session was given a trace path on creation, there is no session
+       # name component to the path. Caller can simply not pass a session name
+       # for this scenario.
+       if [ -n "$session_name" ]; then
+               session_name="$session_name-$date_time_pattern"
+       fi
+
+       pattern="$trace_path/$session_name/ust/pid/$pid/$app_string-*-$date_time_pattern/metadata"
+
+       validate_path_pattern "UST per-pid trace path is valid" "$pattern" "$trace_path"
+}
+
+function validate_trace_path_kernel ()
+{
+       local trace_path=$1
+       local session_name=$2
+       local pattern
+
+       # If the session was given a trace path on creation, there is no session
+       # name component to the path. Caller can simply not pass a session name
+       # for this scenario.
+       if [ -n "$session_name" ]; then
+               session_name="$session_name-$date_time_pattern"
+       fi
+
+       pattern="$trace_path/$session_name/kernel/metadata"
+
+       validate_path_pattern "Kernel trace path is valid" "$pattern" "$trace_path"
+}
+
+function validate_trace_path_kernel_network ()
+{
+       local trace_path=$1
+       local session_name=$2
+       local hostname=$HOSTNAME
+       local pattern="$trace_path/$hostname/$session_name-$date_time_pattern/kernel/metadata"
+
+       validate_path_pattern "Kernel network trace path is valid" "$pattern" "$trace_path"
+}
+
+function validate_trace_path_kernel_snapshot ()
+{
+       local trace_path=$1
+       local session_name=$2
+       local snapshot_name=$3
+       local snapshot_number=$4
+       local base_path=$5
+       local pattern
+       local ret
+
+       # If the session/output was given a network base path (e.g
+       # 127.0.0.1/my/custom/path on creation, there is no session name
+       # component to the path on the relayd side. Caller can simply not pass a
+       # session name for this scenario.
+       if [ -n "$session_name" ]; then
+               session_name="$session_name-$date_time_pattern"
+               if [ -n "$base_path" ]; then
+                       fail "Session name and base path are mutually exclusive"
+                       return
+               fi
+       fi
+
+       pattern="$trace_path/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
+
+       validate_path_pattern "Kernel snapshot trace path is valid" "$pattern" "$trace_path"
+}
+
+function validate_trace_path_kernel_snapshot_network ()
+{
+       local trace_path=$1
+       local session_name=$2
+       local snapshot_name=$3
+       local snapshot_number=$4
+       local base_path=$5
+       local hostname=$HOSTNAME
+       local pattern
+       local ret
+
+       # If the session/output was given a network base path (e.g
+       # 127.0.0.1/my/custom/path on creation, there is no session name
+       # component to the path on the relayd side. Caller can simply not pass a
+       # session name for this scenario.
+       if [ -n "$session_name" ]; then
+               session_name="$session_name-$date_time_pattern"
+               if [ -n "$base_path" ]; then
+                       fail "Session name and base path are mutually exclusive"
+                       return
+               fi
+       fi
+
+       pattern="$trace_path/$hostname/$base_path/$session_name/$snapshot_name-$date_time_pattern-$snapshot_number/kernel/metadata"
+
+       validate_path_pattern "Kernel network snapshot trace path is valid" "$pattern" "$trace_path"
+}
This page took 0.039855 seconds and 4 git commands to generate.