2021-10-09 | Paul Boddie | file changeset files shortlog | Updated libext2fs to version 1.46.2, also introducing some notes about the process of adapting the library for L4Re, together with a tool to generate a configuration from an existing, external "host" build of the library. |
paul@212 | 1 | /* |
paul@212 | 2 | * errcode.c - convert an error code to a string |
paul@212 | 3 | */ |
paul@212 | 4 | |
paul@212 | 5 | #include "config.h" |
paul@212 | 6 | #include <stdio.h> |
paul@212 | 7 | #include <stdlib.h> |
paul@212 | 8 | #include <string.h> |
paul@212 | 9 | |
paul@212 | 10 | static const char *err_string[] = { |
paul@212 | 11 | "", |
paul@212 | 12 | "UNKNOWN", /* 1 */ |
paul@212 | 13 | "EIO", /* 2 */ |
paul@212 | 14 | "ENOMEM", /* 3 */ |
paul@212 | 15 | "EFSBADCRC", /* 4 */ |
paul@212 | 16 | "EFSCORRUPTED", /* 5 */ |
paul@212 | 17 | "ENOSPC", /* 6 */ |
paul@212 | 18 | "ENOKEY", /* 7 */ |
paul@212 | 19 | "EROFS", /* 8 */ |
paul@212 | 20 | "EFBIG", /* 9 */ |
paul@212 | 21 | "EEXIST", /* 10 */ |
paul@212 | 22 | "ERANGE", /* 11 */ |
paul@212 | 23 | "EOVERFLOW", /* 12 */ |
paul@212 | 24 | "EBUSY", /* 13 */ |
paul@212 | 25 | "ENOTDIR", /* 14 */ |
paul@212 | 26 | "ENOTEMPTY", /* 15 */ |
paul@212 | 27 | "ESHUTDOWN", /* 16 */ |
paul@212 | 28 | "EFAULT", /* 17 */ |
paul@212 | 29 | }; |
paul@212 | 30 | |
paul@212 | 31 | #define ARRAY_SIZE(array) \ |
paul@212 | 32 | (sizeof(array) / sizeof(array[0])) |
paul@212 | 33 | |
paul@212 | 34 | /* Return the name of an encoding or NULL */ |
paul@212 | 35 | const char *e2p_errcode2str(int err) |
paul@212 | 36 | { |
paul@212 | 37 | unsigned int i; |
paul@212 | 38 | static char buf[32]; |
paul@212 | 39 | |
paul@212 | 40 | if (err < ARRAY_SIZE(err_string)) |
paul@212 | 41 | return err_string[err]; |
paul@212 | 42 | |
paul@212 | 43 | sprintf(buf, "UNKNOWN_ERRCODE_%d", err); |
paul@212 | 44 | return buf; |
paul@212 | 45 | } |
paul@212 | 46 | |
paul@212 | 47 |