Move to kernel style SPDX license identifiers
[lttng-tools.git] / src / bin / lttng / commands / snapshot.c
index b6b9faa59be0e3412c18a0b56d7a284819b525b9..d357983107ed3312357c74199d272e3a4136694c 100644 (file)
@@ -1,18 +1,8 @@
 /*
- * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
+ * Copyright (C) 2013 David Goulet <dgoulet@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
@@ -346,11 +336,23 @@ static int cmd_add_output(int argc, const char **argv)
        int ret;
 
        if (argc < 2 && (!opt_data_url || !opt_ctrl_url)) {
+               ERR("An output destination must be specified to add a snapshot output.");
                ret = CMD_ERROR;
                goto end;
        }
 
        ret = add_output(argv[1]);
+       if (ret < 0) {
+               switch (-ret) {
+               case LTTNG_ERR_SNAPSHOT_UNSUPPORTED:
+                       ERR("Session \"%s\" contains a channel that is incompatible with the snapshot functionality.\nMake sure all channels are configured in 'mmap' output mode.",
+                                       current_session_name);
+                       ret = CMD_ERROR;
+                       break;
+               default:
+                       break;
+               }
+       }
 
 end:
        return ret;
@@ -363,6 +365,7 @@ static int cmd_del_output(int argc, const char **argv)
        long id;
 
        if (argc < 2) {
+               ERR("A snapshot output name or id must be provided to delete a snapshot output.");
                ret = CMD_ERROR;
                goto end;
        }
@@ -506,8 +509,22 @@ static enum cmd_error_code handle_command(const char **argv)
 
                        result = cmd->func(argc, argv);
                        if (result) {
-                               switch (-result) {
-                               case LTTNG_ERR_SNAPSHOT_NODATA:
+                               switch (result) {
+                               case CMD_ERROR:
+                               case CMD_UNDEFINED:
+                               case CMD_FATAL:
+                               case CMD_WARNING:
+                               case CMD_UNSUPPORTED:
+                                       /*
+                                        * Sub-commands mix lttng_error_codes
+                                        * and cmd_error_codes. This should be
+                                        * cleaned-up, but in the meantime this
+                                        * hack works since the values of the
+                                        * two enums do not intersect.
+                                        */
+                                       cmd_ret = result;
+                                       break;
+                               case -LTTNG_ERR_SNAPSHOT_NODATA:
                                        WARN("%s", lttng_strerror(result));
 
                                        /*  A warning is fine since the user has no control on
This page took 0.024653 seconds and 4 git commands to generate.