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 *	@(#)errno.h	8.5 (Berkeley) 1/21/94
 37 */
 38
 39#ifndef _SYS_ERRNO_H_
 40#define _SYS_ERRNO_H_
 41
 42#if !defined(_KERNEL) && !defined(_STANDALONE)
 43#include <sys/cdefs.h>
 44__BEGIN_DECLS
 45int *	__error(void);
 46__END_DECLS
 47#define	errno		(* __error())
 48#endif
 49
 50#define	EPERM		1		/* Operation not permitted */
 51#define	ENOENT		2		/* No such file or directory */
 52#define	ESRCH		3		/* No such process */
 53#define	EINTR		4		/* Interrupted system call */
 54#define	EIO		5		/* Input/output error */
 55#define	ENXIO		6		/* Device not configured */
 56#define	E2BIG		7		/* Argument list too long */
 57#define	ENOEXEC		8		/* Exec format error */
 58#define	EBADF		9		/* Bad file descriptor */
 59#define	ECHILD		10		/* No child processes */
 60#define	EDEADLK		11		/* Resource deadlock avoided */
 61					/* 11 was EAGAIN */
 62#define	ENOMEM		12		/* Cannot allocate memory */
 63#define	EACCES		13		/* Permission denied */
 64#define	EFAULT		14		/* Bad address */
 65#ifndef _POSIX_SOURCE
 66#define	ENOTBLK		15		/* Block device required */
 67#endif
 68#define	EBUSY		16		/* Device busy */
 69#define	EEXIST		17		/* File exists */
 70#define	EXDEV		18		/* Cross-device link */
 71#define	ENODEV		19		/* Operation not supported by device */
 72#define	ENOTDIR		20		/* Not a directory */
 73#define	EISDIR		21		/* Is a directory */
 74#define	EINVAL		22		/* Invalid argument */
 75#define	ENFILE		23		/* Too many open files in system */
 76#define	EMFILE		24		/* Too many open files */
 77#define	ENOTTY		25		/* Inappropriate ioctl for device */
 78#ifndef _POSIX_SOURCE
 79#define	ETXTBSY		26		/* Text file busy */
 80#endif
 81#define	EFBIG		27		/* File too large */
 82#define	ENOSPC		28		/* No space left on device */
 83#define	ESPIPE		29		/* Illegal seek */
 84#define	EROFS		30		/* Read-only filesystem */
 85#define	EMLINK		31		/* Too many links */
 86#define	EPIPE		32		/* Broken pipe */
 87
 88/* math software */
 89#define	EDOM		33		/* Numerical argument out of domain */
 90#define	ERANGE		34		/* Result too large */
 91
 92/* non-blocking and interrupt i/o */
 93#define	EAGAIN		35		/* Resource temporarily unavailable */
 94#ifndef _POSIX_SOURCE
 95#define	EWOULDBLOCK	EAGAIN		/* Operation would block */
 96#define	EINPROGRESS	36		/* Operation now in progress */
 97#define	EALREADY	37		/* Operation already in progress */
 98
 99/* ipc/network software -- argument errors */
100#define	ENOTSOCK	38		/* Socket operation on non-socket */
101#define	EDESTADDRREQ	39		/* Destination address required */
102#define	EMSGSIZE	40		/* Message too long */
103#define	EPROTOTYPE	41		/* Protocol wrong type for socket */
104#define	ENOPROTOOPT	42		/* Protocol not available */
105#define	EPROTONOSUPPORT	43		/* Protocol not supported */
106#define	ESOCKTNOSUPPORT	44		/* Socket type not supported */
107#define	EOPNOTSUPP	45		/* Operation not supported */
108#define	ENOTSUP		EOPNOTSUPP	/* Operation not supported */
109#define	EPFNOSUPPORT	46		/* Protocol family not supported */
110#define	EAFNOSUPPORT	47		/* Address family not supported by protocol family */
111#define	EADDRINUSE	48		/* Address already in use */
112#define	EADDRNOTAVAIL	49		/* Can't assign requested address */
113
114/* ipc/network software -- operational errors */
115#define	ENETDOWN	50		/* Network is down */
116#define	ENETUNREACH	51		/* Network is unreachable */
117#define	ENETRESET	52		/* Network dropped connection on reset */
118#define	ECONNABORTED	53		/* Software caused connection abort */
119#define	ECONNRESET	54		/* Connection reset by peer */
120#define	ENOBUFS		55		/* No buffer space available */
121#define	EISCONN		56		/* Socket is already connected */
122#define	ENOTCONN	57		/* Socket is not connected */
123#define	ESHUTDOWN	58		/* Can't send after socket shutdown */
124#define	ETOOMANYREFS	59		/* Too many references: can't splice */
125#define	ETIMEDOUT	60		/* Operation timed out */
126#define	ECONNREFUSED	61		/* Connection refused */
127
128#define	ELOOP		62		/* Too many levels of symbolic links */
129#endif /* _POSIX_SOURCE */
130#define	ENAMETOOLONG	63		/* File name too long */
131
132/* should be rearranged */
133#ifndef _POSIX_SOURCE
134#define	EHOSTDOWN	64		/* Host is down */
135#define	EHOSTUNREACH	65		/* No route to host */
136#endif /* _POSIX_SOURCE */
137#define	ENOTEMPTY	66		/* Directory not empty */
138
139/* quotas & mush */
140#ifndef _POSIX_SOURCE
141#define	EPROCLIM	67		/* Too many processes */
142#define	EUSERS		68		/* Too many users */
143#define	EDQUOT		69		/* Disc quota exceeded */
144
145/* Network File System */
146#define	ESTALE		70		/* Stale NFS file handle */
147#define	EREMOTE		71		/* Too many levels of remote in path */
148#define	EBADRPC		72		/* RPC struct is bad */
149#define	ERPCMISMATCH	73		/* RPC version wrong */
150#define	EPROGUNAVAIL	74		/* RPC prog. not avail */
151#define	EPROGMISMATCH	75		/* Program version wrong */
152#define	EPROCUNAVAIL	76		/* Bad procedure for program */
153#endif /* _POSIX_SOURCE */
154
155#define	ENOLCK		77		/* No locks available */
156#define	ENOSYS		78		/* Function not implemented */
157
158#ifndef _POSIX_SOURCE
159#define	EFTYPE		79		/* Inappropriate file type or format */
160#define	EAUTH		80		/* Authentication error */
161#define	ENEEDAUTH	81		/* Need authenticator */
162#define	EIDRM		82		/* Identifier removed */
163#define	ENOMSG		83		/* No message of desired type */
164#define	EOVERFLOW	84		/* Value too large to be stored in data type */
165#define	ECANCELED	85		/* Operation canceled */
166#define	EILSEQ		86		/* Illegal byte sequence */
167#define	ENOATTR		87		/* Attribute not found */
168
169#define	EDOOFUS		88		/* Programming error */
170#endif /* _POSIX_SOURCE */
171
172#define	EBADMSG		89		/* Bad message */
173#define	EMULTIHOP	90		/* Multihop attempted */
174#define	ENOLINK		91		/* Link has been severed */
175#define	EPROTO		92		/* Protocol error */
176
177#ifndef _POSIX_SOURCE
178#define	ENOTCAPABLE	93		/* Capabilities insufficient */
179#define	ECAPMODE	94		/* Not permitted in capability mode */
180#define	ENOTRECOVERABLE	95		/* State not recoverable */
181#define	EOWNERDEAD	96		/* Previous owner died */
182#define	EINTEGRITY	97		/* Integrity check failed */
183#endif /* _POSIX_SOURCE */
184
185#ifndef _POSIX_SOURCE
186#define	ELAST		97		/* Must be equal largest errno */
187#endif /* _POSIX_SOURCE */
188
189#if defined(_KERNEL) || defined(_WANT_KERNEL_ERRNO) || defined(_STANDALONE)
190/* pseudo-errors returned inside kernel to modify return to process */
191#define	ERESTART	(-1)		/* restart syscall */
192#define	EJUSTRETURN	(-2)		/* don't modify regs, just return */
193#define	ENOIOCTL	(-3)		/* ioctl not handled by this layer */
194#define	EDIRIOCTL	(-4)		/* do direct ioctl in GEOM */
195#define	ERELOOKUP	(-5)		/* retry the directory lookup */
196#endif
197
198#ifndef _KERNEL
199#if __EXT1_VISIBLE
200/* ISO/IEC 9899:2011 K.3.2.2 */
201#ifndef _ERRNO_T_DEFINED
202#define _ERRNO_T_DEFINED
203typedef int errno_t;
204#endif
205#endif /* __EXT1_VISIBLE */
206#endif
207
208#endif