add -s option which inserts/matches truncated member names
[unix-history] / usr / src / lib / libc / sys / intro.2
... / ...
CommitLineData
1.\" Copyright (c) 1980,1983,1986 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)intro.2 6.10 (Berkeley) %G%
6.\"
7.TH INTRO 2 ""
8.UC 4
9.de en
10.HP
11\\$1 \\$2 \\$3
12.br
13..
14.SH NAME
15intro \- introduction to system calls and error numbers
16.SH SYNOPSIS
17.B #include <sys/errno.h>
18.SH DESCRIPTION
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.
27An error condition is indicated by an otherwise impossible return
28value. This is almost always \-1; the individual descriptions
29specify the details.
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.
33.PP
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.
40.PP
41The following is a complete list of the errors and their
42names as given in
43.RI < sys/errno.h >.
44.en 0 \h'\w'EIO'u' "Error 0
45Unused.
46.en 1 EPERM "Operation not permitted
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
58The process or process group whose number was given
59does not exist, or any such process is already dead.
60.en 4 EINTR "Interrupted system call
61An asynchronous signal (such as interrupt or quit)
62that the user has elected to catch
63occurred during a system call.
64If execution is resumed
65after processing the signal
66and the system call is not restarted,
67it will appear as if the interrupted system call
68returned this error condition.
69.en 5 EIO "Input/output error
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.
76.en 6 ENXIO "Device not configured
77I/O on a special file refers to a subdevice that does not
78exist,
79or beyond the limits of the device.
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.
83.en 7 E2BIG "Argument list too long
84An argument list longer than 20480 bytes (or the current limit, NCARGS in
85.IR <sys/param.h> )
86is presented to
87.IR execve .
88.en 8 ENOEXEC "Exec format error
89A request is made to execute a file
90that, although it has the appropriate permissions,
91does not start with a valid magic number, (see
92.IR a.out (5)).
93.en 9 EBADF "Bad file descriptor
94Either a file descriptor refers to no
95open file,
96or a read (resp. write) request is made to
97a file that is open only for writing (resp. reading).
98.en 10 ECHILD "No child processes
99.I Wait
100and the process has no
101living or unwaited-for children.
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
106During an
107.I execve
108or
109.I break,
110a program asks for more core or swap space than the system is
111able to supply,
112or a process size limit would be exceeded.
113A lack of swap space is normally a temporary condition; however,
114a lack of core
115is not a temporary condition; the maximum size
116of the text, data, and stack segments is a system parameter.
117Soft limits may be increased to their corresponding hard limits.
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,
126e.g., in
127.IR mount .
128.en 16 EBUSY "Device busy
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
132(open file, current directory, mounted-on file, or active text segment).
133A request was made to an exclusive access device that was already in use.
134.en 17 EEXIST "File exists
135An existing file was mentioned in an inappropriate context,
136e.g.,
137.IR link .
138.en 18 EXDEV "Cross-device link
139A hard link to a file on another device
140was attempted.
141.en 19 ENODEV "Operation not supported by device
142An attempt was made to apply an inappropriate
143system call to a device,
144e.g., to read a write-only device,
145or the device is not configured by the system.
146.en 20 ENOTDIR "Not a directory
147A non-directory was specified where a directory
148is required,
149for example, in a path name or
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,
160or some other argument inappropriate for the call.
161Also set by math functions, (see
162.IR math (3)).
163.en 23 ENFILE "Too many open files in system
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
169As released, the limit on the number of
170open files per process is 64.
171.IR Getdtablesize (2)
172will obtain the current limit.
173Customary configuration limit on most other UNIX systems
174is 20 per process.
175.en 25 ENOTTY "Inappropriate ioctl for device
176The file mentioned in an
177.I ioctl
178is not a terminal or one of the
179devices to which this call applies.
180.en 26 ETXTBSY "Text file busy
181An attempt to execute a pure-procedure
182program that is currently open for writing.
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
187.if t 2\u\s-231\s+2\d
188.if n 2.1E9
189bytes).
190.en 28 ENOSPC "No space left on device
191A
192.I write
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.
199.en 29 ESPIPE "Illegal seek
200An
201.I lseek
202was issued to a socket or pipe.
203This error may also be issued for
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
210An attempt to make more than 32767 hard links to a file.
211.en 32 EPIPE "Broken pipe
212A write on a pipe or socket for which there is no process
213to read the data.
214This condition normally generates a signal;
215the error is returned if the signal is caught or ignored.
216.en 33 EDOM "Numerical argument out of domain
217The argument of a function in the math package (3M)
218is out of the domain of the function.
219.en 34 ERANGE "Numerical result out of range
220The value of a function in the math package (3M)
221is unrepresentable within machine precision.
222.en 35 EAGAIN "Resource temporarily unavailable
223This is a temporary condition and later calls to the
224same routine may complete normally.
225.en 36 EINPROGRESS "Operation now in progress"
226An operation that takes a long time to complete (such as
227a \fIconnect\fP(2)) was attempted on a non-blocking object (see
228\fIfcntl\fP(2)).
229.en 37 EALREADY "Operation already in progress"
230An operation was attempted on a non-blocking object that already
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"
237A message sent on a socket was larger than the internal message buffer
238or some other network limit.
239.en 41 EPROTOTYPE "Protocol wrong type for socket"
240A protocol was specified that does not support the semantics of the
241socket type requested. For example, you cannot use the ARPA Internet
242UDP protocol with type SOCK_STREAM.
243.en 42 ENOPROTOOPT "Protocol not available
244A bad option or level was specified in a
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.
262For example, you shouldn't necessarily expect to be able to use NS
263addresses with ARPA Internet protocols.
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
279results from a loss of the connection on the remote socket
280due to a timeout or a reboot.
281.en 55 ENOBUFS "No buffer space available"
282An operation on a socket or pipe was not performed because
283the system lacked sufficient buffer space or because a queue was full.
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
293when already connected.
294.en 57 ENOTCONN "Socket is not connected"
295An request to send or receive data was disallowed because
296the socket is not connected and (when sending on a datagram socket)
297no address was supplied.
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.
303.en 60 ETIMEDOUT "Connection timed out"
304A
305.I connect
306or
307.I send
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
314to a service that is inactive on the foreign host.
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"
318A component of a path name exceeded 255 (MAXNAMELEN) characters, or an entire
319path name exceeded 1023 (MAXPATHLEN-1) characters.
320.en 64 EHOSTDOWN "Host is down"
321A socket operation failed because the destination host was down.
322.en 65 EHOSTUNREACH "No route to host"
323A socket operation was attempted to an unreachable host.
324.en 66 ENOTEMPTY "Directory not empty"
325A directory with entries other than \*(lq.\*(rq and \*(lq..\*(rq
326was supplied to a remove directory or rename call.
327.en 67 EPROCLIM "Too many processes"
328.en 68 EUSERS "Too many users"
329The quota system ran out of table entries.
330.en 69 EDQUOT "Disc quota exceeded"
331A
332.I write
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.
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.
363.SH DEFINITIONS
364.TP 5
365Process ID
366.br
367Each active process in the system is uniquely identified by a positive
368integer called a process ID. The range of this ID is from 0 to 30000.
369.TP 5
370Parent process ID
371.br
372A new process is created by a currently active process; (see
373.IR fork (2)).
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
380ID of the group leader. This grouping permits the signaling of related
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;
391(see
392.IR csh (1)
393and
394.IR tty (4)).
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.
400.IP
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
409of the process that created it.
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
420file (possibly by one its ancestors) (see
421.IR execve (2)).
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
446.IR open (2)
447or
448.IR dup (2),
449or when a socket is created by
450.IR pipe (2),
451.IR socket (2)
452or
453.IR socketpair (2),
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
459Names consisting of up to 255 (MAXNAMELEN) characters may be used to name
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.
475The total length of a path name must be less than 1024 (MAXPATHLEN) characters.
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
486A directory is a special type of file that contains entries
487that are references to other files.
488Directory entries are called links. By convention, a directory
489contains at least two links, . and .., referred to as
490.I dot
491and
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)