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