From: Jonathan Rajotte Date: Mon, 4 Nov 2019 22:35:27 +0000 (-0500) Subject: Error early on invalid tracker type for UST domain X-Git-Tag: v2.12.0-rc1~98 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ef440343c0d6372c1aaca74d0cdecfcd700a5785;p=lttng-tools.git Error early on invalid tracker type for UST domain Signed-off-by: Jonathan Rajotte Change-Id: Iea182575c99c1fcf84cb8c313af5904581b5023d Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng/commands/track-untrack.c b/src/bin/lttng/commands/track-untrack.c index 4f51ffa30..25b4461f6 100644 --- a/src/bin/lttng/commands/track-untrack.c +++ b/src/bin/lttng/commands/track-untrack.c @@ -286,6 +286,34 @@ static const char *get_tracker_str(enum lttng_tracker_type tracker_type) 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, @@ -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; - 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. */