axf-os161 / man / syscall / errno.html
errno.html
Raw
<!--
Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009, 2013
	The President and Fellows of Harvard College.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors
   may be used to endorse or promote products derived from this software
   without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-->
<html>
<head>
<title>errno</title>
<body bgcolor=#ffffff>
<h2 align=center>errno</h2>
<h4 align=center>OS/161 Reference Manual</h4>

<h3>Name</h3>
<p>
errno - error code reporting
</p>

<h3>Library</h3>
<p>
Standard C Library (libc, -lc)
</p>

<h3>Synopsis</h3>
<p>
<tt>#include &lt;errno.h&gt;</tt><br>
<br>
<tt>extern int errno;</tt>
</p>

<h3>Description</h3>
<p>
When system calls, and sometimes other functions, fail, a code
representing or describing the error condition is placed in the global
variable <tt>errno</tt>.
</p>

<p>
When an operation succeeds, <tt>errno</tt> is not explicitly changed;
however, operations that succeed are also not required to preserve the
pre-existing value of <tt>errno</tt>.
In general one must first check whether the operation failed, and only
then interrogate <tt>errno</tt>.
</p>

<p>
A handful of functions in Standard C and POSIX are explicitly defined
to preserve <tt>errno</tt> on success. These are typically functions
with not-entirely-satisfactory interfaces where the only reliable way
to detect failure is to clear <tt>errno</tt> to zero beforehand and
check it afterwards. The most common/notable example (not currently
available in OS/161's library) is <tt>strtol</tt>.
</p>

<p>
<tt>errno</tt> may be a macro. In a multithreaded process it is almost
invariably a macro. However, it is always an lvalue, that is, it may
be assigned to.
</p>

<p>
Each numeric code has a symbolic name and a textual expansion. The
symbolic names are used in source code; the textual expansions are
printed out when errors are reported to users.
</p>

<p>
The textual expansions can be retrieved with
<A HREF=../libc/strerror.html>strerror</A> or printed with
<A HREF=../libc/err.html>err</A> or <A HREF=../libc/warn.html>warn</A>.
</p>

<h3>Symbolic names</h3>
<p>
The following symbolic errors are defined in the OS/161 base system.
You may add more at your pleasure; but be sure to read the notes in
the file <tt>kern/errno.h</tt> that defines them.

<table width=90%>
<tr><td width=5% rowspan=63>&nbsp;</td>
    <td width=10% valign=top>ENOSYS</td>
<td><b>Function not implemented</b>: the action requested required
	functionality not yet implemented. This is also the error
	produced by attempting to make nonexistent system
	calls.</td></tr>

<tr><td valign=top>ENOMEM</td>
<td><b>Out of memory</b>: a memory allocation failed. This normally
	means that a process has used up all the memory available to
	it. (This may be due to limits or because it has used up all
	the memory available to the system.) It may also mean that
	memory allocation within the kernel has failed.</td></tr>

<tr><td valign=top>EAGAIN</td>
<td><b>Operation would block</b>: some resource is temporarily
	unavailable, or a non-blocking I/O operation (if such things
	exist) could not be completed without waiting. Historically,
	the message was "Try again later"; in 4.4BSD EAGAIN and the
	old EWOULDBLOCK error code were folded together.</td></tr>

<tr><td valign=top>EINTR</td>
<td><b>Interrupted system call</b>: handling of a system call was
	interrupted by the delivery of a signal. (If you have
	signals.)</td></tr>

<tr><td valign=top>EFAULT</td>
<td><b>Bad memory reference</b>: a pointer passed as an argument was
	not valid. Within the kernel, the <tt>copyin</tt> family of
	functions produces this error when given an invalid
	pointer.</td></tr>

<tr><td valign=top>ENAMETOOLONG</td>
<td><b>String too long</b>: a string passed as an argument was too
	long to process.</td></tr>

<tr><td valign=top>EINVAL</td>
<td><b>Invalid argument</b>: an argument passed to a command or system
	call was badly formed, invalid, or nonsensical, in a way for
	which no more specific error code is defined.</td></tr>

<tr><td valign=top>EPERM</td>
<td><b>Operation not permitted</b>: the requested operation is
	restricted to privileged users, or, in some cases, prohibited
	entirely. Note that "permission denied" is not EPERM.</td></tr>

<tr><td valign=top>EACCES</td>
<td><b>Permission denied</b>: the current process's credentials do not
	allow the desired form of access to the target object
	according to its permission settings. Note that "permission
	denied" is not EPERM.</td></tr>

<tr><td valign=top>EMPROC</td>
<td><b>Too many processes</b>: the current user ID has reached its
	limit of simultaneous running processes. In Unix, this is
	spelled EPROCLIM.</td></tr>

<tr><td valign=top>ENPROC</td>
<td><b>Too many processes on system</b>: the system process table is
	full. (Void where impossible or prohibited by law.)</td></tr>

<tr><td valign=top>ENOEXEC</td>
<td><b>File is not executable</b>: an
	<A HREF=../syscall/execv.html>execv</A> operation was
	attempted but the kernel was unable to run the requested
	program.</td></tr>

<tr><td valign=top>E2BIG</td>
<td><b>Argument list too long</b>: the space taken up by the
	<tt>argv[]</tt> strings (and environment strings, where
	applicable) passed to a newly started program is larger than
	the system allows. The limit on this space is given by the
	symbol <tt>ARG_MAX</tt>.</td></tr>

<tr><td valign=top>ESRCH</td>
<td><b>No such process</b>: the supplied process ID does not name any
	of the currently running processes.</td></tr>

<tr><td valign=top>ECHILD</td>
<td><b>No child processes</b>: the current process has no exited child
	processes whose exit status has not yet been collected with <A
	HREF=../syscall/waitpid.html>waitpid</A>.</td></tr>

<tr><td valign=top>ENOTDIR</td>
<td><b>Not a directory</b>: a directory was expected and a
	non-directory filesystem object was found.</td></tr>

<tr><td valign=top>EISDIR</td>
<td><b>Is a directory</b>: a non-directory was expected and a
	directory was found.</td></tr>

<tr><td valign=top>ENOENT</td>
<td><b>No such file or directory</b>: the requested filesystem object
	does/did not exist.</td></tr>

<tr><td valign=top>ELOOP</td>
<td><b>Too many levels of symbolic links</b>: pathname lookup crossed
	more than the maximum allowed number of symbolic links.
	Usually means a link points to itself, or a family of links
	has been arranged into a loop. (If you have symbolic
	links.)</td></tr>

<tr><td valign=top>ENOTEMPTY</td>
<td><b>Directory not empty</b>: a directory must be empty of
	everything (except <tt>.</tt> and <tt>..</tt>) before it may
	be removed.</td></tr>

<tr><td valign=top>EEXIST</td>
<td><b>File exists</b>: a filesystem object that was expected not to
	exist did in fact already exist.</td></tr>

<tr><td valign=top>EMLINK</td>
<td><b>Too many hard links</b>: the maximum number of hard links to
	the target file already exist.</td></tr>

<tr><td valign=top>EXDEV</td>
<td><b>Cross-device link</b>: an attempt was made to instruct one
	filesystem to handle files on another filesystem.</td></tr>

<tr><td valign=top>ENODEV</td>
<td><b>No such device</b>: the requested device or device driver does
	not exist.</td></tr>

<tr><td valign=top>ENXIO</td>
<td><b>Device not available</b>: the requested device exists but is
	not available (is not mounted, is powered off, etc.)</td></tr>

<tr><td valign=top>EBUSY</td>
<td><b>Device busy</b>: the requested object cannot be used (or,
	perhaps, released) because something else is using
	it.</td></tr>

<tr><td valign=top>EMFILE</td>
<td><b>Too many open files</b>: the process file table is full, so the
	process cannot open more files.</td></tr>

<tr><td valign=top>ENFILE</td>
<td><b>Too many open files in system</b>: a system-wide limit of some
	sort, if any exists, on the number of open files has been
	reached. Void where not possible.</td></tr>

<tr><td valign=top>EBADF</td>
<td><b>Bad file number</b>: a file operation was requested on an
	illegal file handle, or a file handle that was not open. Or, a
	write operation was attempted on a file handle that was open
	only for read or vice-versa.</td></tr>

<tr><td valign=top>EIOCTL</td>
<td><b>Invalid or inappropriate ioctl</b>: an operation requested via
	the <A HREF=../syscall/ioctl.html>ioctl</A> system call was
	not defined or could not be performed on the indicated
	object. In Unix, for historical reasons, this is spelled
	ENOTTY, with the historic message "Not a
	typewriter".</td></tr>

<tr><td valign=top>EIO</td>
<td><b>Input/output error</b>: a hardware-level error occured on a
	device. Media errors on disks fall into this
	category.</td></tr>

<tr><td valign=top>ESPIPE</td>
<td><b>Illegal seek</b>: a seek operation was attempted on a
	sequential object where seeking makes no sense, like a
	pipe or terminal.</td></tr>

<tr><td valign=top>EPIPE</td>
<td><b>Broken pipe</b>: a write was made to a pipe or socket object
	with nobody to read it.</td></tr>

<tr><td valign=top>EROFS</td>
<td><b>Read-only file system</b>: an attempt was made to modify a
	filesystem that was mounted read-only. (If you have read-only
	mounts.)</td></tr>

<tr><td valign=top>ENOSPC</td>
<td><b>No space left on device</b>: the target filesystem is
	full.</td></tr>

<tr><td valign=top>EDQUOT</td>
<td><b>Disc</b><font size=-2><i>(sic)</i></font><b> quota
	exceeded</b>: the current user ID's quota (of space or
	number of files) on the target filesystem has been used up.
	(If you have disk quotas.)</td></tr>

