Support new lttng-ust error code
authorDavid Goulet <dgoulet@efficios.com>
Fri, 9 Nov 2012 18:37:25 +0000 (13:37 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 9 Nov 2012 18:37:25 +0000 (13:37 -0500)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/channel.c
src/bin/lttng-sessiond/event.c
src/bin/lttng-sessiond/filter.c
src/bin/lttng-sessiond/lttng-ust-error.h [new file with mode: 0644]
src/bin/lttng-sessiond/ust-app.c
src/bin/lttng-sessiond/ust-ctl.h

index e2cdf563a6bbc42f9cf6f583b323c8c25b6217b8..8b9adfba8370894050c5fd214c64c5282682fed8 100644 (file)
@@ -203,7 +203,7 @@ int channel_ust_enable(struct ltt_ust_session *usess, int domain,
        }
 
        if (ret < 0) {
-               if (ret != -EEXIST) {
+               if (ret != -LTTNG_UST_ERR_EXIST) {
                        ret = LTTNG_ERR_UST_CHAN_ENABLE_FAIL;
                        goto error;
                } else {
@@ -284,7 +284,7 @@ int channel_ust_create(struct ltt_ust_session *usess, int domain,
                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;
        }
@@ -341,7 +341,7 @@ int channel_ust_disable(struct ltt_ust_session *usess, int domain,
                goto error;
        }
 
-       if (ret < 0 && ret != -EEXIST) {
+       if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) {
                ret = LTTNG_ERR_UST_CHAN_DISABLE_FAIL;
                goto error;
        }
index 2173e414a0a015545478a671e3cd930f02b0bf83..a2e6c37effb853d43385cd5da1a4b89de11957c1 100644 (file)
@@ -343,7 +343,7 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain,
                                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;
                                        }
@@ -362,7 +362,7 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int domain,
                        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 {
@@ -455,7 +455,7 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, int domain,
                }
 
                if (ret < 0) {
-                       if (ret == -EEXIST) {
+                       if (ret == -LTTNG_UST_ERR_EXIST) {
                                ret = LTTNG_ERR_UST_EVENT_EXIST;
                                goto end;
                        } else {
@@ -529,7 +529,7 @@ int event_ust_disable_tracepoint(struct ltt_ust_session *usess, int domain,
        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;
                }
@@ -594,7 +594,7 @@ int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, int domain,
                        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;
                                }
index f0acffdc1dfc3287f6892253f59bc862711cd80c..e887533050f8a5f298bbcd7944f63fac59eef416 100644 (file)
@@ -155,17 +155,21 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain,
        }
 
 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:
diff --git a/src/bin/lttng-sessiond/lttng-ust-error.h b/src/bin/lttng-sessiond/lttng-ust-error.h
new file mode 100644 (file)
index 0000000..d83ecb8
--- /dev/null
@@ -0,0 +1,56 @@
+#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 */
index fc0d53787dd6a5d0ff2d8fe9faf5714bc2362951..2ebf79d2828c251da2d2e16469a33e3aed01906f 100644 (file)
@@ -734,10 +734,10 @@ int create_ust_event(struct ust_app *app, struct ust_app_session *ua_sess,
                         * 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;
@@ -1223,7 +1223,7 @@ static struct ust_app_channel *create_ust_app_channel(
        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;
        }
 
@@ -1274,7 +1274,7 @@ int create_ust_app_event(struct ust_app_session *ua_sess,
        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;
        }
 
@@ -2143,7 +2143,7 @@ int ust_app_create_event_glb(struct ltt_ust_session *usess,
 
                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;
                        }
index fd0fc7ad0a006fb22e3428025b6fe012c25dff50..f3494d6c376021bb17b2723acfc40c225ab9ff52 100644 (file)
 #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 */
This page took 0.042854 seconds and 4 git commands to generate.