}
if (ret < 0) {
- if (ret != -EEXIST) {
+ if (ret != -LTTNG_UST_ERR_EXIST) {
ret = LTTNG_ERR_UST_CHAN_ENABLE_FAIL;
goto error;
} else {
goto error_free_chan;
}
- if (ret < 0 && ret != -EEXIST) {
+ if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) {
ret = LTTNG_ERR_UST_CHAN_FAIL;
goto error_free_chan;
}
goto error;
}
- if (ret < 0 && ret != -EEXIST) {
+ if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) {
ret = LTTNG_ERR_UST_CHAN_DISABLE_FAIL;
goto error;
}
ret = ust_app_enable_event_pid(usess, uchan, uevent,
events[i].pid);
if (ret < 0) {
- if (ret != -EEXIST) {
+ if (ret != -LTTNG_UST_ERR_EXIST) {
ret = LTTNG_ERR_UST_ENABLE_FAIL;
goto error;
}
ret = ust_app_enable_event_pid(usess, uchan, uevent,
events[i].pid);
if (ret < 0) {
- if (ret == -EEXIST) {
+ if (ret == -LTTNG_UST_ERR_EXIST) {
ret = LTTNG_ERR_UST_EVENT_EXIST;
goto error;
} else {
}
if (ret < 0) {
- if (ret == -EEXIST) {
+ if (ret == -LTTNG_UST_ERR_EXIST) {
ret = LTTNG_ERR_UST_EVENT_EXIST;
goto end;
} else {
switch (domain) {
case LTTNG_DOMAIN_UST:
ret = ust_app_disable_event_glb(usess, uchan, uevent);
- if (ret < 0 && ret != -EEXIST) {
+ if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) {
ret = LTTNG_ERR_UST_DISABLE_FAIL;
goto error;
}
if (uevent != NULL && uevent->enabled == 1) {
ret = ust_app_disable_event_pid(usess, uchan, uevent,
events[i].pid);
- if (ret < 0 && ret != -EEXIST) {
+ if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) {
ret = LTTNG_ERR_UST_DISABLE_FAIL;
goto error;
}
}
end:
+ /* Must handle both local internal error and UST code. */
switch (ret) {
case -EEXIST:
+ case -LTTNG_UST_ERR_EXIST:
ret = LTTNG_ERR_FILTER_EXIST;
break;
case -ENOMEM:
ret = LTTNG_ERR_FATAL;
break;
case -EINVAL:
+ case -LTTNG_UST_ERR_INVAL:
ret = LTTNG_ERR_FILTER_INVAL;
break;
case -ENOSYS:
+ case -LTTNG_UST_ERR_NOSYS:
ret = LTTNG_ERR_UNKNOWN_DOMAIN;
break;
default:
--- /dev/null
+#ifndef _LTTNG_UST_ERROR_H
+#define _LTTNG_UST_ERROR_H
+
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ * Julien Desfossez <julien.desfossez@polymtl.ca>
+ * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * This header is meant for liblttng and libust internal use ONLY.
+ * These declarations should NOT be considered stable API.
+ */
+
+#include <limits.h>
+#include <unistd.h>
+
+#include "lttng-ust-abi.h"
+
+/*
+ * ustcomm error code.
+ */
+enum lttng_ust_error_code {
+ LTTNG_UST_OK = 0, /* Ok */
+ LTTNG_UST_ERR = 1024, /* Unknown Error */
+ LTTNG_UST_ERR_NOENT = 1025, /* No entry */
+ LTTNG_UST_ERR_EXIST = 1026, /* Object exists */
+ LTTNG_UST_ERR_INVAL = 1027, /* Invalid argument */
+ LTTNG_UST_ERR_PERM = 1028, /* Permission denied */
+ LTTNG_UST_ERR_NOSYS = 1029, /* Not implemented */
+
+ /* MUST be last element */
+ LTTNG_UST_ERR_NR, /* Last element */
+};
+
+/*
+ * Return a human-readable error message for an lttng-ust error code.
+ * code must be a positive value (or 0).
+ */
+extern const char *lttng_ust_strerror(int code);
+
+#endif /* _LTTNG_UST_ERROR_H */
* just created it.
*/
switch (ret) {
- case -EPERM:
+ case -LTTNG_UST_ERR_PERM:
/* Code flow problem */
assert(0);
- case -EEXIST:
+ case -LTTNG_UST_ERR_EXIST:
/* It's OK for our use case. */
ret = 0;
break;
ret = create_ust_channel(app, ua_sess, ua_chan);
if (ret < 0) {
/* Not found previously means that it does not exist on the tracer */
- assert(ret != -EEXIST);
+ assert(ret != -LTTNG_UST_ERR_EXIST);
goto error;
}
ret = create_ust_event(app, ua_sess, ua_chan, ua_event);
if (ret < 0) {
/* Not found previously means that it does not exist on the tracer */
- assert(ret != -EEXIST);
+ assert(ret == -LTTNG_UST_ERR_EXIST);
goto error;
}
ret = create_ust_app_event(ua_sess, ua_chan, uevent, app);
if (ret < 0) {
- if (ret != -EEXIST) {
+ if (ret != -LTTNG_UST_ERR_EXIST) {
/* Possible value at this point: -ENOMEM. If so, we stop! */
break;
}
#ifdef HAVE_LIBLTTNG_UST_CTL
#include <lttng/ust-ctl.h>
#include <lttng/ust-abi.h>
+#include <lttng/ust-error.h>
#else
#include "lttng-ust-ctl.h"
#include "lttng-ust-abi.h"
+#include "lttng-ust-error.h"
#endif
#endif /* _LTT_UST_CTL_H */