<tr><td valign=top>EFBIG</td>
<td><b>File too large</b>: an attempt was made to exceed the target
	filesystem's maximum file size, or a per-user limit on maximum
	file size was reached, if such a thing exists.</td></tr>

<tr><td valign=top>EFTYPE</td>
<td><b>Invalid file type or format</b>: the file provided was the
	wrong kind of file or contained invalid syntax.</td></tr>

<tr><td valign=top>EDOM</td>
<td><b>Argument out of range</b>: the (numeric) argument provided was
	outside the values upon which the operation is defined. For
	example, attempting to evaluate the logarithm of
	zero produces this error. It is sometimes also used for
	non-numeric arguments where the idea of being "out of range"
	still makes sense.</td></tr>

<tr><td valign=top>ERANGE</td>
<td><b>Result out of range</b>: the result of an operation did not fit
	in the space provided or could not be represented. Usually
	used with numeric values. String values that don't fit usually
	result in ENAMETOOLONG, or in its specific case,
	E2BIG.</td></tr>

<tr><td valign=top>EILSEQ</td>
<td><b>Invalid multibyte character sequence</b>: the input string
	contained a byte sequence whose value is undefined or whose
	use is restricted. Only applicable when a multibyte character
	set is in use, and if someone has added locale
	support.</td></tr>

