summaryrefslogtreecommitdiffstats
path: root/lib/e2p/errcode.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:49:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:49:25 +0000
commit464df1d5e5ab1322e2dd0a7796939fff1aeefa9a (patch)
tree6a403684e0978f0287d7f0ec0e5aab1fd31a59e1 /lib/e2p/errcode.c
parentInitial commit. (diff)
downloade2fsprogs-464df1d5e5ab1322e2dd0a7796939fff1aeefa9a.tar.xz
e2fsprogs-464df1d5e5ab1322e2dd0a7796939fff1aeefa9a.zip
Adding upstream version 1.47.0.upstream/1.47.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/e2p/errcode.c')
-rw-r--r--lib/e2p/errcode.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/e2p/errcode.c b/lib/e2p/errcode.c
new file mode 100644
index 0000000..1627c9d
--- /dev/null
+++ b/lib/e2p/errcode.c
@@ -0,0 +1,48 @@
+/*
+ * errcode.c - convert an error code to a string
+ */
+
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "e2p.h"
+
+static const char *err_string[] = {
+ "",
+ "UNKNOWN", /* 1 */
+ "EIO", /* 2 */
+ "ENOMEM", /* 3 */
+ "EFSBADCRC", /* 4 */
+ "EFSCORRUPTED", /* 5 */
+ "ENOSPC", /* 6 */
+ "ENOKEY", /* 7 */
+ "EROFS", /* 8 */
+ "EFBIG", /* 9 */
+ "EEXIST", /* 10 */
+ "ERANGE", /* 11 */
+ "EOVERFLOW", /* 12 */
+ "EBUSY", /* 13 */
+ "ENOTDIR", /* 14 */
+ "ENOTEMPTY", /* 15 */
+ "ESHUTDOWN", /* 16 */
+ "EFAULT", /* 17 */
+};
+
+#define ARRAY_SIZE(array) \
+ (sizeof(array) / sizeof(array[0]))
+
+/* Return the name of an encoding or NULL */
+const char *e2p_errcode2str(unsigned int err)
+{
+ static char buf[32];
+
+ if (err < ARRAY_SIZE(err_string))
+ return err_string[err];
+
+ sprintf(buf, "UNKNOWN_ERRCODE_%u", err);
+ return buf;
+}
+
+