2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
5 * Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 #include <lttng/ust-error.h>
10 #define CODE_OFFSET(code) \
11 (code == LTTNG_UST_OK ? 0 : (code - LTTNG_UST_ERR + 1))
14 * Human readable error message.
16 static const char *ustcomm_readable_code
[] = {
17 [ CODE_OFFSET(LTTNG_UST_OK
) ] = "Success",
18 [ CODE_OFFSET(LTTNG_UST_ERR
) ] = "Unknown error",
19 [ CODE_OFFSET(LTTNG_UST_ERR_NOENT
) ] = "No entry",
20 [ CODE_OFFSET(LTTNG_UST_ERR_EXIST
) ] = "Object already exists",
21 [ CODE_OFFSET(LTTNG_UST_ERR_INVAL
) ] = "Invalid argument",
22 [ CODE_OFFSET(LTTNG_UST_ERR_PERM
) ] = "Permission denied",
23 [ CODE_OFFSET(LTTNG_UST_ERR_NOSYS
) ] = "Not implemented",
24 [ CODE_OFFSET(LTTNG_UST_ERR_EXITING
) ] = "Process is exiting",
26 [ CODE_OFFSET(LTTNG_UST_ERR_INVAL_MAGIC
) ] = "Invalid magic number",
27 [ CODE_OFFSET(LTTNG_UST_ERR_INVAL_SOCKET_TYPE
) ] = "Invalid socket type",
28 [ CODE_OFFSET(LTTNG_UST_ERR_UNSUP_MAJOR
) ] = "Unsupported major version",
29 [ CODE_OFFSET(LTTNG_UST_ERR_PEERCRED
) ] = "Cannot get unix socket peer credentials",
30 [ CODE_OFFSET(LTTNG_UST_ERR_PEERCRED_PID
) ] = "Peer credentials PID is invalid. Socket appears to belong to a distinct, non-nested pid namespace.",
35 * @code: must be a negative value of enum lttng_ust_error_code (or 0).
37 * Returns a ptr to a string representing a human readable error code from the
38 * ustcomm_return_code enum.
40 const char *lttng_ust_strerror(int code
)
44 if (code
< LTTNG_UST_OK
|| code
>= LTTNG_UST_ERR_NR
)
47 return ustcomm_readable_code
[CODE_OFFSET(code
)];