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