Error early on invalid tracker type for UST domain
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 4 Nov 2019 22:35:27 +0000 (17:35 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 20 Dec 2019 05:30:59 +0000 (00:30 -0500)
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: Iea182575c99c1fcf84cb8c313af5904581b5023d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng/commands/track-untrack.c

index 4f51ffa30eef02aec6a1bbe9b79bc20f787b7e6f..25b4461f696a7e96beab3265da9f437eb1fda9d5 100644 (file)
@@ -286,6 +286,34 @@ static const char *get_tracker_str(enum lttng_tracker_type tracker_type)
        return NULL;
 }
 
        return NULL;
 }
 
+static int ust_tracker_type_support(enum lttng_tracker_type *tracker_type)
+{
+       int ret;
+
+       switch (*tracker_type) {
+       case LTTNG_TRACKER_PID:
+               *tracker_type = LTTNG_TRACKER_VPID;
+               ret = 0;
+               break;
+       case LTTNG_TRACKER_VPID:
+       case LTTNG_TRACKER_VUID:
+       case LTTNG_TRACKER_VGID:
+               ret = 0;
+               break;
+       case LTTNG_TRACKER_UID:
+       case LTTNG_TRACKER_GID:
+               ERR("The %s tracker is invalid for UST domain.",
+                               get_tracker_str(*tracker_type));
+               ret = -1;
+               break;
+       default:
+               ret = -1;
+               break;
+       }
+
+       return ret;
+}
+
 static enum cmd_error_code track_untrack_id(enum cmd_type cmd_type,
                const char *cmd_str,
                const char *session_name,
 static enum cmd_error_code track_untrack_id(enum cmd_type cmd_type,
                const char *cmd_str,
                const char *session_name,
@@ -321,8 +349,11 @@ static enum cmd_error_code track_untrack_id(enum cmd_type cmd_type,
                dom.type = LTTNG_DOMAIN_KERNEL;
        } else if (opt_userspace) {
                dom.type = LTTNG_DOMAIN_UST;
                dom.type = LTTNG_DOMAIN_KERNEL;
        } else if (opt_userspace) {
                dom.type = LTTNG_DOMAIN_UST;
-               if (tracker_type == LTTNG_TRACKER_PID) {
-                       tracker_type = LTTNG_TRACKER_VPID;
+               ret = ust_tracker_type_support(&tracker_type);
+               if (ret) {
+                       ERR("Invalid parameter");
+                       retval = CMD_ERROR;
+                       goto end;
                }
        } else {
                /* Checked by the caller. */
                }
        } else {
                /* Checked by the caller. */
This page took 0.034529 seconds and 4 git commands to generate.