Add libc errno translation layer to UST error code
authorDavid Goulet <dgoulet@efficios.com>
Fri, 9 Nov 2012 18:20:46 +0000 (13:20 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 9 Nov 2012 18:20:46 +0000 (13:20 -0500)
Also add four new possible code being EEXIST, EINVAL, ENOSYS and EPERM.

Signed-off-by: David Goulet <dgoulet@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ust-error.h
liblttng-ust-comm/lttng-ust-comm.c
liblttng-ust/lttng-ust-comm.c

index 49890a965db426b7488c6577b45e843c5c51ee5e..0c46c904d0639007053d63691ed200192b6ec356 100644 (file)
 enum lttng_ust_error_code {
        LTTNG_UST_OK = 0,                       /* Ok */
        LTTNG_UST_ERR = 1024,                   /* Unknown Error */
-       LTTNG_UST_ERR_NOENT,                    /* No entry */
+       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 */
index 8765ea6eee0a109a1231e51b8147b5047749bd72..9a67ea19ea7aef43d80e4558dfeeae4162b42616 100644 (file)
@@ -44,6 +44,10 @@ static const char *ustcomm_readable_code[] = {
        [ USTCOMM_CODE_OFFSET(LTTNG_UST_OK) ] = "Success",
        [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR) ] = "Unknown error",
        [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_NOENT) ] = "No entry",
+       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_EXIST) ] = "Object already exists",
+       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_INVAL) ] = "Invalid argument",
+       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_PERM) ] = "Permission denied",
+       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_NOSYS) ] = "Not implemented",
 };
 
 /*
index f11b7d0142a3b210fa6bfd2ce2c606bba83f93ed..92d0fd70da205ecad68d9da6a963d94eda728422 100644 (file)
@@ -376,10 +376,31 @@ end:
                 * we already have a more precise error message to
                 * report.
                 */
-               if (ret > -LTTNG_UST_ERR)
-                       lur.ret_code = -LTTNG_UST_ERR;
-               else
+               if (ret > -LTTNG_UST_ERR) {
+                       /* Translate code to UST error. */
+                       switch (ret) {
+                       case -EEXIST:
+                               lur.ret_code = -LTTNG_UST_ERR_EXIST;
+                               break;
+                       case -EINVAL:
+                               lur.ret_code = -LTTNG_UST_ERR_INVAL;
+                               break;
+                       case -ENOENT:
+                               lur.ret_code = -LTTNG_UST_ERR_NOENT;
+                               break;
+                       case -EPERM:
+                               lur.ret_code = -LTTNG_UST_ERR_PERM;
+                               break;
+                       case -ENOSYS:
+                               lur.ret_code = -LTTNG_UST_ERR_NOSYS;
+                               break;
+                       default:
+                               lur.ret_code = -LTTNG_UST_ERR;
+                               break;
+                       }
+               } else {
                        lur.ret_code = ret;
+               }
        }
        if (ret >= 0) {
                switch (lum->cmd) {
This page took 0.026533 seconds and 4 git commands to generate.