xref: /csrg-svn/lib/libc/sys/intro.2 (revision 58263)
147208Scael.\" Copyright (c) 1980,1983,1986,1991 Regents of the University of California.
247208Scael.\" All rights reserved.
320110Smckusick.\"
447208Scael.\" %sccs.include.redist.man%
520110Smckusick.\"
6*58263Smckusick.\"     @(#)intro.2	6.15 (Berkeley) 02/26/93
747208Scael.\"
847208Scael.Dd
947208Scael.Dt INTRO 2
1047208Scael.Os BSD 4
1147208Scael.Sh NAME
1247208Scael.Nm intro
1347208Scael.Nd introduction to system calls and error numbers
1447208Scael.Sh SYNOPSIS
15*58263Smckusick.Fd #include <sys/errno.h>
1647208Scael.Sh DESCRIPTION
1744667SkarelsThis section provides an overview of the system calls,
1844667Skarelstheir error returns, and other common definitions and concepts.
1947208Scael.\".Pp
2047208Scael.\".Sy System call restart
2147208Scael.\".Pp
2244667Skarels.\"<more later...>
2347208Scael.Sh DIAGNOSTICS
2447208ScaelNearly all of the system calls provide an error number in the external
2547208Scaelvariable
2647208Scael.Va errno ,
2747208Scaelwhich is defined as:
2847208Scael.Pp
2947208Scael.Dl extern int errno
3047208Scael.Pp
3147208ScaelWhen a system call detects an error,
3247208Scaelit returns an integer value
3347208Scaelindicating failure (usually -1)
3447208Scaeland sets the variable
3547208Scael.Va errno
3647208Scaelaccordingly.
3747208Scael<This allows interpretation of the failure on receiving
3847208Scaela -1 and to take action accordingly.>
3947208ScaelSuccessful calls never set
4047208Scael.Va errno ;
4147208Scaelonce set, it remains until another error occurs.
4247208ScaelIt should only be examined after an error.
4328185SkarelsNote that a number of system calls overload the meanings of these
4428185Skarelserror numbers, and that the meanings must be interpreted according
4528185Skarelsto the type and circumstances of the call.
4647208Scael.Pp
4720111SmckusickThe following is a complete list of the errors and their
4820111Smckusicknames as given in
4947208Scael.Aq Pa sys/errno.h .
5047208Scael.Bl -hang -width Ds
5147208Scael.It Er 0 Em "Error 0" .
5247208ScaelNot used.
5347208Scael.It Er 1 EPERM Em "Operation not permitted .
5447208ScaelAn attempt was made to perform an operation limited to processes
5547208Scaelwith appropriate privileges or to the owner of a file or other
5647208Scaelresources.
5747208Scael.It Er 2 ENOENT Em "No such file or directory" .
5847208ScaelA component of a specified pathname did not exist, or the
5947208Scaelpathname was an empty string.
6047208Scael.It Er 3 ESRCH Em "No such process" .
6147208ScaelNo process could be found corresponding to that specified by the given
6247208Scaelprocess ID.
6347208Scael.It Er 4 EINTR Em "Interrupted function call" .
6447208ScaelAn asynchronous signal (such as
6547208Scael.Dv SIGINT
6620110Smckusickor
6747208Scael.Dv SIGQUIT )
6847208Scaelwas caught by the process during the execution of an interruptible
6947208Scaelfunction. If the signal handler performs a normal return, the
70*58263Smckusickinterrupted function call will seem to have returned the error condition.
7147208Scael.It Er 5 EIO Em "Input/output error" .
7247208ScaelSome physical input or output error occurred.
7347208ScaelThis error not be reported until a subsequent operation on the same file
7447208Scaeldescriptor and may be lost (over written) by any subsequent errors.
7547208Scael.It Er 6 ENXIO Em "\&No such device or address" .
7647208ScaelInput or output on a special file referred to a device that did not
7747208Scaelexist, or
7847208Scaelmade a request beyond the limits of the device.
7947208ScaelThis error may also occur when, for example,
8047208Scaela tape drive is not online or no disk pack is
8147208Scaelis loaded on a drive.
8247208Scael.It Er 7 E2BIG Em "Arg list too long" .
8347208ScaelThe number of bytes used for the argument and environment
8447208Scaellist of the new process exceeded the current limit
8547208Scaelof 20480 bytes
8647208Scael.Pf ( Dv NCARGS
8747208Scaelin
8847208Scael.Aq Pa sys/param.h ) .
8947208Scael.It Er 8 ENOEXEC Em "Exec format error" .
9047208ScaelA request was made to execute a file
9123809Ssechrestthat, although it has the appropriate permissions,
9247208Scaelwas not in the format required for an
9347208Scaelexecutable file.
9447208Scael.It Er 9 EBADF Em "Bad file descriptor" .
9547208ScaelA file descriptor argument was out of range, referred to no open file,
9647208Scaelor a read (write) request was made to a file that was only open for
9747208Scaelwriting (reading).
9847208Scael.It Er 10 ECHILD Em "\&No child processes" .
9947208ScaelA
10047208Scael.Xr wait
10147208Scaelor
10247208Scael.Xr waitpid
10347208Scaelfunction was executed by a process that had no existing or unwaited-for
10447208Scaelchild processes.
10547208Scael.It Er 11 EDEADLK Em "Resource deadlock avoided" .
10644763StrentAn attempt was made to lock a system resource that
10744763Strentwould have resulted in a deadlock situation.
108*58263Smckusick.It Er 12 ENOMEM Em "Cannot allocate memory" .
10947208ScaelThe new process image required more memory than was allowed by the hardware
11047208Scaelor by system-imposed memory management constraints.
11147208ScaelA lack of swap space is normally temporary; however,
11247208Scaela lack of core is not.
11328185SkarelsSoft limits may be increased to their corresponding hard limits.
11447208Scael.It Er 13 EACCES Em "Permission denied" .
11520110SmckusickAn attempt was made to access a file in a way forbidden
11647208Scaelby its file access permissions.
11747208Scael.It Er 14 EFAULT Em "Bad address" .
11847208ScaelThe system detected an invalid address in attempting to
11947208Scaeluse an argument of a call.
12047208Scael.It Er 15 ENOTBLK Em "Not a block device" .
12147208ScaelA block device operation was attempted on a non-block device or file.
12247208Scael.It Er 16 EBUSY Em "Resource busy" .
12347208ScaelAn attempt to use a system resource which was in use at the time
12447208Scaelin a manner which would have conflicted with the request.
12547208Scael.It Er 17 EEXIST Em "File exists" .
12620110SmckusickAn existing file was mentioned in an inappropriate context,
12747208Scaelfor instance, as the new link name in a
12847208Scael.Xr link
12947208Scaelfunction.
13047208Scael.It Er 18 EXDEV Em "Improper link" .
13147208ScaelA hard link to a file on another file system
13220110Smckusickwas attempted.
13347208Scael.It Er 19 ENODEV Em "Operation not supported by device" .
13420110SmckusickAn attempt was made to apply an inappropriate
13547208Scaelfunction to a device,
13647208Scaelfor example,
13747208Scaeltrying to read a write-only device such as a printer.
13847208Scael.It Er 20 ENOTDIR Em "Not a directory" .
13947208ScaelA component of the specified pathname existed, but it was
14047208Scaelnot a directory, when a directory was expected.
14147208Scael.It Er 21 EISDIR Em "Is a directory" .
14247208ScaelAn attempt was made to open a directory with write mode specified.
14347208Scael.It Er 22 EINVAL Em "Invalid argument" .
14447208ScaelSome invalid argument was supplied. (For example,
14547208Scaelspecifying an undefined signal to a
14647208Scael.Xr signal
14747208Scaelor
14847208Scael.Xr kill
14947208Scaelfunction).
15047208Scael.It Er 23 ENFILE Em "Too many open files in system" .
15147208ScaelMaximum number of file descriptors allowable on the system
15247208Scaelhas been reached and a requests for an open cannot be satisfied
15347208Scaeluntil at least one has been closed.
15447208Scael.It Er 24 EMFILE Em "Too many open files" .
15547208Scael<As released, the limit on the number of
15647208Scaelopen files per process is 64.>
15747208Scael.Xr Getdtablesize 2
15828185Skarelswill obtain the current limit.
15947208Scael.It Er 25 ENOTTY Em "Inappropriate ioctl for device" .
16047208ScaelA control function (see
16147208Scael.Xr ioctl 2 )
16247208Scaelwas attempted for a file or
16347208Scaelspecial device for which the operation was inappropriate.
16447208Scael.It Er 26 ETXTBSY Em "Text file busy" .
16547208ScaelThe new process was a pure procedure (shared text) file
16647208Scaelwhich was open for writing by another process, or
16747208Scaelthe pure procedure file was being executed an
16847208Scael.Xr open
16947208Scaelcall requested write access.
17047208Scael.It Er 27 EFBIG Em "File too large" .
17120110SmckusickThe size of a file exceeded the maximum (about
17228185Skarels.if t 2\u\s-231\s+2\d
17328185Skarels.if n 2.1E9
17420110Smckusickbytes).
17547208Scael.It Er 28 ENOSPC Em "Device out of space" .
17624439SmckusickA
17747208Scael.Xr write
17824439Smckusickto an ordinary file, the creation of a
17924439Smckusickdirectory or symbolic link, or the creation of a directory
18024439Smckusickentry failed because no more disk blocks are available
18124439Smckusickon the file system, or the allocation of an inode for a newly
18224439Smckusickcreated file failed because no more inodes are available
18324439Smckusickon the file system.
18447208Scael.It Er 29 ESPIPE Em "Illegal seek" .
18520110SmckusickAn
18647208Scael.Xr lseek
18747208Scaelfunction was issued on a socket, pipe or
18847208Scael.Tn FIFO .
18947208Scael.It Er 30 EROFS Em "Read-only file system" .
19047208ScaelAn attempt was made to modify a file or directory
19120110Smckusickwas made
19247208Scaelon a file system that was read-only at the time.
19347208Scael.It Er 31 EMLINK Em "Too many links" .
19447208ScaelMaximum allowable hard links to a single file has been exceeded (limit
19547208Scaelof 32767 hard links per file).
19647208Scael.It Er 32 EPIPE Em "Broken pipe" .
19747208ScaelA write on a pipe, socket or
19847208Scael.Tn FIFO
19947208Scaelfor which there is no process
20020110Smckusickto read the data.
20147208Scael.It Er 33 EDOM Em "Numerical argument out of domain" .
20247208ScaelA numerical input argument was outside the defined domain of the mathematical
20347208Scaelfunction.
20447208Scael.It Er 34 ERANGE Em "Numerical result out of range" .
20547208ScaelA numerical result of the function was to large to fit in the
20647208Scaelavailable space (perhaps exceeded precision).
20747208Scael.It Er 35 EAGAIN Em "Resource temporarily unavailable" .
20844763StrentThis is a temporary condition and later calls to the
20944763Strentsame routine may complete normally.
21047208Scael.It Er 36 EINPROGRESS Em "Operation now in progress" .
21123809SsechrestAn operation that takes a long time to complete (such as
21247208Scaela
21347208Scael.Xr connect 2 )
21447208Scaelwas attempted on a non-blocking object (see
21547208Scael.Xr fcntl 2 ) .
21647208Scael.It Er 37 EALREADY Em "Operation already in progress" .
21723809SsechrestAn operation was attempted on a non-blocking object that already
21820111Smckusickhad an operation in progress.
21947208Scael.It Er 38 ENOTSOCK Em "Socket operation on non-socket" .
22020111SmckusickSelf-explanatory.
22147208Scael.It Er 39 EDESTADDRREQ Em "Destination address required" .
22220111SmckusickA required address was omitted from an operation on a socket.
22347208Scael.It Er 40 EMSGSIZE Em "Message too long" .
22428185SkarelsA message sent on a socket was larger than the internal message buffer
22528185Skarelsor some other network limit.
22647208Scael.It Er 41 EPROTOTYPE Em "Protocol wrong type for socket" .
22723809SsechrestA protocol was specified that does not support the semantics of the
22847208Scaelsocket type requested. For example, you cannot use the
22947208Scael.Tn ARPA
23047208ScaelInternet
23147208Scael.Tn UDP
23247208Scaelprotocol with type
23347208Scael.Dv SOCK_STREAM .
23447208Scael.It Er 42 ENOPROTOOPT Em "Protocol not available" .
23528185SkarelsA bad option or level was specified in a
23647208Scael.Xr getsockopt 2
23720111Smckusickor
23847208Scael.Xr setsockopt 2
23920111Smckusickcall.
24047208Scael.It Er 43 EPROTONOSUPPORT Em "Protocol not supported" .
24120111SmckusickThe protocol has not been configured into the
24220111Smckusicksystem or no implementation for it exists.
24347208Scael.It Er 44 ESOCKTNOSUPPORT Em "Socket type not supported" .
24420111SmckusickThe support for the socket type has not been configured into the
24520111Smckusicksystem or no implementation for it exists.
24648433Skarels.It Er 45 EOPNOTSUPP Em "Operation not supported" .
24748433SkarelsThe attempted operation is not supported for the type of object referenced.
24848433SkarelsUsually this occurs when a file descriptor refers to a file or socket
24948433Skarelsthat cannot support this operation,
25048433Skarelsfor example, trying to
25147208Scael.Em accept
25247208Scaela connection on a datagram socket.
25347208Scael.It Er 46 EPFNOSUPPORT Em "Protocol family not supported" .
25420111SmckusickThe protocol family has not been configured into the
25520111Smckusicksystem or no implementation for it exists.
25647208Scael.It Er 47 EAFNOSUPPORT Em "Address family not supported by protocol family" .
25720111SmckusickAn address incompatible with the requested protocol was used.
25847208ScaelFor example, you shouldn't necessarily expect to be able to use
25947208Scael.Tn NS
26047208Scaeladdresses with
26147208Scael.Tn ARPA
26247208ScaelInternet protocols.
26347208Scael.It Er 48 EADDRINUSE Em "Address already in use" .
26420111SmckusickOnly one usage of each address is normally permitted.
26547208Scael.It Er 49 EADDRNOTAVAIL Em "Cannot assign requested address" .
26620111SmckusickNormally results from an attempt to create a socket with an
26720111Smckusickaddress not on this machine.
26847208Scael.It Er 50 ENETDOWN Em "Network is down" .
26920111SmckusickA socket operation encountered a dead network.
27047208Scael.It Er 51 ENETUNREACH Em "Network is unreachable" .
27120111SmckusickA socket operation was attempted to an unreachable network.
27247208Scael.It Er 52 ENETRESET Em "Network dropped connection on reset" .
27320111SmckusickThe host you were connected to crashed and rebooted.
27447208Scael.It Er 53 ECONNABORTED Em "Software caused connection abort" .
27520111SmckusickA connection abort was caused internal to your host machine.
27647208Scael.It Er 54 ECONNRESET Em "Connection reset by peer" .
27720111SmckusickA connection was forcibly closed by a peer.  This normally
27828185Skarelsresults from a loss of the connection on the remote socket
27928185Skarelsdue to a timeout or a reboot.
28047208Scael.It Er 55 ENOBUFS Em "\&No buffer space available" .
28120111SmckusickAn operation on a socket or pipe was not performed because
28228185Skarelsthe system lacked sufficient buffer space or because a queue was full.
28347208Scael.It Er 56 EISCONN Em "Socket is already connected" .
28420111SmckusickA
28547208Scael.Xr connect
28620111Smckusickrequest was made on an already connected socket; or,
28720111Smckusicka
28847208Scael.Xr sendto
28920111Smckusickor
29047208Scael.Xr sendmsg
29120111Smckusickrequest on a connected socket specified a destination
29228185Skarelswhen already connected.
29347208Scael.It Er 57 ENOTCONN Em "Socket is not connected" .
29420111SmckusickAn request to send or receive data was disallowed because
29528185Skarelsthe socket is not connected and (when sending on a  datagram socket)
29628185Skarelsno address was supplied.
29747208Scael.It Er 58 ESHUTDOWN Em "Cannot send after socket shutdown" .
29820111SmckusickA request to send data was disallowed because the socket
29920111Smckusickhad already been shut down with a previous
30047208Scael.Xr shutdown 2
30120111Smckusickcall.
30247208Scael.It Er 60 ETIMEDOUT Em "Connection timed out" .
30320111SmckusickA
30447208Scael.Xr connect
30528185Skarelsor
30647208Scael.Xr send
30720111Smckusickrequest failed because the connected party did not
30820111Smckusickproperly respond after a period of time.  (The timeout
30920111Smckusickperiod is dependent on the communication protocol.)
31047208Scael.It Er 61 ECONNREFUSED Em "Connection refused" .
31120111SmckusickNo connection could be made because the target machine actively
31220111Smckusickrefused it.  This usually results from trying to connect
31323809Ssechrestto a service that is inactive on the foreign host.
31447208Scael.It Er 62 ELOOP Em "Too many levels of symbolic links" .
31520111SmckusickA path name lookup involved more than 8 symbolic links.
31647208Scael.It Er 63 ENAMETOOLONG Em "File name too long" .
31747208ScaelA component of a path name exceeded 255
31847208Scael.Pq Dv MAXNAMELEN
31947208Scaelcharacters, or an entire
32047208Scaelpath name exceeded 1023
32147208Scael.Pq Dv MAXPATHLEN Ns -1
32247208Scaelcharacters.
32347208Scael.It Er 64 EHOSTDOWN Em "Host is down" .
32420112SmckusickA socket operation failed because the destination host was down.
32547208Scael.It Er 65 EHOSTUNREACH Em "No route to host" .
32620112SmckusickA socket operation was attempted to an unreachable host.
32747208Scael.It Er 66 ENOTEMPTY Em "Directory not empty" .
32847208ScaelA directory with entries other than
32947208Scael.Ql \&.
33047208Scaeland
33147208Scael.Ql \&..
33220111Smckusickwas supplied to a remove directory or rename call.
33347208Scael.It Er 67 EPROCLIM Em "Too many processes" .
33447208Scael.It Er 68 EUSERS Em "Too many users" .
33535335SbosticThe quota system ran out of table entries.
33647208Scael.It Er 69 EDQUOT Em "Disc quota exceeded" .
33724439SmckusickA
33847208Scael.Xr write
33924439Smckusickto an ordinary file, the creation of a
34024439Smckusickdirectory or symbolic link, or the creation of a directory
34124439Smckusickentry failed because the user's quota of disk blocks was
34224439Smckusickexhausted, or the allocation of an inode for a newly
34324439Smckusickcreated file failed because the user's quota of inodes
34424439Smckusickwas exhausted.
34547208Scael.It Er 70 ESTALE Em "Stale NFS file handle" .
34647208ScaelAn attempt was made to access an open file (on an
34747208Scael.Tn NFS
34847208Scaelfilesystem)
34944763Strentwhich is now unavailable as referenced by the file descriptor.
35047208ScaelThis may indicate the file was deleted on the
35147208Scael.Tn NFS
35247208Scaelserver or some
353*58263Smckusickother catastrophic event occurred.
35447208Scael.It Er 72 EBADRPC Em "RPC struct is bad" .
35547208ScaelExchange of
35647208Scael.Tn RPC
35747208Scaelinformation was unsuccessful.
35847208Scael.It Er 73 ERPCMISMATCH Em "RPC version wrong" .
35947208ScaelThe version of
36047208Scael.Tn RPC
36147208Scaelon the remote peer is not compatible with
36244763Strentthe local version.
36347208Scael.It Er 74 EPROGUNAVAIL Em "RPC prog. not avail" .
36444763StrentThe requested program is not registered on the remote host.
36547208Scael.It Er 75 EPROGMISMATCH Em "Program version wrong" .
36644763StrentThe requested version of the program is not available
36747208Scaelon the remote host
36847208Scael.Pq Tn RPC .
36947208Scael.It Er 76 EPROCUNAVAIL Em "Bad procedure for program" .
37047208ScaelAn
37147208Scael.Tn RPC
37247208Scaelcall was attempted for a procedure which doesn't exist
37344763Strentin the remote program.
37447208Scael.It Er 77 ENOLCK Em "No locks available" .
37544763StrentA system-imposed limit on the number of simultaneous file
37644763Strentlocks was reached.
37747208Scael.It Er 78 ENOSYS Em "Function not implemented" .
37844763StrentAttempted a system call that is not available on this
37944763Strentsystem.
38047208Scael.Sh DEFINITIONS
38147208Scael.Bl -tag -width Ds
38247208Scael.It  Process ID .
38347208ScaelEach active process in the system is uniquely identified by a non-negative
38428185Skarelsinteger called a process ID.  The range of this ID is from 0 to 30000.
38547208Scael.It  Parent process ID
38628635SkjdA new process is created by a currently active process; (see
38747208Scael.Xr fork 2 ) .
38820111SmckusickThe parent process ID of a process is the process ID of its creator.
38947208Scael.It  Process Group ID
39020111SmckusickEach active process is a member of a process group that is identified by
39147208Scaela non-negative integer called the process group ID.  This is the process
39228185SkarelsID of the group leader.  This grouping permits the signaling of related
39320111Smckusickprocesses (see
394*58263Smckusick.Xr termios 4 )
39520111Smckusickand the job control mechanisms of
39647208Scael.Xr csh 1 .
397*58263Smckusick.It Session
398*58263SmckusickA session is a set of one or more process groups.
399*58263SmckusickA session is created by a successful call to
400*58263Smckusick.Xr setsid 2 ,
401*58263Smckusickwhich causes the caller to become the only member of the only process
402*58263Smckusickgroup in the new session.
403*58263SmckusickThe process is known as the session leader.
404*58263SmckusickOnly a session leader may acquire a terminal as its controlling terminal (see
405*58263Smckusick.Xr termios 4 ) .
406*58263SmckusickA session leader with a controlling terminal is known as a controlling process.
407*58263Smckusick.It  "Tty Process Group ID"
408*58263SmckusickA terminal may be acquired by a session leader as its controlling terminal.
409*58263SmckusickOnce a terminal is associated with a session, any of the process groups
410*58263Smckusickwithin the session may be placed into the foreground by setting
411*58263Smckusickthe terminal process group ID to the ID of the process group.
412*58263SmckusickThis facility is used
41320111Smckusickto arbitrate between multiple jobs contending for the same terminal;
41428635Skjd(see
41547208Scael.Xr csh 1
41620110Smckusickand
41747208Scael.Xr tty 4 ) .
41850486Scael.It "Real User ID and Real Group ID"
41920111SmckusickEach user on the system is identified by a positive integer
42020111Smckusicktermed the real user ID.
42147208Scael.Pp
42220111SmckusickEach user is also a member of one or more groups.
42320111SmckusickOne of these groups is distinguished from others and
42420111Smckusickused in implementing accounting facilities.  The positive
42520111Smckusickinteger corresponding to this distinguished group is termed
42620111Smckusickthe real group ID.
42747208Scael.Pp
42820111SmckusickAll processes have a real user ID and real group ID.
42920111SmckusickThese are initialized from the equivalent attributes
43023809Ssechrestof the process that created it.
431*58263Smckusick.It "Effective User Id, Effective Group Id, and Group Access List"
432*58263SmckusickAccess to system resources is governed by two values:
433*58263Smckusickthe effective user ID, and the group access list.
434*58263SmckusickThe first member of the group access list is also known as the
435*58263Smckusickeffective group ID.
436*58263Smckusick(In POSIX.1, the group access list is known as the set of supplementary
437*58263Smckusickgroup IDs, and it is unspecified whether the effective group ID is
438*58263Smckusicka member of the list.)
43947208Scael.Pp
44020111SmckusickThe effective user ID and effective group ID are initially the
44120111Smckusickprocess's real user ID and real group ID respectively.  Either
44220111Smckusickmay be modified through execution of a set-user-ID or set-group-ID
44328635Skjdfile (possibly by one its ancestors) (see
44447208Scael.Xr execve 2 ) .
445*58263SmckusickBy convention, the effective group ID (the first member of the group access
446*58263Smckusicklist) is duplicated, so that the execution of a set-group-ID program
447*58263Smckusickdoes not result in the loss of the original (real) group ID.
44847208Scael.Pp
449*58263SmckusickThe group access list is a set of group ID's
45020111Smckusickused only in determining resource accessibility.  Access checks
45120111Smckusickare performed as described below in ``File Access Permissions''.
452*58263Smckusick.It  "Saved Set User ID and Saved Set Group ID"
453*58263SmckusickWhen a process executes a new file, the effective user ID is set
454*58263Smckusickto the owner of the file if the file is set-user-ID, and the effective
455*58263Smckusickgroup ID (first element of the group access list) is set to the group
456*58263Smckusickof the file if the file is set-group-ID.
457*58263SmckusickThe effective user ID of the process is then recorded as the saved set-user-ID,
458*58263Smckusickand the effective group ID of the process is recorded as the saved set-group-ID.
459*58263SmckusickThese values may be used to regain those values as the effective user
460*58263Smckusickor group ID after reverting to the real ID (see
461*58263Smckusick.Xr setuid 2 ) .
462*58263Smckusick(In POSIX.1, the saved set-user-ID and saved set-group-ID are optional,
463*58263Smckusickand are used in setuid and setgid, but this does not work as desired
464*58263Smckusickfor the super-user.)
46547208Scael.It  Super-user
46620111SmckusickA process is recognized as a
46747208Scael.Em super-user
46820111Smckusickprocess and is granted special privileges if its effective user ID is 0.
46947208Scael.It  Special Processes
47020111SmckusickThe processes with a process ID's of 0, 1, and 2 are special.
47120111SmckusickProcess 0 is the scheduler.  Process 1 is the initialization process
47247208Scael.Xr init ,
47320111Smckusickand is the ancestor of every other process in the system.
47420111SmckusickIt is used to control the process structure.
47520111SmckusickProcess 2 is the paging daemon.
47647208Scael.It  Descriptor
47720111SmckusickAn integer assigned by the system when a file is referenced
47820111Smckusickby
47947208Scael.Xr open 2
48028185Skarelsor
48147208Scael.Xr dup 2 ,
48228185Skarelsor when a socket is created by
48347208Scael.Xr pipe 2 ,
48447208Scael.Xr socket 2
48520111Smckusickor
48647208Scael.Xr socketpair 2 ,
48720111Smckusickwhich uniquely identifies an access path to that file or socket from
48820111Smckusicka given process or any of its children.
48947208Scael.It  File Name
49047208ScaelNames consisting of up to 255
49147208Scael.Pq Dv MAXNAMELEN
49247208Scaelcharacters may be used to name
49320111Smckusickan ordinary file, special file, or directory.
49447208Scael.Pp
49547208ScaelThese characters may be selected from the set of all
49647208Scael.Tn ASCII
49747208Scaelcharacter
49847208Scaelexcluding 0 (NUL) and the
49947208Scael.Tn ASCII
50047208Scaelcode for
50147208Scael.Ql \&/
50247208Scael(slash).  (The parity bit,
50347208Scaelbit 7, must be 0.)
50447208Scael.Pp
50547208ScaelNote that it is generally unwise to use
50647208Scael.Ql \&* ,
50747208Scael.Ql \&? ,
50847208Scael.Ql \&[
50947208Scaelor
51047208Scael.Ql \&]
51147208Scaelas part of
51220111Smckusickfile names because of the special meaning attached to these characters
51320111Smckusickby the shell.
51447208Scael.It  Path Name
51550486ScaelA path name is a
51650486Scael.Tn NUL Ns -terminated
51750486Scaelcharacter string starting with an
51847208Scaeloptional slash
51947208Scael.Ql \&/ ,
52047208Scaelfollowed by zero or more directory names separated
52120111Smckusickby slashes, optionally followed by a file name.
52247208ScaelThe total length of a path name must be less than 1024
52347208Scael.Pq Dv MAXPATHLEN
52447208Scaelcharacters.
52547208Scael.Pp
52620111SmckusickIf a path name begins with a slash, the path search begins at the
52747208Scael.Em root
52820111Smckusickdirectory.
52920111SmckusickOtherwise, the search begins from the current working directory.
53047208ScaelA slash by itself names the root directory.  An empty
53120111Smckusickpathname refers to the current directory.
53247208Scael.It  Directory
53323809SsechrestA directory is a special type of file that contains entries
53423809Ssechrestthat are references to other files.
53520111SmckusickDirectory entries are called links.  By convention, a directory
53647208Scaelcontains at least two links,
53747208Scael.Ql \&.
53820110Smckusickand
53947208Scael.Ql \&.. ,
54047208Scaelreferred to as
54147208Scael.Em dot
54247208Scaeland
54347208Scael.Em dot-dot
54420111Smckusickrespectively.  Dot refers to the directory itself and
54520111Smckusickdot-dot refers to its parent directory.
54650486Scael.It "Root Directory and Current Working Directory"
54720111SmckusickEach process has associated with it a concept of a root directory
54820111Smckusickand a current working directory for the purpose of resolving path
54920111Smckusickname searches.  A process's root directory need not be the root
55020111Smckusickdirectory of the root file system.
55147208Scael.It  File Access Permissions
55220111SmckusickEvery file in the file system has a set of access permissions.
55320111SmckusickThese permissions are used in determining whether a process
55420111Smckusickmay perform a requested operation on the file (such as opening
55520111Smckusicka file for writing).  Access permissions are established at the
55620111Smckusicktime a file is created.  They may be changed at some later time
55720111Smckusickthrough the
55847208Scael.Xr chmod 2
55920111Smckusickcall.
56047208Scael.Pp
56120111SmckusickFile access is broken down according to whether a file may be: read,
56220111Smckusickwritten, or executed.  Directory files use the execute
56320111Smckusickpermission to control if the directory may be searched.
56447208Scael.Pp
56520111SmckusickFile access permissions are interpreted by the system as
56620111Smckusickthey apply to three different classes of users: the owner
56720111Smckusickof the file, those users in the file's group, anyone else.
56820111SmckusickEvery file has an independent set of access permissions for
56920111Smckusickeach of these classes.  When an access check is made, the system
57020111Smckusickdecides if permission should be granted by checking the access
57120111Smckusickinformation applicable to the caller.
57247208Scael.Pp
57320111SmckusickRead, write, and execute/search permissions on
57420111Smckusicka file are granted to a process if:
57547208Scael.Pp
57647208ScaelThe process's effective user ID is that of the super-user. (Note:
57747208Scaeleven the super-user cannot execute a non-executable file.)
57847208Scael.Pp
57920111SmckusickThe process's effective user ID matches the user ID of the owner
58020111Smckusickof the file and the owner permissions allow the access.
58147208Scael.Pp
58220111SmckusickThe process's effective user ID does not match the user ID of the
58320111Smckusickowner of the file, and either the process's effective
58420111Smckusickgroup ID matches the group ID
58520111Smckusickof the file, or the group ID of the file is in
58620111Smckusickthe process's group access list,
58720111Smckusickand the group permissions allow the access.
58847208Scael.Pp
58920111SmckusickNeither the effective user ID nor effective group ID
59020111Smckusickand group access list of the process
59120111Smckusickmatch the corresponding user ID and group ID of the file,
59220111Smckusickbut the permissions for ``other users'' allow access.
59347208Scael.Pp
59420111SmckusickOtherwise, permission is denied.
59547208Scael.It  Sockets and Address Families
59647208Scael.Pp
59720111SmckusickA socket is an endpoint for communication between processes.
59820111SmckusickEach socket has queues for sending and receiving data.
59947208Scael.Pp
60020111SmckusickSockets are typed according to their communications properties.
60120111SmckusickThese properties include whether messages sent and received
60220111Smckusickat a socket require the name of the partner, whether communication
60320111Smckusickis reliable, the format used in naming message recipients, etc.
60447208Scael.Pp
60520111SmckusickEach instance of the system supports some
60620111Smckusickcollection of socket types; consult
60747208Scael.Xr socket 2
60820111Smckusickfor more information about the types available and
60920111Smckusicktheir properties.
61047208Scael.Pp
61120111SmckusickEach instance of the system supports some number of sets of
61220111Smckusickcommunications protocols.  Each protocol set supports addresses
61320111Smckusickof a certain format.  An Address Family is the set of addresses
61420111Smckusickfor a specific group of protocols.  Each socket has an address
61520111Smckusickchosen from the address family in which the socket was created.
61647208Scael.Sh SEE ALSO
61720111Smckusickintro(3), perror(3)
618