<tr><td valign=top>ENOTSOCK</td>
<td><b>Not a socket</b>: the file handle in question does not refer to
	a socket, but a socket was expected.</td></tr>

<tr><td valign=top>EISSOCK</td>
<td><b>Is a socket</b>: the file handle in question refers to a
	socket, but a socket was not expected. In Unix this is spelled
	EOPNOTSUPP, and prints as "Operation not supported on
	socket".</td></tr>

<tr><td valign=top>EISCONN</td>
<td><b>Socket is already connected</b>: given the protocol in use, the
	operation requires a socket that has not yet been connected,
	but the socket provided is in fact connected.</td></tr>

<tr><td valign=top>ENOTCONN</td>
<td><b>Socket is not connected</b>: given the protocol in use, the
	operation requires a connected socket, but no connection has
	yet been made.</td></tr>

<tr><td valign=top>ESHUTDOWN</td>
<td><b>Socket has been shut down</b>: the operation requires a running
	socket, but the socket provided has been closed
	down.</td></tr>

<tr><td valign=top>EPFNOSUPPORT</td>
<td><b>Protocol family not supported</b>: the requested protocol
	family (PF_INET, PF_LOCAL, etc.) is not supported by the
	system.</td></tr>

<tr><td valign=top>ESOCKTNOSUPPORT</td>
<td><b>Socket type not supported</b>: the requested socket type
	(SOCK_STREAM, SOCK_DGRAM, etc.) is not supported by the
	system.</td></tr>

