ret = LTTCOMM_KERN_CHAN_ENABLE_FAIL;
goto error;
}
+ } else {
+ ret = LTTCOMM_KERN_CHAN_EXIST;
+ goto error;
}
ret = LTTCOMM_OK;
/* If already enabled, everything is OK */
if (uchan->enabled) {
DBG3("Channel %s already enabled. Skipping", uchan->name);
+ ret = LTTCOMM_UST_CHAN_EXIST;
goto end;
}
ret = LTTCOMM_KERN_ENABLE_FAIL;
goto end;
}
+ } else {
+ /* At this point, the event is considered enabled */
+ ret = LTTCOMM_KERN_EVENT_EXIST;
+ goto end;
}
+
ret = LTTCOMM_OK;
end:
return ret;
#include <common/common.h>
#include <common/kernel-ctl/kernel-ctl.h>
+#include <common/sessiond-comm/sessiond-comm.h>
#include "kernel.h"
#include "kern-modules.h"
int ret;
ret = kernctl_enable(event->fd);
- if (ret < 0 && errno != EEXIST) {
- PERROR("enable kernel event");
+ if (ret < 0) {
+ switch (errno) {
+ case EEXIST:
+ ret = LTTCOMM_KERN_EVENT_EXIST;
+ break;
+ default:
+ PERROR("enable kernel event");
+ break;
+ }
goto error;
}
int ret;
ret = kernctl_disable(event->fd);
- if (ret < 0 && errno != EEXIST) {
- PERROR("disable kernel event");
+ if (ret < 0) {
+ switch (errno) {
+ case EEXIST:
+ ret = LTTCOMM_KERN_EVENT_EXIST;
+ break;
+ default:
+ PERROR("disable kernel event");
+ break;
+ }
goto error;
}
#include "utils.h"
enum cmd_error_code {
- CMD_SUCCESS,
+ CMD_SUCCESS = 0,
CMD_ERROR,
CMD_UNDEFINED,
CMD_FATAL,
#include "../command.h"
#include "../utils.h"
+#include <common/sessiond-comm/sessiond-comm.h>
+
static char *opt_output_path;
static char *opt_session_name;
ret = lttng_create_session(session_name, traces_path);
if (ret < 0) {
/* Don't set ret so lttng can interpret the sessiond error. */
+ switch (-ret) {
+ case LTTCOMM_EXIST_SESS:
+ WARN("Session %s already exists", session_name);
+ break;
+ }
goto error;
}
#include "../command.h"
+#include <common/sessiond-comm/sessiond-comm.h>
+
static char *opt_session_name;
enum {
ret = lttng_destroy_session(session_name);
if (ret < 0) {
- /* Don't set ret so lttng can interpret the sessiond error. */
+ switch (-ret) {
+ case LTTCOMM_SESS_NOT_FOUND:
+ WARN("Session name %s not found", session_name);
+ break;
+ default:
+ break;
+ }
goto free_name;
}
#include "../command.h"
+#include <src/common/sessiond-comm/sessiond-comm.h>
+
static char *opt_channels;
static int opt_kernel;
static char *opt_session_name;
ret = lttng_enable_channel(handle, &chan);
if (ret < 0) {
- ERR("Channel %s: %s (session %s)", channel_name,
- lttng_strerror(ret), session_name);
+ switch (-ret) {
+ case LTTCOMM_KERN_CHAN_EXIST:
+ case LTTCOMM_UST_CHAN_EXIST:
+ WARN("Channel %s: %s (session %s", channel_name,
+ lttng_strerror(ret), session_name);
+ goto error;
+ default:
+ ERR("Channel %s: %s (session %s)", channel_name,
+ lttng_strerror(ret), session_name);
+ break;
+ }
warn = 1;
} else {
MSG("%s channel %s enabled for session %s",
#include <ctype.h>
#include "../command.h"
+#include <src/common/sessiond-comm/sessiond-comm.h>
static char *opt_event_list;
static int opt_event_type;
ret = lttng_enable_event(handle, &ev, channel_name);
if (ret < 0) {
- goto error;
+ switch (-ret) {
+ case LTTCOMM_KERN_EVENT_EXIST:
+ WARN("Kernel events already enabled (channel %s, session %s)",
+ channel_name, session_name);
+ goto end;
+ default:
+ ERR("Event %s: %s (channel %s, session %s)", event_name,
+ lttng_strerror(ret), channel_name, session_name);
+ break;
+ }
}
switch (opt_event_type) {
ret = lttng_enable_event(handle, &ev, channel_name);
if (ret < 0) {
- ERR("Event %s: %s (channel %s, session %s)", event_name,
- lttng_strerror(ret), channel_name, session_name);
+ /* Turn ret to positive value to handle the positive error code */
+ switch (-ret) {
+ case LTTCOMM_KERN_EVENT_EXIST:
+ WARN("Kernel event %s already enabled (channel %s, session %s)",
+ event_name, channel_name, session_name);
+ break;
+ default:
+ ERR("Event %s: %s (channel %s, session %s)", event_name,
+ lttng_strerror(ret), channel_name, session_name);
+ break;
+ }
warn = 1;
} else {
MSG("%s event %s created in channel %s",
#include "../command.h"
+#include <common/sessiond-comm/sessiond-comm.h>
+
static char *opt_session_name;
enum {
ret = lttng_start_tracing(session_name);
if (ret < 0) {
- /* Don't set ret so lttng can interpret the sessiond error. */
+ switch (-ret) {
+ case LTTCOMM_TRACE_ALREADY_STARTED:
+ WARN("Tracing already started for session %s", session_name);
+ break;
+ default:
+ ERR("%s", lttng_strerror(ret));
+ break;
+ }
goto free_name;
}
#include "../command.h"
+#include <common/sessiond-comm/sessiond-comm.h>
+
static char *opt_session_name;
enum {
ret = lttng_stop_tracing(session_name);
if (ret < 0) {
- /* Don't set ret so lttng can interpret the sessiond error. */
+ switch (-ret) {
+ case LTTCOMM_TRACE_ALREADY_STOPPED:
+ WARN("Tracing already stopped for session %s", session_name);
+ break;
+ default:
+ ERR("%s", lttng_strerror(ret));
+ break;
+ }
goto free_name;
}
case 0:
break;
default:
- ERR("%s", lttng_strerror(ret));
+ if (ret < 0) {
+ ret = -ret;
+ }
break;
}
[ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_VERSION) ] = "Kernel tracer version is not compatible",
[ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_EVENT_EXIST) ] = "Kernel event already exists",
[ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_SESS_FAIL) ] = "Kernel create session failed",
+ [ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CHAN_EXIST) ] = "Kernel channel already exists",
[ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CHAN_FAIL) ] = "Kernel create channel failed",
[ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CHAN_NOT_FOUND) ] = "Kernel channel not found",
[ LTTCOMM_ERR_INDEX(LTTCOMM_KERN_CHAN_DISABLE_FAIL) ] = "Disable kernel channel failed",
* lttcomm error code.
*/
enum lttcomm_return_code {
- LTTCOMM_OK = 1000, /* Ok */
+ LTTCOMM_OK = 10, /* Ok */
LTTCOMM_ERR, /* Unknown Error */
LTTCOMM_UND, /* Undefine command */
LTTCOMM_NOT_IMPLEMENTED, /* Command not implemented */
LTTCOMM_KERN_VERSION, /* Kernel tracer version is not compatible */
LTTCOMM_KERN_EVENT_EXIST, /* Kernel event already exists */
LTTCOMM_KERN_SESS_FAIL, /* Kernel create session failed */
+ LTTCOMM_KERN_CHAN_EXIST, /* Kernel channel already exists */
LTTCOMM_KERN_CHAN_FAIL, /* Kernel create channel failed */
LTTCOMM_KERN_CHAN_NOT_FOUND, /* Kernel channel not found */
LTTCOMM_KERN_CHAN_DISABLE_FAIL, /* Kernel disable channel failed */