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