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