SoW-2019-0002: Dynamic Snapshot
[lttng-tools.git] / src / bin / lttng / commands / track-untrack.c
index afb4d93d1fe9bc30e14f56c6aee90a8c1181330e..24e2d02aeb50e1f6ffb9c5eb3864913b84547715 100644 (file)
@@ -1,24 +1,15 @@
 /*
- * 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>
@@ -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) {
This page took 0.026302 seconds and 5 git commands to generate.