1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright (C) 2014 Samsung Electronics
3*4882a593Smuzhiyun * Przemyslaw Marczak <p.marczak@samsung.com>
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * SDPX-License-Identifier: GPL-2.0+
6*4882a593Smuzhiyun */
7*4882a593Smuzhiyun #include <common.h>
8*4882a593Smuzhiyun #include <errno.h>
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun #define ERRNO_MSG(errno, msg) msg
11*4882a593Smuzhiyun #define SAME_AS(x) (const char *)&errno_message[x]
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun static const char * const errno_message[] = {
14*4882a593Smuzhiyun ERRNO_MSG(0, "Success"),
15*4882a593Smuzhiyun ERRNO_MSG(EPERM, "Operation not permitted"),
16*4882a593Smuzhiyun ERRNO_MSG(ENOEN, "No such file or directory"),
17*4882a593Smuzhiyun ERRNO_MSG(ESRCH, "No such process"),
18*4882a593Smuzhiyun ERRNO_MSG(EINTR, "Interrupted system call"),
19*4882a593Smuzhiyun ERRNO_MSG(EIO, "I/O error"),
20*4882a593Smuzhiyun ERRNO_MSG(ENXIO, "No such device or address"),
21*4882a593Smuzhiyun ERRNO_MSG(E2BIG, "Argument list too long"),
22*4882a593Smuzhiyun ERRNO_MSG(ENOEXEC, "Exec format error"),
23*4882a593Smuzhiyun ERRNO_MSG(EBADF, "Bad file number"),
24*4882a593Smuzhiyun ERRNO_MSG(ECHILD, "No child processes"),
25*4882a593Smuzhiyun ERRNO_MSG(EAGAIN, "Try again"),
26*4882a593Smuzhiyun ERRNO_MSG(ENOMEM, "Out of memory"),
27*4882a593Smuzhiyun ERRNO_MSG(EACCES, "Permission denied"),
28*4882a593Smuzhiyun ERRNO_MSG(EFAULT, "Bad address"),
29*4882a593Smuzhiyun ERRNO_MSG(ENOTBL, "Block device required"),
30*4882a593Smuzhiyun ERRNO_MSG(EBUSY, "Device or resource busy"),
31*4882a593Smuzhiyun ERRNO_MSG(EEXIST, "File exists"),
32*4882a593Smuzhiyun ERRNO_MSG(EXDEV, "Cross-device link"),
33*4882a593Smuzhiyun ERRNO_MSG(ENODEV, "No such device"),
34*4882a593Smuzhiyun ERRNO_MSG(ENOTDIR, "Not a directory"),
35*4882a593Smuzhiyun ERRNO_MSG(EISDIR, "Is a directory"),
36*4882a593Smuzhiyun ERRNO_MSG(EINVAL, "Invalid argument"),
37*4882a593Smuzhiyun ERRNO_MSG(ENFILE, "File table overflow"),
38*4882a593Smuzhiyun ERRNO_MSG(EMFILE, "Too many open files"),
39*4882a593Smuzhiyun ERRNO_MSG(ENOTTY, "Not a typewriter"),
40*4882a593Smuzhiyun ERRNO_MSG(ETXTBSY, "Text file busy"),
41*4882a593Smuzhiyun ERRNO_MSG(EFBIG, "File too large"),
42*4882a593Smuzhiyun ERRNO_MSG(ENOSPC, "No space left on device"),
43*4882a593Smuzhiyun ERRNO_MSG(ESPIPE, "Illegal seek"),
44*4882a593Smuzhiyun ERRNO_MSG(EROFS, "Read-only file system"),
45*4882a593Smuzhiyun ERRNO_MSG(EMLINK, "Too many links"),
46*4882a593Smuzhiyun ERRNO_MSG(EPIPE, "Broken pipe"),
47*4882a593Smuzhiyun ERRNO_MSG(EDOM, "Math argument out of domain of func"),
48*4882a593Smuzhiyun ERRNO_MSG(ERANGE, "Math result not representable"),
49*4882a593Smuzhiyun ERRNO_MSG(EDEADLK, "Resource deadlock would occur"),
50*4882a593Smuzhiyun ERRNO_MSG(ENAMETOOLONG, "File name too long"),
51*4882a593Smuzhiyun ERRNO_MSG(ENOLCK, "No record locks available"),
52*4882a593Smuzhiyun ERRNO_MSG(ENOSYS, "Function not implemented"),
53*4882a593Smuzhiyun ERRNO_MSG(ENOTEMPTY, "Directory not empty"),
54*4882a593Smuzhiyun ERRNO_MSG(ELOOP, "Too many symbolic links encountered"),
55*4882a593Smuzhiyun ERRNO_MSG(EWOULDBLOCK, SAME_AS(EAGAIN)),
56*4882a593Smuzhiyun ERRNO_MSG(ENOMSG, "No message of desired type"),
57*4882a593Smuzhiyun ERRNO_MSG(EIDRM, "Identifier removed"),
58*4882a593Smuzhiyun ERRNO_MSG(ECHRNG, "Channel number out of range"),
59*4882a593Smuzhiyun ERRNO_MSG(EL2NSYNC, "Level 2 not synchronized"),
60*4882a593Smuzhiyun ERRNO_MSG(EL3HLT, "Level 3 halted"),
61*4882a593Smuzhiyun ERRNO_MSG(EL3RST, "Level 3 reset"),
62*4882a593Smuzhiyun ERRNO_MSG(ELNRNG, "Link number out of range"),
63*4882a593Smuzhiyun ERRNO_MSG(EUNATCH, "Protocol driver not attached"),
64*4882a593Smuzhiyun ERRNO_MSG(ENOCSI, "No CSI structure available"),
65*4882a593Smuzhiyun ERRNO_MSG(EL2HLT, "Level 2 halted"),
66*4882a593Smuzhiyun ERRNO_MSG(EBADE, "Invalid exchange"),
67*4882a593Smuzhiyun ERRNO_MSG(EBADR, "Invalid request descriptor"),
68*4882a593Smuzhiyun ERRNO_MSG(EXFULL, "Exchange full"),
69*4882a593Smuzhiyun ERRNO_MSG(ENOANO, "No anode"),
70*4882a593Smuzhiyun ERRNO_MSG(EBADRQC, "Invalid request code"),
71*4882a593Smuzhiyun ERRNO_MSG(EBADSLT, "Invalid slot"),
72*4882a593Smuzhiyun ERRNO_MSG(EDEADLOCK, SAME_AS(EDEADLK)),
73*4882a593Smuzhiyun ERRNO_MSG(EBFONT, "Bad font file format"),
74*4882a593Smuzhiyun ERRNO_MSG(ENOSTR, "Device not a stream"),
75*4882a593Smuzhiyun ERRNO_MSG(ENODATA, "No data available"),
76*4882a593Smuzhiyun ERRNO_MSG(ETIME, "Timer expired"),
77*4882a593Smuzhiyun ERRNO_MSG(ENOSR, "Out of streams resources"),
78*4882a593Smuzhiyun ERRNO_MSG(ENONET, "Machine is not on the network"),
79*4882a593Smuzhiyun ERRNO_MSG(ENOPKG, "Package not installed"),
80*4882a593Smuzhiyun ERRNO_MSG(EREMOTE, "Object is remote"),
81*4882a593Smuzhiyun ERRNO_MSG(ENOLINK, "Link has been severed"),
82*4882a593Smuzhiyun ERRNO_MSG(EADV, "Advertise error"),
83*4882a593Smuzhiyun ERRNO_MSG(ESRMNT, "Srmount error"),
84*4882a593Smuzhiyun ERRNO_MSG(ECOMM, "Communication error on send"),
85*4882a593Smuzhiyun ERRNO_MSG(EPROTO, "Protocol error"),
86*4882a593Smuzhiyun ERRNO_MSG(EMULTIHOP, "Multihop attempted"),
87*4882a593Smuzhiyun ERRNO_MSG(EDOTDOT, "RFS specific error"),
88*4882a593Smuzhiyun ERRNO_MSG(EBADMSG, "Not a data message"),
89*4882a593Smuzhiyun ERRNO_MSG(EOVERFLOW, "Value too large for defined data type"),
90*4882a593Smuzhiyun ERRNO_MSG(ENOTUNIQ, "Name not unique on network"),
91*4882a593Smuzhiyun ERRNO_MSG(EBADFD, "File descriptor in bad state"),
92*4882a593Smuzhiyun ERRNO_MSG(EREMCHG, "Remote address changed"),
93*4882a593Smuzhiyun ERRNO_MSG(ELIBACC, "Can not access a needed shared library"),
94*4882a593Smuzhiyun ERRNO_MSG(ELIBBAD, "Accessing a corrupted shared library"),
95*4882a593Smuzhiyun ERRNO_MSG(ELIBSCN, ".lib section in a.out corrupted"),
96*4882a593Smuzhiyun ERRNO_MSG(ELIBMAX, "Attempting to link in too many shared libraries"),
97*4882a593Smuzhiyun ERRNO_MSG(ELIBEXEC, "Cannot exec a shared library directly"),
98*4882a593Smuzhiyun ERRNO_MSG(EILSEQ, "Illegal byte sequence"),
99*4882a593Smuzhiyun ERRNO_MSG(ERESTART, "Interrupted system call should be restarted"),
100*4882a593Smuzhiyun ERRNO_MSG(ESTRPIPE, "Streams pipe error"),
101*4882a593Smuzhiyun ERRNO_MSG(EUSERS, "Too many users"),
102*4882a593Smuzhiyun ERRNO_MSG(ENOTSOCK, "Socket operation on non-socket"),
103*4882a593Smuzhiyun ERRNO_MSG(EDESTADDRREQ, "Destination address required"),
104*4882a593Smuzhiyun ERRNO_MSG(EMSGSIZE, "Message too long"),
105*4882a593Smuzhiyun ERRNO_MSG(EPROTOTYPE, "Protocol wrong type for socket"),
106*4882a593Smuzhiyun ERRNO_MSG(ENOPROTOOPT, "Protocol not available"),
107*4882a593Smuzhiyun ERRNO_MSG(EPROTONOSUPPORT, "Protocol not supported"),
108*4882a593Smuzhiyun ERRNO_MSG(ESOCKTNOSUPPORT, "Socket type not supported"),
109*4882a593Smuzhiyun ERRNO_MSG(EOPNOTSUPP, "Operation not supported on transport endpoint"),
110*4882a593Smuzhiyun ERRNO_MSG(EPFNOSUPPORT, "Protocol family not supported"),
111*4882a593Smuzhiyun ERRNO_MSG(AFNOSUPPORT, "Address family not supported by protocol"),
112*4882a593Smuzhiyun ERRNO_MSG(EADDRINUSE, "Address already in use"),
113*4882a593Smuzhiyun ERRNO_MSG(EADDRNOTAVAIL, "Cannot assign requested address"),
114*4882a593Smuzhiyun ERRNO_MSG(ENETDOWN, "Network is down"),
115*4882a593Smuzhiyun ERRNO_MSG(ENETUNREACH, "Network is unreachable"),
116*4882a593Smuzhiyun ERRNO_MSG(ENETRESET, "Network dropped connection because of reset"),
117*4882a593Smuzhiyun ERRNO_MSG(ECONNABORTED, "Software caused connection abort"),
118*4882a593Smuzhiyun ERRNO_MSG(ECONNRESET, "Connection reset by peer"),
119*4882a593Smuzhiyun ERRNO_MSG(ENOBUFS, "No buffer space available"),
120*4882a593Smuzhiyun ERRNO_MSG(EISCONN, "Transport endpoint is already connected"),
121*4882a593Smuzhiyun ERRNO_MSG(ENOTCONN, "Transport endpoint is not connected"),
122*4882a593Smuzhiyun ERRNO_MSG(ESHUTDOWN, "Cannot send after transport endpoint shutdown"),
123*4882a593Smuzhiyun ERRNO_MSG(ETOOMANYREFS, "Too many references: cannot splice"),
124*4882a593Smuzhiyun ERRNO_MSG(ETIMEDOUT, "Connection timed out"),
125*4882a593Smuzhiyun ERRNO_MSG(ECONNREFUSED, "Connection refused"),
126*4882a593Smuzhiyun ERRNO_MSG(EHOSTDOWN, "Host is down"),
127*4882a593Smuzhiyun ERRNO_MSG(EHOSTUNREACH, "No route to host"),
128*4882a593Smuzhiyun ERRNO_MSG(EALREADY, "Operation already in progress"),
129*4882a593Smuzhiyun ERRNO_MSG(EINPROGRESS, "Operation now in progress"),
130*4882a593Smuzhiyun ERRNO_MSG(ESTALE, "Stale NFS file handle"),
131*4882a593Smuzhiyun ERRNO_MSG(EUCLEAN, "Structure needs cleaning"),
132*4882a593Smuzhiyun ERRNO_MSG(ENOTNAM, "Not a XENIX named type file"),
133*4882a593Smuzhiyun ERRNO_MSG(ENAVAIL, "No XENIX semaphores available"),
134*4882a593Smuzhiyun ERRNO_MSG(EISNAM, "Is a named type file"),
135*4882a593Smuzhiyun ERRNO_MSG(EREMOTEIO, "Remote I/O error"),
136*4882a593Smuzhiyun ERRNO_MSG(EDQUOT, "Quota exceeded"),
137*4882a593Smuzhiyun ERRNO_MSG(ENOMEDIUM, "No medium found"),
138*4882a593Smuzhiyun ERRNO_MSG(EMEDIUMTYPE, "Wrong medium type"),
139*4882a593Smuzhiyun };
140*4882a593Smuzhiyun
errno_str(int errno)141*4882a593Smuzhiyun const char *errno_str(int errno)
142*4882a593Smuzhiyun {
143*4882a593Smuzhiyun if (errno >= 0)
144*4882a593Smuzhiyun return errno_message[0];
145*4882a593Smuzhiyun
146*4882a593Smuzhiyun return errno_message[abs(errno)];
147*4882a593Smuzhiyun }
148