| INTRO(2) | System Calls Manual | INTRO(2) |
intro —
introduction to system calls and error numbers
#include
<sys/errno.h>
This section provides an overview of the system calls, their error returns, and other common definitions and concepts.
Nearly all of the system calls provide an error number in the external variable errno, which is defined as:
extern int errnoWhen a system call detects an error, it returns an integer value indicating failure (usually -1) and sets the variable errno accordingly. <This allows interpretation of the failure on receiving a -1 and to take action accordingly.> Successful calls never set errno; once set, it remains until another error occurs. It should only be examined after an error. Note that a number of system calls overload the meanings of these error numbers, and that the meanings must be interpreted according to the type and circumstances of the call.
The following is a complete list of the errors and their names as given in ⟨sys/errno.h⟩.
0
Error 0.1 EPERM Operation not
permitted.2 ENOENT No such file or
directory.3 ESRCH No such process.4 EINTR
Interrupted function
call.SIGINT or
SIGQUIT) was caught by the process during the
execution of an interruptible function. If the signal handler performs a
normal return, the interrupted function call will seem to have returned
the error condition.5 EIO
Input/output
error.6 ENXIO No such device or
address.7 E2BIG
Arg list too
long.NCARGS (specified in
⟨sys/param.h⟩).8 ENOEXEC
Exec format
error.9 EBADF Bad file
descriptor.10 ECHILD No child
processes.11 EDEADLK Resource deadlock
avoided.12 ENOMEM Cannot allocate
memory.13 EACCES
Permission
denied.14 EFAULT Bad address.15 ENOTBLK Not a block
device.16 EBUSY Resource busy.17 EEXIST File exists.18 EXDEV
Improper
link.19 ENODEV Operation not supported by
device.20 ENOTDIR Not a directory.21 EISDIR
Is a directory.22 EINVAL
Invalid
argument.23 ENFILE Too many open files in
system.24 EMFILE Too many open
files.25 ENOTTY Inappropriate ioctl for
device.26 ETXTBSY
Text file busy.27 EFBIG File too large.28 ENOSPC Device out of
space.29 ESPIPE Illegal seek.30 EROFS
Read-only file
system.31 EMLINK Too many links.32 EPIPE
Broken pipe.33 EDOM Numerical argument out of
domain.34 ERANGE Numerical result out of
range.35 EAGAIN Resource temporarily
unavailable.36 EINPROGRESS Operation now in
progress.37 EALREADY Operation already in
progress.38 ENOTSOCK Socket operation on
non-socket.39 EDESTADDRREQ
Destination address
required.40 EMSGSIZE
Message too
long.41 EPROTOTYPE Protocol wrong type
for socket.SOCK_STREAM.42 ENOPROTOOPT Protocol not
available.43 EPROTONOSUPPORT Protocol not
supported.44 ESOCKTNOSUPPORT Socket type not
supported.45 ENOTSUP Not supported.46 EPFNOSUPPORT Protocol family not
supported.47 EAFNOSUPPORT Address family not
supported by protocol family.48 EADDRINUSE Address already in
use.49 EADDRNOTAVAIL Cannot assign
requested address.50 ENETDOWN Network is
down.51 ENETUNREACH Network is
unreachable.52 ENETRESET Network dropped
connection on reset.53 ECONNABORTED
Software caused
connection abort.54 ECONNRESET Connection reset by
peer.55 ENOBUFS No buffer space
available.56 EISCONN Socket is already
connected.57 ENOTCONN Socket is not
connected.58 ESHUTDOWN Cannot send after
socket shutdown.60 ETIMEDOUT Operation timed
out.61 ECONNREFUSED Connection
refused.62 ELOOP Too many levels of symbolic
links.63 ENAMETOOLONG File name too
long.MAXNAMELEN) characters, or an entire path name
exceeded 1023 (MAXPATHLEN-1) characters.64 EHOSTDOWN
Host is down.65 EHOSTUNREACH No route to
host.66 ENOTEMPTY
Directory not
empty..’ and
‘..’ was supplied to a remove
directory or rename call.67 EPROCLIM Too many
processes.68 EUSERS Too many users.69 EDQUOT
Disc quota
exceeded.70 ESTALE
Stale NFS file
handle.72 EBADRPC RPC struct is
bad.73 ERPCMISMATCH RPC version
wrong.74 EPROGUNAVAIL RPC prog. not
avail.75 EPROGMISMATCH
Program version
wrong.76 EPROCUNAVAIL Bad procedure for
program.77 ENOLCK No locks
available.78 ENOSYS
Function not
implemented.79 EFTYPE Inappropriate file type or
format.80 EAUTH
Authentication
error.81 ENEEDAUTH
Need
authenticator.82 EPWROFF Device power is
off.83 EDEVERR Device error.84 EOVERFLOW
Value too large to be
stored in data type.85 EBADEXEC Bad executable (or
shared library).86 EBADARCH Bad CPU type in
executable.88 EBADMACHO
Malformed Mach-o
file.89 ECANCELED Operation
canceled.90 EIDRM
Identifier
removed.91 ENOMSG No message of desired
type.92 EILSEQ Illegal byte
sequence.93 ENOATTR
Attribute not
found.94 EBADMSG Bad message.95 EMULTIHOP Reserved.96 ENODATA No message
available.97 ENOLINK Reserved.98 ENOSR No STREAM
resources.99 ENOSTR Not a STREAM.100 EPROTO Protocol error.101 ETIME
STREAM ioctl()
timeout.102 EOPNOTSUPP Operation
not supported on socket.Each user is also a member of one or more groups. One of these groups is distinguished from others and used in implementing accounting facilities. The positive integer corresponding to this distinguished group is termed the real group ID.
All processes have a real user ID and real group ID. These are initialized from the equivalent attributes of the process that created it.
The effective user ID and effective group ID are initially the process's real user ID and real group ID respectively. Either may be modified through execution of a set-user-ID or set-group-ID file (possibly by one its ancestors) (see execve(2)). By convention, the effective group ID (the first member of the group access list) is duplicated, so that the execution of a set-group-ID program does not result in the loss of the original (real) group ID.
The group access list is a set of group IDs used only in determining resource accessibility. Access checks are performed as described below in ``File Access Permissions''.
MAXNAMELEN)
characters may be used to name an ordinary file, special file, or
directory.
These characters may be selected from the set of all ASCII
character excluding 0 (NUL) and the ASCII code for
‘/’ (slash).
Note that it is generally unwise to use
‘*’,
‘?’,
‘[’ or
‘]’ as part of file names because
of the special meaning attached to these characters by the shell.
/’, followed by zero or more
directory names separated by slashes, optionally followed by a file name.
The total length of a path name must be less than 1024
(MAXPATHLEN) characters.
If a path name begins with a slash, the path search begins at the root directory. Otherwise, the search begins from the current working directory. A slash by itself names the root directory. An empty pathname refers to the current directory.
.’ and
‘..’, referred to as
dot and
dot-dot
respectively. Dot refers to the directory itself and dot-dot refers to its
parent directory.File access is broken down according to whether a file may be: read, written, or executed. Directory files use the execute permission to control if the directory may be searched.
File access permissions are interpreted by the system as they apply to three different classes of users: the owner of the file, those users in the file's group, anyone else. Every file has an independent set of access permissions for each of these classes. When an access check is made, the system decides if permission should be granted by checking the access information applicable to the caller.
Read, write, and execute/search permissions on a file are granted to a process if:
The process's effective user ID is that of the super-user. (Note: even the super-user cannot execute a non-executable file.)
The process's effective user ID matches the user ID of the owner of the file and the owner permissions allow the access.
The process's effective user ID does not match the user ID of the owner of the file, and either the process's effective group ID matches the group ID of the file, or the group ID of the file is in the process's group access list, and the group permissions allow the access.
Neither the effective user ID nor effective group ID and group access list of the process match the corresponding user ID and group ID of the file, but the permissions for ``other users'' allow access.
Otherwise, permission is denied.
A socket is an endpoint for communication between processes. Each socket has queues for sending and receiving data.
Sockets are typed according to their communications properties. These properties include whether messages sent and received at a socket require the name of the partner, whether communication is reliable, the format used in naming message recipients, etc.
Each instance of the system supports some collection of socket types; consult socket(2) for more information about the types available and their properties.
Each instance of the system supports some number of sets of communications protocols. Each protocol set supports addresses of a certain format. An Address Family is the set of addresses for a specific group of protocols. Each socket has an address chosen from the address family in which the socket was created.
An intro manual page appeared in
Version 6 AT&T UNIX.
| March 18, 2015 | BSD 4 |