manual page distributed with 4.2BSD
[unix-history] / usr / src / lib / libc / sys / intro.2
CommitLineData
5822f3c2
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5e1f9d48 5.\" @(#)intro.2 5.1 (Berkeley) %G%
5822f3c2 6.\"
5e1f9d48 7.TH INTRO 2 "12 February 1983"
5822f3c2
KM
8.UC 4
9.de en
10.HP
11\\$1 \\$2 \\$3
12.br
13..
14.SH NAME
5e1f9d48 15intro \- introduction to system calls and error numbers
5822f3c2
KM
16.SH SYNOPSIS
17.B #include <errno.h>
18.SH DESCRIPTION
5e1f9d48
KM
19This section describes all of the system calls. Most
20of these calls have one or more error returns.
21An error condition is indicated by an otherwise impossible return
22value. This is almost always \-1; the individual descriptions
23specify the details.
5822f3c2 24.PP
5e1f9d48
KM
25As with normal arguments, all return codes and values from
26functions are of type integer unless otherwise noted.
27An error number is also made available in the external
28variable \fIerrno\fP, which is not cleared
29on successful calls.
30Thus \fIerrno\fP should be tested only after an error has occurred.
5822f3c2 31.PP
5e1f9d48
KM
32The following is a complete list of the errors and their
33names as given in
34.RI < errno.h >.
5822f3c2
KM
35.en 0 \h'\w'EIO'u' "Error 0
36Unused.
37.en 1 EPERM "Not owner
38Typically this error indicates
39an attempt to modify a file in some way forbidden
40except to its owner or super-user.
41It is also returned for attempts
42by ordinary users to do things
43allowed only to the super-user.
44.en 2 ENOENT "No such file or directory
45This error occurs when a file name is specified
46and the file should exist but doesn't, or when one
47of the directories in a path name does not exist.
48.en 3 ESRCH "No such process
49The process whose number was given to
5e1f9d48 50.I kill
5822f3c2
KM
51and
52.I ptrace
53does not exist, or is already dead.
54.en 4 EINTR "Interrupted system call
55An asynchronous signal (such as interrupt or quit),
56which the user has elected to catch,
57occurred during a system call.
58If execution is resumed
59after processing the signal,
60it will appear as if the interrupted system call
61returned this error condition.
62.en 5 EIO "I/O error
63Some physical I/O error occurred during a
64.I read
65or
66.IR write .
67This error may in some cases occur
68on a call following the one to which it actually applies.
69.en 6 ENXIO "No such device or address
70I/O on a special file refers to a subdevice which does not
71exist,
72or beyond the limits of the device.
5e1f9d48
KM
73It may also occur when, for example, an illegal tape drive
74unit number is selected
75or a disk pack is not loaded on a drive.
5822f3c2
KM
76.en 7 E2BIG "Arg list too long
77An argument list longer than 10240 bytes
78is presented to
5e1f9d48 79.IR execve .
5822f3c2
KM
80.en 8 ENOEXEC "Exec format error
81A request is made to execute a file
82which, although it has the appropriate permissions,
83does not start with a valid magic number, see
84.IR a.out (5).
85.en 9 EBADF "Bad file number
86Either a file descriptor refers to no
87open file,
88or a read (resp. write) request is made to
89a file which is open only for writing (resp. reading).
90.en 10 ECHILD "No children
91.I Wait
92and the process has no
93living or unwaited-for children.
94.en 11 EAGAIN "No more processes
95In a
96.I fork,
97the system's process table is full
98or the user is not allowed to create any more
99processes.
100.en 12 ENOMEM "Not enough core
101During an
5e1f9d48 102.I execve
5822f3c2
KM
103or
104.I break,
5e1f9d48
KM
105a program asks for more core or swap space than the system is
106able to supply.
107A lack of swap space is normally a temporary condition, however
108a lack of core
109is not a temporary condition; the maximum size
110of the text, data, and stack segments is a system parameter.
5822f3c2
KM
111.en 13 EACCES "Permission denied
112An attempt was made to access a file in a way forbidden
113by the protection system.
114.en 14 EFAULT "Bad address
115The system encountered a hardware fault in attempting to
116access the arguments of a system call.
117.en 15 ENOTBLK "Block device required
118A plain file was mentioned where a block device was required,
119e.g. in
120.IR mount .
121.en 16 EBUSY "Mount device busy
122An attempt to mount a device that was already mounted or
123an attempt was made to dismount a device
124on which there is an active file
125directory.
126(open file, current directory, mounted-on file, active text segment).
127.en 17 EEXIST "File exists
128An existing file was mentioned in an inappropriate context,
129e.g.
130.IR link .
131.en 18 EXDEV "Cross-device link
5e1f9d48 132A hard link to a file on another device
5822f3c2
KM
133was attempted.
134.en 19 ENODEV "No such device
135An attempt was made to apply an inappropriate
136system call to a device;
137e.g. read a write-only device.
138.en 20 ENOTDIR "Not a directory
139A non-directory was specified where a directory
140is required,
141for example in a path name or
142as an argument to
143.IR chdir .
144.en 21 EISDIR "Is a directory
145An attempt to write on a directory.
146.en 22 EINVAL "Invalid argument
147Some invalid argument:
148dismounting a non-mounted
149device,
150mentioning an unknown signal in
151.I signal,
152reading or writing a file for which
153.I seek
154has generated a negative pointer.
155Also set by math functions, see
156.IR intro (3).
157.en 23 ENFILE "File table overflow
158The system's table of open files is full,
159and temporarily no more
160.I opens
161can be accepted.
162.en 24 EMFILE "Too many open files
163Customary configuration limit is 20 per process.
164.en 25 ENOTTY "Not a typewriter
5e1f9d48
KM
165The file mentioned in an
166.I ioctl
5822f3c2
KM
167is not a terminal or one of the other
168devices to which these calls apply.
169.en 26 ETXTBSY "Text file busy
170An attempt to execute a pure-procedure
171program which is currently open for writing
172(or reading!).
173Also an attempt to open for writing a pure-procedure
174program that is being executed.
175.en 27 EFBIG "File too large
176The size of a file exceeded the maximum (about
177.if t 10\u\s-29\s+2\d
178.if n 1.0E9
179bytes).
180.en 28 ENOSPC "No space left on device
181During a
182.I write
183to an ordinary file,
184there is no free space left on the device.
185.en 29 ESPIPE "Illegal seek
186An
187.I lseek
188was issued to a pipe.
5e1f9d48 189This error may also be issued for
5822f3c2
KM
190other non-seekable devices.
191.en 30 EROFS "Read-only file system
192An attempt to modify a file or directory
193was made
194on a device mounted read-only.
195.en 31 EMLINK "Too many links
5e1f9d48 196An attempt to make more than 32767 hard links to a file.
5822f3c2 197.en 32 EPIPE "Broken pipe
5e1f9d48 198A write on a pipe or socket for which there is no process
5822f3c2
KM
199to read the data.
200This condition normally generates a signal;
201the error is returned if the signal is ignored.
202.en 33 EDOM "Math argument
203The argument of a function in the math package (3M)
204is out of the domain of the function.
205.en 34 ERANGE "Result too large
206The value of a function in the math package (3M)
207is unrepresentable within machine precision.
5e1f9d48
KM
208.en 35 EWOULDBLOCK "Operation would block"
209An operation which would cause a process to block was attempted
210on a object in non-blocking mode (see \fIioctl\fP (2)).
211.en 36 EINPROGRESS "Operation now in progress"
212An operation which takes a long time to complete (such as
213a \fIconnect\fP (2)) was attempted on a non-blocking object (see
214\fIioctl\fP (2)).
215.en 37 EALREADY "Operation already in progress"
216An operation was attempted on a non-blocking object which already
217had an operation in progress.
218.en 38 ENOTSOCK "Socket operation on non-socket"
219Self-explanatory.
220.en 39 EDESTADDRREQ "Destination address required"
221A required address was omitted from an operation on a socket.
222.en 40 EMSGSIZE "Message too long"
223A message sent on a socket was larger than the internal message buffer.
224.en 41 EPROTOTYPE "Protocol wrong type for socket"
225A protocol was specified which does not support the semantics of the
226socket type requested. For example you cannot use the ARPA Internet
227UDP protocol with type SOCK_STREAM.
228.en 42 ENOPROTOOPT "Bad protocol option"
229A bad option was specified in a
230.IR getsockopt (2)
231or
232.IR setsockopt (2)
233call.
234.en 43 EPROTONOSUPPORT "Protocol not supported"
235The protocol has not been configured into the
236system or no implementation for it exists.
237.en 44 ESOCKTNOSUPPORT "Socket type not supported"
238The support for the socket type has not been configured into the
239system or no implementation for it exists.
240.en 45 EOPNOTSUPP "Operation not supported on socket"
241For example, trying to \fIaccept\fP a connection on a datagram socket.
242.en 46 EPFNOSUPPORT "Protocol family not supported"
243The protocol family has not been configured into the
244system or no implementation for it exists.
245.en 47 EAFNOSUPPORT "Address family not supported by protocol family"
246An address incompatible with the requested protocol was used.
247For example, you shouldn't necessarily expect to be able to use PUP
248Internet addresses with ARPA Internet protocols.
249.en 48 EADDRINUSE "Address already in use"
250Only one usage of each address is normally permitted.
251.en 49 EADDRNOTAVAIL "Can't assign requested address"
252Normally results from an attempt to create a socket with an
253address not on this machine.
254.en 50 ENETDOWN "Network is down"
255A socket operation encountered a dead network.
256.en 51 ENETUNREACH "Network is unreachable"
257A socket operation was attempted to an unreachable network.
258.en 52 ENETRESET "Network dropped connection on reset"
259The host you were connected to crashed and rebooted.
260.en 53 ECONNABORTED "Software caused connection abort"
261A connection abort was caused internal to your host machine.
262.en 54 ECONNRESET "Connection reset by peer"
263A connection was forcibly closed by a peer. This normally
264results from the peer executing a \fIshutdown\fP (2) call.
265.en 55 ENOBUFS "No buffer space available"
266An operation on a socket or pipe was not performed because
267the system lacked sufficient buffer space.
268.en 56 EISCONN "Socket is already connected"
269A
270.I connect
271request was made on an already connected socket; or,
272a
273.I sendto
274or
275.I sendmsg
276request on a connected socket specified a destination
277other than the connected party.
278.en 57 ENOTCONN "Socket is not connected"
279An request to send or receive data was disallowed because
280the socket is not connected.
281.en 58 ESHUTDOWN "Can't send after socket shutdown"
282A request to send data was disallowed because the socket
283had already been shut down with a previous
284.IR shutdown (2)
285call.
286.en 59 \fIunused\fP
287.en 60 ETIMEDOUT "Connection timed out"
288A
289.I connect
290request failed because the connected party did not
291properly respond after a period of time. (The timeout
292period is dependent on the communication protocol.)
293.en 61 ECONNREFUSED "Connection refused"
294No connection could be made because the target machine actively
295refused it. This usually results from trying to connect
296to a service which is inactive on the foreign host.
297.en 62 ELOOP "Too many levels of symbolic links"
298A path name lookup involved more than 8 symbolic links.
299.en 63 ENAMETOOLONG "File name too long"
300A component of a path name exceeded 255 characters, or an entire
301path name exceeded 1023 characters.
302.en 64 ENOTEMPTY "Directory not empty"
303A directory with entries other than \*(lq.\*(rq and \*(lq..\*(rq
304was supplied to a remove directory or rename call.
305.SH DEFINITIONS
306.TP 5
307Process ID
308.br
309Each active process in the system is uniquely identified by a positive
310integer called a process ID. The range of this ID is from 0 to {PROC_MAX}.
311.TP 5
312Parent process ID
313.br
314A new process is created by a currently active process; see
315.IR fork (2).
316The parent process ID of a process is the process ID of its creator.
317.TP 5
318Process Group ID
319.br
320Each active process is a member of a process group that is identified by
321a positive integer called the process group ID. This is the process
322ID of the group leader. This grouping permits the signalling of related
323processes (see
324.IR killpg (2))
325and the job control mechanisms of
326.IR csh (1).
327.TP 5
328Tty Group ID
329.br
330Each active process can be a member of a terminal group that is identified
331by a positive integer called the tty group ID. This grouping is used
332to arbitrate between multiple jobs contending for the same terminal;
333see
334.IR csh (1),
5822f3c2 335and
5e1f9d48
KM
336.IR tty (4).
337.TP 5
338Real User ID and Real Group ID
339.br
340Each user on the system is identified by a positive integer
341termed the real user ID.
5822f3c2 342.IP
5e1f9d48
KM
343Each user is also a member of one or more groups.
344One of these groups is distinguished from others and
345used in implementing accounting facilities. The positive
346integer corresponding to this distinguished group is termed
347the real group ID.
348.IP
349All processes have a real user ID and real group ID.
350These are initialized from the equivalent attributes
351of the process which created it.
352.TP 5
353Effective User Id, Effective Group Id, and Access Groups
354.br
355Access to system resources is governed by three values:
356the effective user ID, the effective group ID, and the
357group access list.
358.IP
359The effective user ID and effective group ID are initially the
360process's real user ID and real group ID respectively. Either
361may be modified through execution of a set-user-ID or set-group-ID
362file (possibly by one its ancestors); see
363.IR execve (2).
364.IP
365The group access list is an additional set of group ID's
366used only in determining resource accessibility. Access checks
367are performed as described below in ``File Access Permissions''.
368.TP 5
369Super-user
370.br
371A process is recognized as a
372.I super-user
373process and is granted special privileges if its effective user ID is 0.
374.TP 5
375Special Processes
376.br
377The processes with a process ID's of 0, 1, and 2 are special.
378Process 0 is the scheduler. Process 1 is the initialization process
379.IR init ,
380and is the ancestor of every other process in the system.
381It is used to control the process structure.
382Process 2 is the paging daemon.
383.TP 5
384Descriptor
385.br
386An integer assigned by the system when a file is referenced
387by
388.IR open (2),
389.IR dup (2),
390or
391.IR pipe (2)
392or a socket is referenced by
393.IR socket (2)
394or
395.IR socketpair (2)
396which uniquely identifies an access path to that file or socket from
397a given process or any of its children.
398.TP 5
399File Name
400.br
401Names consisting of up to {FILENAME_MAX} characters may be used to name
402an ordinary file, special file, or directory.
403.IP
404These characters may be selected from the set of all ASCII character
405excluding 0 (null) and the ASCII code for / (slash). (The parity bit,
406bit 8, must be 0.)
407.IP
408Note that it is generally unwise to use *, ?, [ or ] as part of
409file names because of the special meaning attached to these characters
410by the shell.
411.TP 5
412Path Name
413.br
414A path name is a null-terminated character string starting with an
415optional slash (/), followed by zero or more directory names separated
416by slashes, optionally followed by a file name.
417The total length of a path name must be less than {PATHNAME_MAX} characters.
418.IP
419If a path name begins with a slash, the path search begins at the
420.I root
421directory.
422Otherwise, the search begins from the current working directory.
423A slash by itself names the root directory. A null
424pathname refers to the current directory.
425.TP 5
426Directory
427.br
428A directory is a special type of file which contains entries
429which are references to other files.
430Directory entries are called links. By convention, a directory
431contains at least two links, . and .., referred to as
432.I dot
5822f3c2 433and
5e1f9d48
KM
434.I dot-dot
435respectively. Dot refers to the directory itself and
436dot-dot refers to its parent directory.
437.TP 5
438Root Directory and Current Working Directory
439.br
440Each process has associated with it a concept of a root directory
441and a current working directory for the purpose of resolving path
442name searches. A process's root directory need not be the root
443directory of the root file system.
444.TP 5
445File Access Permissions
446.br
447Every file in the file system has a set of access permissions.
448These permissions are used in determining whether a process
449may perform a requested operation on the file (such as opening
450a file for writing). Access permissions are established at the
451time a file is created. They may be changed at some later time
452through the
453.IR chmod (2)
454call.
455.IP
456File access is broken down according to whether a file may be: read,
457written, or executed. Directory files use the execute
458permission to control if the directory may be searched.
459.IP
460File access permissions are interpreted by the system as
461they apply to three different classes of users: the owner
462of the file, those users in the file's group, anyone else.
463Every file has an independent set of access permissions for
464each of these classes. When an access check is made, the system
465decides if permission should be granted by checking the access
466information applicable to the caller.
467.IP
468Read, write, and execute/search permissions on
469a file are granted to a process if:
470.IP
471The process's effective user ID is that of the super-user.
472.IP
473The process's effective user ID matches the user ID of the owner
474of the file and the owner permissions allow the access.
475.IP
476The process's effective user ID does not match the user ID of the
477owner of the file, and either the process's effective
478group ID matches the group ID
479of the file, or the group ID of the file is in
480the process's group access list,
481and the group permissions allow the access.
482.IP
483Neither the effective user ID nor effective group ID
484and group access list of the process
485match the corresponding user ID and group ID of the file,
486but the permissions for ``other users'' allow access.
487.IP
488Otherwise, permission is denied.
489.TP 5
490Sockets and Address Families
491.IP
492A socket is an endpoint for communication between processes.
493Each socket has queues for sending and receiving data.
494.IP
495Sockets are typed according to their communications properties.
496These properties include whether messages sent and received
497at a socket require the name of the partner, whether communication
498is reliable, the format used in naming message recipients, etc.
499.IP
500Each instance of the system supports some
501collection of socket types; consult
502.IR socket (2)
503for more information about the types available and
504their properties.
505.IP
506Each instance of the system supports some number of sets of
507communications protocols. Each protocol set supports addresses
508of a certain format. An Address Family is the set of addresses
509for a specific group of protocols. Each socket has an address
510chosen from the address family in which the socket was created.
511.SH SEE ALSO
512intro(3), perror(3)