<tr><td valign=top>EPROTONOSUPPORT</td>
<td><b>Protocol not supported</b>: the protocol requested for a socket
	was not one supported by the system.</td></tr>

<tr><td valign=top>EPROTOTYPE</td>
<td><b>Protocol wrong type for socket</b>: the protocol requested for
	a socket was not one supported by the requested socket type
	and protocol family.</td></tr>

<tr><td valign=top>EAFNOSUPPORT</td>
<td><b>Address family not supported by protocol family</b>: the
	address family named in a struct sockaddr (AF_INET, AF_LOCAL,
	etc.) is not supported by the protocol family used to create
	the socket (PF_INET, PF_LOCAL, etc.). In practice each
	protocol family has exactly one address family and the values
	of AF_* and PF_* are often, if incorrectly, used
	interchangeably. If you run into this error in real life, it
	usually means you didn't initialize your sockaddr structures
	correctly.</td></tr>

<tr><td valign=top>ENOPROTOOPT</td>
<td><b>Protocol option not available</b>: the protocol option that was
	requested is not supported or cannot be activated.</td></tr>

<tr><td valign=top>EADDRINUSE</td>
<td><b>Address already in use</b>: the requested socket address is
	already in use by another socket somewhere on the
	system.</td></tr>

<tr><td valign=top>EADDRNOTAVAIL</td>
<td><b>Cannot assign requested address</b>: the requested socket
	address is unavailable. Usually caused by attempting to bind a
	socket to the IP address of another machine. </td></tr>

<tr><td valign=top>ENETDOWN</td>
<td><b>Network is down</b>: the network or subnet needed is
	offline.</td></tr>

<tr><td valign=top>ENETUNREACH</td>
<td><b>Network is unreachable</b>: the network or subnet needed cannot
	be reached from here, possibly due to routing problems on the
	network, possibly due to local configuration
	trouble.</td></tr>

<tr><td valign=top>EHOSTDOWN</td>
<td><b>Host is down</b>: the specific machine requested is
	offline.</td></tr>

<tr><td valign=top>EHOSTUNREACH</td>
<td><b>Host is unreachable</b>: the specific machine requested cannot
	be reached from here.</td></tr>

<tr><td valign=top>ECONNREFUSED</td>
<td><b>Connection refused</b>: the remote machine is not listening for
	connections on the requested port.</td></tr>

<tr><td valign=top>ETIMEDOUT</td>
<td><b>Connection timed out</b>: there was no response from the remote
	machine. It may be down, it may not be listening, or it may
	not be receiving our packets at all.</td></tr>

<tr><td valign=top>ECONNRESET</td>
<td><b>Connection reset by peer</b>: the connection was abandoned by
	the remote host. Usually seen on already-open connections
	after the remote machine reboots and thereby loses its network
	state. Sometimes also caused by defective network devices
	between the local and remote hosts.</td></tr>

<tr><td valign=top>EMSGSIZE</td>
<td><b>Message too large</b>: an internal protocol length limit was
	exceeded.</td></tr>

<tr><td valign=top>ENOTSUP</td>
<td><b>Threads operation not supported</b>: a special error code
	defined by the POSIX threads standard, which is a "special"
	interface.</td></tr>

</table>
</p>

</body>
</html>