1.\" $OpenBSD: intro.2,v 1.46 2011/01/21 08:20:17 lum Exp $ 2.\" $NetBSD: intro.2,v 1.6 1995/02/27 12:33:41 cgd Exp $ 3.\" 4.\" Copyright (c) 1980, 1983, 1986, 1991, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)intro.2 8.3 (Berkeley) 12/11/93 32.\" 33.Dd $Mdocdate: January 21 2011 $ 34.Dt INTRO 2 35.Os 36.Sh NAME 37.Nm intro 38.Nd introduction to system calls and error numbers 39.Sh SYNOPSIS 40.Fd #include <errno.h> 41.Sh DESCRIPTION 42The manual pages in section 2 provide an overview of the system calls, 43their error returns, and other common definitions and concepts. 44.\".Pp 45.\".Sy System call restart 46.\".Pp 47.\"<more later...> 48.Sh DIAGNOSTICS 49Nearly all of the system calls provide an error number in the external 50variable 51.Va errno , 52which is currently defined as: 53.Pp 54.Dl extern int errno; 55.Pp 56Portable applications must not depend on this definition, and should only 57use 58.Va errno 59as defined in 60.Aq Pa errno.h . 61When a system call detects an error, it returns an integer value 62indicating failure (usually \-1) and sets the variable 63.Va errno 64accordingly. 65(This allows interpretation of the failure on receiving 66a \-1 and to take action accordingly.) 67Successful calls never set 68.Va errno ; 69once set, it remains until another error occurs. 70It should only be examined after an error. 71Note that a number of system calls overload the meanings of these 72error numbers, and that the meanings must be interpreted according 73to the type and circumstances of the call. 74.Pp 75The following is a complete list of the errors and their 76names as given in 77.Aq Pa sys/errno.h . 78.Bl -hang -width Ds 79.It Er 0 Em "Error 0" . 80Not used. 81.It Er 1 EPERM Em "Operation not permitted" . 82An attempt was made to perform an operation limited to processes 83with appropriate privileges or to the owner of a file or other 84resources. 85.It Er 2 ENOENT Em "\&No such file or directory" . 86A component of a specified pathname did not exist, or the 87pathname was an empty string. 88.It Er 3 ESRCH Em "\&No such process" . 89No process could be found which corresponds to the given process ID. 90.It Er 4 EINTR Em "Interrupted system call" . 91An asynchronous signal (such as 92.Dv SIGINT 93or 94.Dv SIGQUIT ) 95was caught by the process during the execution of an interruptible 96function. 97If the signal handler performs a normal return, the 98interrupted function call will seem to have returned the error condition. 99.It Er 5 EIO Em "Input/output error" . 100Some physical input or output error occurred. 101This error will not be reported until a subsequent operation on the same file 102descriptor and may be lost (overwritten) by any subsequent errors. 103.It Er 6 ENXIO Em "Device not configured" . 104Input or output on a special file referred to a device that did not 105exist, or made a request beyond the limits of the device. 106This error may also occur when, for example, a tape drive is not online or 107no disk pack is loaded on a drive. 108.It Er 7 E2BIG Em "Argument list too long" . 109The number of bytes used for the argument and environment 110list of the new process exceeded the limit 111.Dv NCARGS 112(specified in 113.Aq Pa sys/param.h ) . 114.It Er 8 ENOEXEC Em "Exec format error" . 115A request was made to execute a file that, although it has the appropriate 116permissions, was not in the format required for an executable file. 117.It Er 9 EBADF Em "Bad file descriptor" . 118A file descriptor argument was out of range, referred to no open file, 119or a read (write) request was made to a file that was only open for 120writing (reading). 121.It Er 10 ECHILD Em "\&No child processes" . 122A 123.Xr wait 2 124or 125.Xr waitpid 2 126function was executed by a process that had no existing or unwaited-for 127child processes. 128.It Er 11 EDEADLK Em "Resource deadlock avoided" . 129An attempt was made to lock a system resource that 130would have resulted in a deadlock situation. 131.It Er 12 ENOMEM Em "Cannot allocate memory" . 132The new process image required more memory than was allowed by the hardware 133or by system-imposed memory management constraints. 134A lack of swap space is normally temporary; however, a lack of core is not. 135Soft limits may be increased to their corresponding hard limits. 136.It Er 13 EACCES Em "Permission denied" . 137An attempt was made to access a file in a way forbidden 138by its file access permissions. 139.It Er 14 EFAULT Em "Bad address" . 140The system detected an invalid address in attempting to 141use an argument of a call. 142.It Er 15 ENOTBLK Em "Block device required" . 143A block device operation was attempted on a non-block device or file. 144.It Er 16 EBUSY Em "Device busy" . 145An attempt to use a system resource which was in use at the time 146in a manner which would have conflicted with the request. 147.It Er 17 EEXIST Em "File exists" . 148An existing file was mentioned in an inappropriate context, 149for instance, as the new link name in a 150.Xr link 2 151function. 152.It Er 18 EXDEV Em "Cross-device link" . 153A hard link to a file on another file system was attempted. 154.It Er 19 ENODEV Em "Operation not supported by device" . 155An attempt was made to apply an inappropriate function to a device, 156for example, trying to read a write-only device such as a printer. 157.It Er 20 ENOTDIR Em "Not a directory" . 158A component of the specified pathname existed, but it was 159not a directory, when a directory was expected. 160.It Er 21 EISDIR Em "Is a directory" . 161An attempt was made to open a directory with write mode specified. 162.It Er 22 EINVAL Em "Invalid argument" . 163Some invalid argument was supplied. 164(For example, specifying an undefined signal to a 165.Xr signal 3 166or 167.Xr kill 2 168function). 169.It Er 23 ENFILE Em "Too many open files in system" . 170Maximum number of file descriptors allowable on the system 171has been reached and a request for an open cannot be satisfied 172until at least one has been closed. 173The 174.Xr sysctl 3 175variable 176.Va kern.maxfiles 177contains the current limit. 178.It Er 24 EMFILE Em "Too many open files" . 179The maximum number of file descriptors allowable for this process 180has been reached and a request for an open cannot be satisfied 181until at least one has been closed. 182.Xr getdtablesize 3 183will obtain the current limit. 184.It Er 25 ENOTTY Em "Inappropriate ioctl for device" . 185A control function (see 186.Xr ioctl 2 ) 187was attempted for a file or 188special device for which the operation was inappropriate. 189.It Er 26 ETXTBSY Em "Text file busy" . 190The new process was a pure procedure (shared text) file 191which was open for writing by another process, or 192while the pure procedure file was being executed an 193.Xr open 2 194call requested write access. 195.It Er 27 EFBIG Em "File too large" . 196The size of a file exceeded the maximum. 197(The system-wide maximum file size is 2**63 bytes. 198Each file system may impose a lower limit for files contained within it.) 199.It Er 28 ENOSPC Em "\&No space left on device" . 200A 201.Xr write 2 202to an ordinary file, the creation of a directory or symbolic link, 203or the creation of a directory entry failed because no more disk 204blocks were available on the file system, or the allocation of an 205inode for a newly created file failed because no more inodes were 206available on the file system. 207.It Er 29 ESPIPE Em "Illegal seek" . 208An 209.Xr lseek 2 210function was issued on a socket, pipe or 211.Tn FIFO . 212.It Er 30 EROFS Em "Read-only file system" . 213An attempt was made to modify a file or create a directory 214on a file system that was read-only at the time. 215.It Er 31 EMLINK Em "Too many links" . 216The maximum allowable number of hard links to a single file has been 217exceeded (see 218.Xr pathconf 2 219for how to obtain this value). 220.It Er 32 EPIPE Em "Broken pipe" . 221A write on a pipe, socket or 222.Tn FIFO 223for which there is no process to read the data. 224.It Er 33 EDOM Em "Numerical argument out of domain" . 225A numerical input argument was outside the defined domain of 226the mathematical function. 227.It Er 34 ERANGE Em "Result too large" . 228A result of the function was too large to fit in the 229available space (perhaps exceeded precision). 230.It Er 35 EAGAIN Em "Resource temporarily unavailable" . 231This is a temporary condition and later calls to the 232same routine may complete normally. 233.It Er 36 EINPROGRESS Em "Operation now in progress" . 234An operation that takes a long time to complete (such as a 235.Xr connect 2 ) 236was attempted on a non-blocking object (see 237.Xr fcntl 2 ) . 238.It Er 37 EALREADY Em "Operation already in progress" . 239An operation was attempted on a non-blocking object that already 240had an operation in progress. 241.It Er 38 ENOTSOCK Em "Socket operation on non-socket" . 242Self-explanatory. 243.It Er 39 EDESTADDRREQ Em "Destination address required" . 244A required address was omitted from an operation on a socket. 245.It Er 40 EMSGSIZE Em "Message too long" . 246A message sent on a socket was larger than the internal message buffer 247or some other network limit. 248.It Er 41 EPROTOTYPE Em "Protocol wrong type for socket" . 249A protocol was specified that does not support the semantics of the 250socket type requested. 251For example, you cannot use the 252.Tn ARPA 253Internet 254.Tn UDP 255protocol with type 256.Dv SOCK_STREAM . 257.It Er 42 ENOPROTOOPT Em "Protocol not available" . 258A bad option or level was specified in a 259.Xr getsockopt 2 260or 261.Xr setsockopt 2 262call. 263.It Er 43 EPROTONOSUPPORT Em "Protocol not supported" . 264The protocol has not been configured into the 265system or no implementation for it exists. 266.It Er 44 ESOCKTNOSUPPORT Em "Socket type not supported" . 267The support for the socket type has not been configured into the 268system or no implementation for it exists. 269.It Er 45 EOPNOTSUPP Em "Operation not supported" . 270The attempted operation is not supported for the type of object referenced. 271Usually this occurs when a file descriptor refers to a file or socket 272that cannot support this operation, for example, trying to 273.Em accept 274a connection on a datagram socket. 275.It Er 46 EPFNOSUPPORT Em "Protocol family not supported" . 276The protocol family has not been configured into the 277system or no implementation for it exists. 278.It Er 47 EAFNOSUPPORT Em "Address family not supported by protocol family" . 279An address incompatible with the requested protocol was used. 280For example, you shouldn't necessarily expect to be able to use 281.Tn NS 282addresses with 283.Tn ARPA 284Internet protocols. 285.It Er 48 EADDRINUSE Em "Address already in use" . 286Only one usage of each address is normally permitted. 287.It Er 49 EADDRNOTAVAIL Em "Can't assign requested address" . 288Normally results from an attempt to create a socket with an 289address not on this machine. 290.It Er 50 ENETDOWN Em "Network is down" . 291A socket operation encountered a dead network. 292.It Er 51 ENETUNREACH Em "Network is unreachable" . 293A socket operation was attempted to an unreachable network. 294.It Er 52 ENETRESET Em "Network dropped connection on reset" . 295The host you were connected to crashed and rebooted. 296.It Er 53 ECONNABORTED Em "Software caused connection abort" . 297A connection abort was caused internal to your host machine. 298.It Er 54 ECONNRESET Em "Connection reset by peer" . 299A connection was forcibly closed by a peer. 300This normally results from a loss of the connection on the remote socket 301due to a timeout or a reboot. 302.It Er 55 ENOBUFS Em "\&No buffer space available" . 303An operation on a socket or pipe was not performed because 304the system lacked sufficient buffer space or because a queue was full. 305.It Er 56 EISCONN Em "Socket is already connected" . 306A 307.Xr connect 2 308request was made on an already connected socket; or, a 309.Xr sendto 2 310or 311.Xr sendmsg 2 312request on a connected socket specified a destination 313when already connected. 314.It Er 57 ENOTCONN Em "Socket is not connected" . 315A request to send or receive data was disallowed because 316the socket was not connected and (when sending on a datagram socket) 317no address was supplied. 318.It Er 58 ESHUTDOWN Em "Can't send after socket shutdown" . 319A request to send data was disallowed because the socket 320had already been shut down with a previous 321.Xr shutdown 2 322call. 323.It Er 59 ETOOMANYREFS Em "Too many references: can't splice" . 324Not used in 325.Ox . 326.It Er 60 ETIMEDOUT Em "Operation timed out" . 327A 328.Xr connect 2 329or 330.Xr send 2 331request failed because the connected party did not 332properly respond after a period of time. 333(The timeout period is dependent on the communication protocol.) 334.It Er 61 ECONNREFUSED Em "Connection refused" . 335No connection could be made because the target machine actively 336refused it. 337This usually results from trying to connect to a service that is 338inactive on the foreign host. 339.It Er 62 ELOOP Em "Too many levels of symbolic links" . 340A path name lookup involved more than 32 341.Pq Dv SYMLOOP_MAX 342symbolic links. 343.It Er 63 ENAMETOOLONG Em "File name too long" . 344A component of a path name exceeded 255 345.Pq Dv MAXNAMLEN 346characters, or an entire path name exceeded 1023 347.Pq Dv MAXPATHLEN Ns -1 348characters. 349.It Er 64 EHOSTDOWN Em "Host is down" . 350A socket operation failed because the destination host was down. 351.It Er 65 EHOSTUNREACH Em "\&No route to host" . 352A socket operation was attempted to an unreachable host. 353.It Er 66 ENOTEMPTY Em "Directory not empty" . 354A directory with entries other than 355.Ql \&. 356and 357.Ql \&.. 358was supplied to a remove directory or rename call. 359.It Er 67 EPROCLIM Em "Too many processes" . 360.It Er 68 EUSERS Em "Too many users" . 361The quota system ran out of table entries. 362.It Er 69 EDQUOT Em "Disc quota exceeded" . 363A 364.Xr write 2 365to an ordinary file, the creation of a directory or symbolic link, 366or the creation of a directory entry failed because the user's quota 367of disk blocks was exhausted, or the allocation of an inode for a newly 368created file failed because the user's quota of inodes was exhausted. 369.It Er 70 ESTALE Em "Stale NFS file handle" . 370An attempt was made to access an open file (on an 371.Tn NFS 372filesystem) which is now unavailable as referenced by the file descriptor. 373This may indicate the file was deleted on the 374.Tn NFS 375server or some 376other catastrophic event occurred. 377.It Er 72 EBADRPC Em "RPC struct is bad" . 378Exchange of 379.Tn RPC 380information was unsuccessful. 381.It Er 73 ERPCMISMATCH Em "RPC version wrong" . 382The version of 383.Tn RPC 384on the remote peer is not compatible with the local version. 385.It Er 74 EPROGUNAVAIL Em "RPC prog. not avail" . 386The requested program is not registered on the remote host. 387.It Er 75 EPROGMISMATCH Em "Program version wrong" . 388The requested version of the program is not available on the remote host 389.Pq Tn RPC . 390.It Er 76 EPROCUNAVAIL Em "Bad procedure for program" . 391An 392.Tn RPC 393call was attempted for a procedure which doesn't exist 394in the remote program. 395.It Er 77 ENOLCK Em "\&No locks available" . 396A system-imposed limit on the number of simultaneous file 397locks was reached. 398.It Er 78 ENOSYS Em "Function not implemented" . 399Attempted a system call that is not available on this 400system. 401.It Er 79 EFTYPE Em "Inappropriate file type or format" . 402The file contains invalid data or set to invalid modes. 403.It Er 80 EAUTH Em "Authentication error" . 404Attempted to use an invalid authentication ticket to mount a 405.Tn NFS 406filesystem. 407.It Er 81 ENEEDAUTH Em "Need authenticator" . 408An authentication ticket must be obtained before the given 409.Tn NFS 410filesystem may be mounted. 411.It Er 82 EIPSEC Em "IPsec processing failure" . 412IPsec subsystem error. 413Not used in 414.Ox . 415.It Er 83 ENOATTR Em "Attribute not found" . 416A UFS Extended Attribute is not found for the specified pathname. 417.It Er 84 EILSEQ Em "Illegal byte sequence" . 418An illegal sequence of bytes was used when using wide characters. 419.It Er 85 ENOMEDIUM Em "\&No medium found" . 420Attempted to use a removable media device with no medium present. 421.It Er 86 EMEDIUMTYPE Em "Wrong medium type" . 422Attempted to use a removable media device with incorrect or incompatible 423medium. 424.It Er 87 EOVERFLOW Em "Value too large to be stored in data type" . 425A numerical result of the function was too large to be stored in the 426caller provided space. 427.It Er 88 ECANCELED Em "Operation canceled" . 428The requested operation was canceled. 429.It Er 89 EIDRM Em "Identifier removed" . 430An IPC identifier was removed while the current process was waiting on it. 431.It Er 90 ENOMSG Em "\&No message of desired type". 432An IPC message queue does not contain a message of the desired type, 433or a message catalog does not contain the requested message. 434.It Er 91 ENOTSUP Em "Not supported" . 435The operation has requested an unsupported value. 436.El 437.Sh DEFINITIONS 438.Bl -tag -width Ds 439.It Process ID 440Each active process in the system is uniquely identified by a non-negative 441integer called a process ID. 442The range of this ID is from 1 to 32766. 443.It Parent Process ID 444A new process is created by a currently active process; (see 445.Xr fork 2 ) . 446The parent process ID of a process is initially the process ID of its creator. 447If the creating process exits, 448the parent process ID of each child is set to the ID of a system process, 449.Xr init 8 . 450.It Process Group 451Each active process is a member of a process group that is identified by 452a non-negative integer called the process group ID. 453This is the process ID of the group leader. 454This grouping permits the signaling of related processes (see 455.Xr termios 4 ) 456and the job control mechanisms of 457.Xr csh 1 . 458.It Session 459A session is a set of one or more process groups. 460A session is created by a successful call to 461.Xr setsid 2 , 462which causes the caller to become the only member of the only process 463group in the new session. 464.It Session Leader 465A process that has created a new session by a successful call to 466.Xr setsid 2 , 467is known as a session leader. 468Only a session leader may acquire a terminal as its controlling terminal (see 469.Xr termios 4 ) . 470.It Controlling Process 471A session leader with a controlling terminal is a controlling process. 472.It Controlling Terminal 473A terminal that is associated with a session is known as the controlling 474terminal for that session and its members. 475.It Terminal Process Group ID 476A terminal may be acquired by a session leader as its controlling terminal. 477Once a terminal is associated with a session, any of the process groups 478within the session may be placed into the foreground by setting 479the terminal process group ID to the ID of the process group. 480This facility is used 481to arbitrate between multiple jobs contending for the same terminal; 482(see 483.Xr csh 1 484and 485.Xr tty 4 ) . 486.It Orphaned Process Group 487A process group is considered to be 488.Em orphaned 489if it is not under the control of a job control shell. 490More precisely, a process group is orphaned 491when none of its members has a parent process that is in the same session 492as the group, 493but is in a different process group. 494Note that when a process exits, the parent process for its children 495is changed to be 496.Xr init 8 , 497which is in a separate session. 498Not all members of an orphaned process group are necessarily orphaned 499processes (those whose creating process has exited). 500The process group of a session leader is orphaned by definition. 501.It Real User ID and Real Group ID 502Each user on the system is identified by a positive integer 503termed the real user ID. 504.Pp 505Each user is also a member of one or more groups. 506One of these groups is distinguished from others and 507used in implementing accounting facilities. 508The positive integer corresponding to this distinguished group is termed 509the real group ID. 510.Pp 511All processes have a real user ID and real group ID. 512These are initialized from the equivalent attributes 513of the process that created it. 514.It "Effective User ID, Effective Group ID, and Group Access List" 515Access to system resources is governed by two values: 516the effective user ID, and the group access list. 517The first member of the group access list is also known as the 518effective group ID. 519(In POSIX.1, the group access list is known as the set of supplementary 520group IDs, and it is unspecified whether the effective group ID is 521a member of the list.) 522.Pp 523The effective user ID and effective group ID are initially the 524process's real user ID and real group ID respectively. 525Either may be modified through execution of a set-user-ID or set-group-ID 526file (possibly by one of its ancestors) (see 527.Xr execve 2 ) . 528By convention, the effective group ID (the first member of the group access 529list) is duplicated, so that the execution of a set-group-ID program 530does not result in the loss of the original (real) group ID. 531.Pp 532The group access list is a set of group IDs 533used only in determining resource accessibility. 534Access checks are performed as described below in ``File Access Permissions''. 535.It Saved Set User ID and Saved Set Group ID 536When a process executes a new file, the effective user ID is set 537to the owner of the file if the file is set-user-ID, and the effective 538group ID (first element of the group access list) is set to the group 539of the file if the file is set-group-ID. 540The effective user ID of the process is then recorded as the saved set-user-ID, 541and the effective group ID of the process is recorded as the saved set-group-ID. 542These values may be used to regain those values as the effective user 543or group ID after reverting to the real ID (see 544.Xr setuid 2 ) . 545(In POSIX.1, the saved set-user-ID and saved set-group-ID are optional, 546and are used in setuid and setgid, but this does not work as desired 547for the superuser.) 548.It Superuser 549A process is recognized as a 550.Em superuser 551process and is granted special privileges if its effective user ID is 0. 552.It Special Processes 553The processes with process IDs of 0, 1, and 2 are special. 554Process 0 is the scheduler. 555Process 1 is the initialization process 556.Xr init 8 , 557and is the ancestor of every other process in the system. 558It is used to control the process structure. 559Process 2 is the paging daemon. 560.It Descriptor 561An integer assigned by the system when a file is referenced 562by 563.Xr open 2 564or 565.Xr dup 2 , 566or when a socket is created by 567.Xr pipe 2 , 568.Xr socket 2 569or 570.Xr socketpair 2 , 571which uniquely identifies an access path to that file or socket from 572a given process or any of its children. 573.It File Name 574Names consisting of up to 255 575.Pq Dv MAXNAMLEN 576characters may be used to name 577an ordinary file, special file, or directory. 578.Pp 579These characters may be selected from the set of all 580.Tn ASCII 581character 582excluding 0 (NUL) and the 583.Tn ASCII 584code for 585.Ql \&/ 586(slash). 587.Pp 588Note that it is generally unwise to use 589.Ql \&* , 590.Ql \&? , 591.Ql \&[ 592or 593.Ql \&] 594as part of 595file names because of the special meaning attached to these characters 596by the shell. 597.Pp 598Note also that 599.Pq Dv MAXNAMLEN 600is an upper limit fixed by the kernel, meant to be used for sizing buffers. 601Some filesystems may have additional restrictions. 602These can be queried using 603.Xr pathconf 2 604and 605.Xr fpathconf 2 . 606.It Path Name 607A path name is a 608.Tn NUL Ns -terminated 609character string starting with an 610optional slash 611.Ql \&/ , 612followed by zero or more directory names separated 613by slashes, optionally followed by a file name. 614The total length of a path name must be less than 1024 615.Pq Dv MAXPATHLEN 616characters. 617Additional restrictions may apply, depending upon the filesystem, to be 618queried with 619.Xr pathconf 2 620or 621.Xr fpathconf 2 622if needed. 623.Pp 624If a path name begins with a slash, the path search begins at the 625.Em root 626directory. 627Otherwise, the search begins from the current working directory. 628A slash by itself names the root directory. 629An empty pathname is invalid. 630.It Directory 631A directory is a special type of file that contains entries 632that are references to other files. 633Directory entries are called links. 634By convention, a directory contains at least two links, 635.Ql \&. 636and 637.Ql \&.. , 638referred to as 639.Em dot 640and 641.Em dot-dot 642respectively. 643Dot refers to the directory itself and dot-dot refers to its 644parent directory. 645.It "Root Directory and Current Working Directory" 646Each process has associated with it a concept of a root directory 647and a current working directory for the purpose of resolving path 648name searches. 649A process's root directory need not be the root directory of 650the root file system. 651.It File Access Permissions 652Every file in the file system has a set of access permissions. 653These permissions are used in determining whether a process 654may perform a requested operation on the file (such as opening 655a file for writing). 656Access permissions are established at the time a file is created. 657They may be changed at some later time through the 658.Xr chmod 2 659call. 660.Pp 661File access is broken down according to whether a file may be: read, 662written, or executed. 663Directory files use the execute permission to control if the directory 664may be searched. 665.Pp 666File access permissions are interpreted by the system as 667they apply to three different classes of users: the owner 668of the file, those users in the file's group, anyone else. 669Every file has an independent set of access permissions for 670each of these classes. 671When an access check is made, the system decides if permission should be 672granted by checking the access information applicable to the caller. 673.Pp 674Read, write, and execute/search permissions on 675a file are granted to a process if: 676.Pp 677The process's effective user ID is that of the superuser. 678(Note: even the superuser cannot execute a non-executable file.) 679.Pp 680The process's effective user ID matches the user ID of the owner 681of the file and the owner permissions allow the access. 682.Pp 683The process's effective user ID does not match the user ID of the 684owner of the file, and either the process's effective 685group ID matches the group ID 686of the file, or the group ID of the file is in 687the process's group access list, 688and the group permissions allow the access. 689.Pp 690Neither the effective user ID nor effective group ID 691and group access list of the process 692match the corresponding user ID and group ID of the file, 693but the permissions for ``other users'' allow access. 694.Pp 695Otherwise, permission is denied. 696.It Sockets and Address Families 697A socket is an endpoint for communication between processes. 698Each socket has queues for sending and receiving data. 699.Pp 700Sockets are typed according to their communications properties. 701These properties include whether messages sent and received 702at a socket require the name of the partner, whether communication 703is reliable, the format used in naming message recipients, etc. 704.Pp 705Each instance of the system supports some 706collection of socket types; consult 707.Xr socket 2 708for more information about the types available and 709their properties. 710.Pp 711Each instance of the system supports some number of sets of 712communications protocols. 713Each protocol set supports addresses of a certain format. 714An Address Family is the set of addresses for a specific group of protocols. 715Each socket has an address chosen from the address family in which the 716socket was created. 717.El 718.Sh SEE ALSO 719.Xr intro 3 , 720.Xr perror 3 721.Sh HISTORY 722An 723.Nm 724manual page appeared in 725.At v6 . 726