1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1982, 1986, 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#ifndef _SYS_ERRNO_H_
38#define _SYS_ERRNO_H_
39
40#if !defined(_KERNEL) && !defined(_STANDALONE)
41#include <sys/cdefs.h>
42__BEGIN_DECLS
43int * __error(void);
44__END_DECLS
45#define errno (* __error())
46#endif
47
48#define EPERM 1 /* Operation not permitted */
49#define ENOENT 2 /* No such file or directory */
50#define ESRCH 3 /* No such process */
51#define EINTR 4 /* Interrupted system call */
52#define EIO 5 /* Input/output error */
53#define ENXIO 6 /* Device not configured */
54#define E2BIG 7 /* Argument list too long */
55#define ENOEXEC 8 /* Exec format error */
56#define EBADF 9 /* Bad file descriptor */
57#define ECHILD 10 /* No child processes */
58#define EDEADLK 11 /* Resource deadlock avoided */
59 /* 11 was EAGAIN */
60#define ENOMEM 12 /* Cannot allocate memory */
61#define EACCES 13 /* Permission denied */
62#define EFAULT 14 /* Bad address */
63#ifndef _POSIX_SOURCE
64#define ENOTBLK 15 /* Block device required */
65#endif
66#define EBUSY 16 /* Device busy */
67#define EEXIST 17 /* File exists */
68#define EXDEV 18 /* Cross-device link */
69#define ENODEV 19 /* Operation not supported by device */
70#define ENOTDIR 20 /* Not a directory */
71#define EISDIR 21 /* Is a directory */
72#define EINVAL 22 /* Invalid argument */
73#define ENFILE 23 /* Too many open files in system */
74#define EMFILE 24 /* Too many open files */
75#define ENOTTY 25 /* Inappropriate ioctl for device */
76#ifndef _POSIX_SOURCE
77#define ETXTBSY 26 /* Text file busy */
78#endif
79#define EFBIG 27 /* File too large */
80#define ENOSPC 28 /* No space left on device */
81#define ESPIPE 29 /* Illegal seek */
82#define EROFS 30 /* Read-only filesystem */
83#define EMLINK 31 /* Too many links */
84#define EPIPE 32 /* Broken pipe */
85
86/* math software */
87#define EDOM 33 /* Numerical argument out of domain */
88#define ERANGE 34 /* Result too large */
89
90/* non-blocking and interrupt i/o */
91#define EAGAIN 35 /* Resource temporarily unavailable */
92#ifndef _POSIX_SOURCE
93#define EWOULDBLOCK EAGAIN /* Operation would block */
94#define EINPROGRESS 36 /* Operation now in progress */
95#define EALREADY 37 /* Operation already in progress */
96
97/* ipc/network software -- argument errors */
98#define ENOTSOCK 38 /* Socket operation on non-socket */
99#define EDESTADDRREQ 39 /* Destination address required */
100#define EMSGSIZE 40 /* Message too long */
101#define EPROTOTYPE 41 /* Protocol wrong type for socket */
102#define ENOPROTOOPT 42 /* Protocol not available */
103#define EPROTONOSUPPORT 43 /* Protocol not supported */
104#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
105#define EOPNOTSUPP 45 /* Operation not supported */
106#define ENOTSUP EOPNOTSUPP /* Operation not supported */
107#define EPFNOSUPPORT 46 /* Protocol family not supported */
108#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
109#define EADDRINUSE 48 /* Address already in use */
110#define EADDRNOTAVAIL 49 /* Can't assign requested address */
111
112/* ipc/network software -- operational errors */
113#define ENETDOWN 50 /* Network is down */
114#define ENETUNREACH 51 /* Network is unreachable */
115#define ENETRESET 52 /* Network dropped connection on reset */
116#define ECONNABORTED 53 /* Software caused connection abort */
117#define ECONNRESET 54 /* Connection reset by peer */
118#define ENOBUFS 55 /* No buffer space available */
119#define EISCONN 56 /* Socket is already connected */
120#define ENOTCONN 57 /* Socket is not connected */
121#define ESHUTDOWN 58 /* Can't send after socket shutdown */
122#define ETOOMANYREFS 59 /* Too many references: can't splice */
123#define ETIMEDOUT 60 /* Operation timed out */
124#define ECONNREFUSED 61 /* Connection refused */
125
126#define ELOOP 62 /* Too many levels of symbolic links */
127#endif /* _POSIX_SOURCE */
128#define ENAMETOOLONG 63 /* File name too long */
129
130/* should be rearranged */
131#ifndef _POSIX_SOURCE
132#define EHOSTDOWN 64 /* Host is down */
133#define EHOSTUNREACH 65 /* No route to host */
134#endif /* _POSIX_SOURCE */
135#define ENOTEMPTY 66 /* Directory not empty */
136
137/* quotas & mush */
138#ifndef _POSIX_SOURCE
139#define EPROCLIM 67 /* Too many processes */
140#define EUSERS 68 /* Too many users */
141#define EDQUOT 69 /* Disc quota exceeded */
142
143/* Network File System */
144#define ESTALE 70 /* Stale NFS file handle */
145#define EREMOTE 71 /* Too many levels of remote in path */
146#define EBADRPC 72 /* RPC struct is bad */
147#define ERPCMISMATCH 73 /* RPC version wrong */
148#define EPROGUNAVAIL 74 /* RPC prog. not avail */
149#define EPROGMISMATCH 75 /* Program version wrong */
150#define EPROCUNAVAIL 76 /* Bad procedure for program */
151#endif /* _POSIX_SOURCE */
152
153#define ENOLCK 77 /* No locks available */
154#define ENOSYS 78 /* Function not implemented */
155
156#ifndef _POSIX_SOURCE
157#define EFTYPE 79 /* Inappropriate file type or format */
158#define EAUTH 80 /* Authentication error */
159#define ENEEDAUTH 81 /* Need authenticator */
160#define EIDRM 82 /* Identifier removed */
161#define ENOMSG 83 /* No message of desired type */
162#define EOVERFLOW 84 /* Value too large to be stored in data type */
163#define ECANCELED 85 /* Operation canceled */
164#define EILSEQ 86 /* Illegal byte sequence */
165#define ENOATTR 87 /* Attribute not found */
166
167#define EDOOFUS 88 /* Programming error */
168#endif /* _POSIX_SOURCE */
169
170#define EBADMSG 89 /* Bad message */
171#define EMULTIHOP 90 /* Multihop attempted */
172#define ENOLINK 91 /* Link has been severed */
173#define EPROTO 92 /* Protocol error */
174
175#ifndef _POSIX_SOURCE
176#define ENOTCAPABLE 93 /* Capabilities insufficient */
177#define ECAPMODE 94 /* Not permitted in capability mode */
178#define ENOTRECOVERABLE 95 /* State not recoverable */
179#define EOWNERDEAD 96 /* Previous owner died */
180#define EINTEGRITY 97 /* Integrity check failed */
181#endif /* _POSIX_SOURCE */
182
183#ifndef _POSIX_SOURCE
184#define ELAST 97 /* Must be equal largest errno */
185#endif /* _POSIX_SOURCE */
186
187#if defined(_KERNEL) || defined(_WANT_KERNEL_ERRNO) || defined(_STANDALONE)
188/* pseudo-errors returned inside kernel to modify return to process */
189#define ERESTART (-1) /* restart syscall */
190#define EJUSTRETURN (-2) /* don't modify regs, just return */
191#define ENOIOCTL (-3) /* ioctl not handled by this layer */
192#define EDIRIOCTL (-4) /* do direct ioctl in GEOM */
193#define ERELOOKUP (-5) /* retry the directory lookup */
194#endif
195
196#ifndef _KERNEL
197#if __EXT1_VISIBLE
198/* ISO/IEC 9899:2011 K.3.2.2 */
199#ifndef _ERRNO_T_DEFINED
200#define _ERRNO_T_DEFINED
201typedef int errno_t;
202#endif
203#endif /* __EXT1_VISIBLE */
204#endif
205
206#endif