/*
- * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
- * Copyright (C) 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
- * 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 <ctype.h>
#include <popt.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
ret = cmd_func(handle, tracker_type, item);
if (ret) {
- char *msg = NULL;
+ const char *msg = NULL;
switch (-ret) {
case LTTNG_ERR_ID_TRACKED:
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;
+ int opt, ret = 0, success = 1;
+ bool opt_all_present = false;
enum cmd_error_code command_ret = CMD_SUCCESS;
- int success = 1;
static poptContext pc;
char *session_name = NULL;
+ const char *leftover = NULL;
struct mi_writer *writer = NULL;
if (argc < 1) {
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;
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) {
session_name = opt_session_name;
}
+ leftover = poptGetArg(pc);
+ if (leftover) {
+ ERR("Unknown argument: %s", leftover);
+ command_ret = CMD_ERROR;
+ goto end;
+ }
+
/* Mi check */
if (lttng_opt_mi) {
writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi);