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