1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
// Code generated by mksysnum_linux.py; DO NOT EDIT.

use crate::syscalls::Errno;

pub const EPERM: Errno = 1;
pub const ENOENT: Errno = 2;
pub const ESRCH: Errno = 3;
pub const EINTR: Errno = 4;
pub const EIO: Errno = 5;
pub const ENXIO: Errno = 6;
pub const E2BIG: Errno = 7;
pub const ENOEXEC: Errno = 8;
pub const EBADF: Errno = 9;
pub const ECHILD: Errno = 10;
pub const EAGAIN: Errno = 11;
pub const ENOMEM: Errno = 12;
pub const EACCES: Errno = 13;
pub const EFAULT: Errno = 14;
pub const ENOTBLK: Errno = 15;
pub const EBUSY: Errno = 16;
pub const EEXIST: Errno = 17;
pub const EXDEV: Errno = 18;
pub const ENODEV: Errno = 19;
pub const ENOTDIR: Errno = 20;
pub const EISDIR: Errno = 21;
pub const EINVAL: Errno = 22;
pub const ENFILE: Errno = 23;
pub const EMFILE: Errno = 24;
pub const ENOTTY: Errno = 25;
pub const ETXTBSY: Errno = 26;
pub const EFBIG: Errno = 27;
pub const ENOSPC: Errno = 28;
pub const ESPIPE: Errno = 29;
pub const EROFS: Errno = 30;
pub const EMLINK: Errno = 31;
pub const EPIPE: Errno = 32;
pub const EDOM: Errno = 33;
pub const ERANGE: Errno = 34;
pub const EDEADLK: Errno = 35;
pub const ENAMETOOLONG: Errno = 36;
pub const ENOLCK: Errno = 37;
pub const ENOSYS: Errno = 38;
pub const ENOTEMPTY: Errno = 39;
pub const ELOOP: Errno = 40;
pub const EWOULDBLOCK: Errno = EAGAIN;
pub const ENOMSG: Errno = 42;
pub const EIDRM: Errno = 43;
pub const ECHRNG: Errno = 44;
pub const EL2NSYNC: Errno = 45;
pub const EL3HLT: Errno = 46;
pub const EL3RST: Errno = 47;
pub const ELNRNG: Errno = 48;
pub const EUNATCH: Errno = 49;
pub const ENOCSI: Errno = 50;
pub const EL2HLT: Errno = 51;
pub const EBADE: Errno = 52;
pub const EBADR: Errno = 53;
pub const EXFULL: Errno = 54;
pub const ENOANO: Errno = 55;
pub const EBADRQC: Errno = 56;
pub const EBADSLT: Errno = 57;
pub const EDEADLOCK: Errno = EDEADLK;
pub const EBFONT: Errno = 59;
pub const ENOSTR: Errno = 60;
pub const ENODATA: Errno = 61;
pub const ETIME: Errno = 62;
pub const ENOSR: Errno = 63;
pub const ENONET: Errno = 64;
pub const ENOPKG: Errno = 65;
pub const EREMOTE: Errno = 66;
pub const ENOLINK: Errno = 67;
pub const EADV: Errno = 68;
pub const ESRMNT: Errno = 69;
pub const ECOMM: Errno = 70;
pub const EPROTO: Errno = 71;
pub const EMULTIHOP: Errno = 72;
pub const EDOTDOT: Errno = 73;
pub const EBADMSG: Errno = 74;
pub const EOVERFLOW: Errno = 75;
pub const ENOTUNIQ: Errno = 76;
pub const EBADFD: Errno = 77;
pub const EREMCHG: Errno = 78;
pub const ELIBACC: Errno = 79;
pub const ELIBBAD: Errno = 80;
pub const ELIBSCN: Errno = 81;
pub const ELIBMAX: Errno = 82;
pub const ELIBEXEC: Errno = 83;
pub const EILSEQ: Errno = 84;
pub const ERESTART: Errno = 85;
pub const ESTRPIPE: Errno = 86;
pub const EUSERS: Errno = 87;
pub const ENOTSOCK: Errno = 88;
pub const EDESTADDRREQ: Errno = 89;
pub const EMSGSIZE: Errno = 90;
pub const EPROTOTYPE: Errno = 91;
pub const ENOPROTOOPT: Errno = 92;
pub const EPROTONOSUPPORT: Errno = 93;
pub const ESOCKTNOSUPPORT: Errno = 94;
pub const EOPNOTSUPP: Errno = 95;
pub const EPFNOSUPPORT: Errno = 96;
pub const EAFNOSUPPORT: Errno = 97;
pub const EADDRINUSE: Errno = 98;
pub const EADDRNOTAVAIL: Errno = 99;
pub const ENETDOWN: Errno = 100;
pub const ENETUNREACH: Errno = 101;
pub const ENETRESET: Errno = 102;
pub const ECONNABORTED: Errno = 103;
pub const ECONNRESET: Errno = 104;
pub const ENOBUFS: Errno = 105;
pub const EISCONN: Errno = 106;
pub const ENOTCONN: Errno = 107;
pub const ESHUTDOWN: Errno = 108;
pub const ETOOMANYREFS: Errno = 109;
pub const ETIMEDOUT: Errno = 110;
pub const ECONNREFUSED: Errno = 111;
pub const EHOSTDOWN: Errno = 112;
pub const EHOSTUNREACH: Errno = 113;
pub const EALREADY: Errno = 114;
pub const EINPROGRESS: Errno = 115;
pub const ESTALE: Errno = 116;
pub const EUCLEAN: Errno = 117;
pub const ENOTNAM: Errno = 118;
pub const ENAVAIL: Errno = 119;
pub const EISNAM: Errno = 120;
pub const EREMOTEIO: Errno = 121;
pub const EDQUOT: Errno = 122;
pub const ENOMEDIUM: Errno = 123;
pub const EMEDIUMTYPE: Errno = 124;
pub const ECANCELED: Errno = 125;
pub const ENOKEY: Errno = 126;
pub const EKEYEXPIRED: Errno = 127;
pub const EKEYREVOKED: Errno = 128;
pub const EKEYREJECTED: Errno = 129;
pub const EOWNERDEAD: Errno = 130;
pub const ENOTRECOVERABLE: Errno = 131;
pub const ERFKILL: Errno = 132;
pub const EHWPOISON: Errno = 133;

