X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Ftrack-untrack.c;h=24e2d02aeb50e1f6ffb9c5eb3864913b84547715;hp=afb4d93d1fe9bc30e14f56c6aee90a8c1181330e;hb=refs%2Fheads%2Fsow-2019-0002-rev1;hpb=c47a705beb4d03d1a7498802047f6410814dced3 diff --git a/src/bin/lttng/commands/track-untrack.c b/src/bin/lttng/commands/track-untrack.c index afb4d93d1..24e2d02ae 100644 --- a/src/bin/lttng/commands/track-untrack.c +++ b/src/bin/lttng/commands/track-untrack.c @@ -1,24 +1,15 @@ /* - * Copyright (C) 2011 - David Goulet - * Copyright (C) 2015 - Mathieu Desnoyers + * Copyright (C) 2011 David Goulet + * Copyright (C) 2015 Mathieu Desnoyers * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _LGPL_SOURCE #include #include +#include #include #include #include @@ -460,7 +451,7 @@ static enum cmd_error_code track_untrack_id(enum cmd_type cmd_type, ret = cmd_func(handle, tracker_type, item); if (ret) { - char *msg = NULL; + const char *msg = NULL; switch (-ret) { case LTTNG_ERR_ID_TRACKED: @@ -591,6 +582,7 @@ int cmd_track_untrack(enum cmd_type cmd_type, const char *cmd_str, int argc, const char **argv, const char *help_msg) { int opt, ret = 0, success = 1; + bool opt_all_present = false; enum cmd_error_code command_ret = CMD_SUCCESS; static poptContext pc; char *session_name = NULL; @@ -670,29 +662,7 @@ int cmd_track_untrack(enum cmd_type cmd_type, const char *cmd_str, type_state = STATE_VGID; break; case OPT_ALL: - switch (type_state) { - case STATE_PID: - opt_pid.all = 1; - break; - case STATE_VPID: - opt_vpid.all = 1; - break; - case STATE_UID: - opt_uid.all = 1; - break; - case STATE_VUID: - opt_vuid.all = 1; - break; - case STATE_GID: - opt_gid.all = 1; - break; - case STATE_VGID: - opt_vgid.all = 1; - break; - default: - command_ret = CMD_ERROR; - goto end; - } + opt_all_present = true; break; default: command_ret = CMD_UNDEFINED; @@ -706,6 +676,36 @@ int cmd_track_untrack(enum cmd_type cmd_type, const char *cmd_str, goto end; } + /* + * If the `--all` option is present set the appropriate tracker's `all` + * field. + */ + if (opt_all_present) { + switch (type_state) { + case STATE_PID: + opt_pid.all = 1; + break; + case STATE_VPID: + opt_vpid.all = 1; + break; + case STATE_UID: + opt_uid.all = 1; + break; + case STATE_VUID: + opt_vuid.all = 1; + break; + case STATE_GID: + opt_gid.all = 1; + break; + case STATE_VGID: + opt_vgid.all = 1; + break; + default: + command_ret = CMD_ERROR; + goto end; + } + } + if (!opt_session_name) { session_name = get_session_name(); if (session_name == NULL) {