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