/// Get errno description.
pub fn strerror(errno: Errno) -> &'static str {
    match errno {
        EPERM => "Operation not permitted",
        ENOENT => "No such file or directory",
        ESRCH => "No such process",
        EINTR => "Interrupted system call",
        EIO => "I/O error",
        ENXIO => "No such device or address",
        E2BIG => "Argument list too long",
        ENOEXEC => "Exec format error",
        EBADF => "Bad file number",
        ECHILD => "No child processes",
        EAGAIN => "Try again",
        ENOMEM => "Out of memory",
        EACCES => "Permission denied",
        EFAULT => "Bad address",
        ENOTBLK => "Block device required",
        EBUSY => "Device or resource busy",
        EEXIST => "File exists",
        EXDEV => "Cross-device link",
        ENODEV => "No such device",
        ENOTDIR => "Not a directory",
        EISDIR => "Is a directory",
        EINVAL => "Invalid argument",
        ENFILE => "File table overflow",
        EMFILE => "Too many open files",
        ENOTTY => "Not a typewriter",
        ETXTBSY => "Text file busy",
        EFBIG => "File too large",
        ENOSPC => "No space left on device",
        ESPIPE => "Illegal seek",
        EROFS => "Read-only file system",
        EMLINK => "Too many links",
        EPIPE => "Broken pipe",
        EDOM => "Math argument out of domain of func",
        ERANGE => "Math result not representable",
        EDEADLK => "Resource deadlock would occur",
        ENAMETOOLONG => "File name too long",
        ENOLCK => "No record locks available",
        ENOSYS => "Invalid system call number",
        ENOTEMPTY => "Directory not empty",
        ELOOP => "Too many symbolic links encountered",
        ENOMSG => "No message of desired type",
        EIDRM => "Identifier removed",
        ECHRNG => "Channel number out of range",
        EL2NSYNC => "Level 2 not synchronized",
        EL3HLT => "Level 3 halted",
        EL3RST => "Level 3 reset",
        ELNRNG => "Link number out of range",
        EUNATCH => "Protocol driver not attached",
        ENOCSI => "No CSI structure available",
        EL2HLT => "Level 2 halted",
        EBADE => "Invalid exchange",
        EBADR => "Invalid request descriptor",
        EXFULL => "Exchange full",
        ENOANO => "No anode",
        EBADRQC => "Invalid request code",
        EBADSLT => "Invalid slot",
        EBFONT => "Bad font file format",
        ENOSTR => "Device not a stream",
        ENODATA => "No data available",
        ETIME => "Timer expired",
        ENOSR => "Out of streams resources",
        ENONET => "Machine is not on the network",
        ENOPKG => "Package not installed",
        EREMOTE => "Object is remote",
        ENOLINK => "Link has been severed",
        EADV => "Advertise error",
        ESRMNT => "Srmount error",
        ECOMM => "Communication error on send",
        EPROTO => "Protocol error",
        EMULTIHOP => "Multihop attempted",
        EDOTDOT => "RFS specific error",
        EBADMSG => "Not a data message",
        EOVERFLOW => "Value too large for defined data type",
        ENOTUNIQ => "Name not unique on network",
        EBADFD => "File descriptor in bad state",
        EREMCHG => "Remote address changed",
        ELIBACC => "Can not access a needed shared library",
        ELIBBAD => "Accessing a corrupted shared library",
        ELIBSCN => ".lib section in a.out corrupted",
        ELIBMAX => "Attempting to link in too many shared libraries",
        ELIBEXEC => "Cannot exec a shared library directly",
        EILSEQ => "Illegal byte sequence",
        ERESTART => "Interrupted system call should be restarted",
        ESTRPIPE => "Streams pipe error",
        EUSERS => "Too many users",
        ENOTSOCK => "Socket operation on non-socket",
        EDESTADDRREQ => "Destination address required",
        EMSGSIZE => "Message too long",
        EPROTOTYPE => "Protocol wrong type for socket",
        ENOPROTOOPT => "Protocol not available",
        EPROTONOSUPPORT => "Protocol not supported",
        ESOCKTNOSUPPORT => "Socket type not supported",
        EOPNOTSUPP => "Operation not supported on transport endpoint",
        EPFNOSUPPORT => "Protocol family not supported",
        EAFNOSUPPORT => "Address family not supported by protocol",
        EADDRINUSE => "Address already in use",
        EADDRNOTAVAIL => "Cannot assign requested address",
        ENETDOWN => "Network is down",
        ENETUNREACH => "Network is unreachable",
        ENETRESET => "Network dropped connection because of reset",
        ECONNABORTED => "Software caused connection abort",
        ECONNRESET => "Connection reset by peer",
        ENOBUFS => "No buffer space available",
        EISCONN => "Transport endpoint is already connected",
        ENOTCONN => "Transport endpoint is not connected",
        ESHUTDOWN => "Cannot send after transport endpoint shutdown",
        ETOOMANYREFS => "Too many references: cannot splice",
        ETIMEDOUT => "Connection timed out",
        ECONNREFUSED => "Connection refused",
        EHOSTDOWN => "Host is down",
        EHOSTUNREACH => "No route to host",
        EALREADY => "Operation already in progress",
        EINPROGRESS => "Operation now in progress",
        ESTALE => "Stale file handle",
        EUCLEAN => "Structure needs cleaning",
        ENOTNAM => "Not a XENIX named type file",
        ENAVAIL => "No XENIX semaphores available",
        EISNAM => "Is a named type file",
        EREMOTEIO => "Remote I/O error",
        EDQUOT => "Quota exceeded",
        ENOMEDIUM => "No medium found",
        EMEDIUMTYPE => "Wrong medium type",
        ECANCELED => "Operation Canceled",
        ENOKEY => "Required key not available",
        EKEYEXPIRED => "Key has expired",
        EKEYREVOKED => "Key has been revoked",
        EKEYREJECTED => "Key was rejected by service",
        EOWNERDEAD => "Owner died",
        ENOTRECOVERABLE => "State not recoverable",
        ERFKILL => "Operation not possible due to RF-kill",
        EHWPOISON => "Memory page has hardware error",

        _ => "Unknown errno!",
    }
}