BSD 3 development
[unix-history] / usr / man / man2 / intro.2
CommitLineData
e6817382
BJ
1.TH INTRO 2
2.de en
3.HP
4\\$1 \\$2 \\$3
5.br
6..
7.SH NAME
8intro, errno \- introduction to system calls and error numbers
9.SH SYNOPSIS
10.B #include <errno.h>
11.SH DESCRIPTION
12Section 2 of this manual
13lists all the entries into the system.
14Most of these calls have an error return.
15.pg
16An error condition is indicated by an otherwise
17impossible returned value.
18Almost always this is \(mi1;
19the individual sections specify the details.
20An error number is also made available
21in the external variable
22.IR errno .
23.I Errno
24is not cleared on successful calls, so it should be tested only
25after an error has occurred.
26.PP
27There is a table of messages
28associated with each error, and a routine for printing the
29message;
30See
31.IR perror (3).
32The possible error numbers
33are not recited with each writeup in section 2, since many
34errors are possible for most of the calls.
35Here is a list of the error numbers,
36their names as defined in <errno.h>,
37and the messages available using
38.IR perror .
39.en 0 \h'\w'EIO'u' "Error 0
40Unused.
41.en 1 EPERM "Not owner
42Typically this error indicates
43an attempt to modify a file in some way forbidden
44except to its owner or super-user.
45It is also returned for attempts
46by ordinary users to do things
47allowed only to the super-user.
48.en 2 ENOENT "No such file or directory
49This error occurs when a file name is specified
50and the file should exist but doesn't, or when one
51of the directories in a path name does not exist.
52.en 3 ESRCH "No such process
53The process whose number was given to
54.I signal
55and
56.I ptrace
57does not exist, or is already dead.
58.en 4 EINTR "Interrupted system call
59An asynchronous signal (such as interrupt or quit),
60which the user has elected to catch,
61occurred during a system call.
62If execution is resumed
63after processing the signal,
64it will appear as if the interrupted system call
65returned this error condition.
66.en 5 EIO "I/O error
67Some physical I/O error occurred during a
68.I read
69or
70.IR write .
71This error may in some cases occur
72on a call following the one to which it actually applies.
73.en 6 ENXIO "No such device or address
74I/O on a special file refers to a subdevice which does not
75exist,
76or beyond the limits of the device.
77It may also occur when, for example, a tape drive
78is not dialled in or no disk pack is loaded on a drive.
79.en 7 E2BIG "Arg list too long
80An argument list longer than 5120 bytes
81is presented to
82.IR exec .
83.en 8 ENOEXEC "Exec format error
84A request is made to execute a file
85which, although it has the appropriate permissions,
86does not start with a valid magic number, see
87.IR a.out (5).
88.en 9 EBADF "Bad file number
89Either a file descriptor refers to no
90open file,
91or a read (resp. write) request is made to
92a file which is open only for writing (resp. reading).
93.en 10 ECHILD "No children
94.I Wait
95and the process has no
96living or unwaited-for children.
97.en 11 EAGAIN "No more processes
98In a
99.I fork,
100the system's process table is full
101or the user is not allowed to create any more
102processes.
103.en 12 ENOMEM "Not enough core
104During an
105.I exec
106or
107.I break,
108a program asks for more core than the system is able to supply.
109This is not a temporary condition; the maximum core size
110is a system parameter.
111The error may also occur if the arrangement
112of text, data, and stack segments
113requires too many segmentation registers.
114.en 13 EACCES "Permission denied
115An attempt was made to access a file in a way forbidden
116by the protection system.
117.en 14 EFAULT "Bad address
118The system encountered a hardware fault in attempting to
119access the arguments of a system call.
120.en 15 ENOTBLK "Block device required
121A plain file was mentioned where a block device was required,
122e.g. in
123.IR mount .
124.en 16 EBUSY "Mount device busy
125An attempt to mount a device that was already mounted or
126an attempt was made to dismount a device
127on which there is an active file
128directory.
129(open file, current directory, mounted-on file, active text segment).
130.en 17 EEXIST "File exists
131An existing file was mentioned in an inappropriate context,
132e.g.
133.IR link .
134.en 18 EXDEV "Cross-device link
135A link to a file on another device
136was attempted.
137.en 19 ENODEV "No such device
138An attempt was made to apply an inappropriate
139system call to a device;
140e.g. read a write-only device.
141.en 20 ENOTDIR "Not a directory
142A non-directory was specified where a directory
143is required,
144for example in a path name or
145as an argument to
146.IR chdir .
147.en 21 EISDIR "Is a directory
148An attempt to write on a directory.
149.en 22 EINVAL "Invalid argument
150Some invalid argument:
151dismounting a non-mounted
152device,
153mentioning an unknown signal in
154.I signal,
155reading or writing a file for which
156.I seek
157has generated a negative pointer.
158Also set by math functions, see
159.IR intro (3).
160.en 23 ENFILE "File table overflow
161The system's table of open files is full,
162and temporarily no more
163.I opens
164can be accepted.
165.en 24 EMFILE "Too many open files
166Customary configuration limit is 20 per process.
167.en 25 ENOTTY "Not a typewriter
168The file mentioned in
169.I stty
170or
171.I gtty
172is not a terminal or one of the other
173devices to which these calls apply.
174.en 26 ETXTBSY "Text file busy
175An attempt to execute a pure-procedure
176program which is currently open for writing
177(or reading!).
178Also an attempt to open for writing a pure-procedure
179program that is being executed.
180.en 27 EFBIG "File too large
181The size of a file exceeded the maximum (about
182.if t 10\u\s-29\s+2\d
183.if n 1.0E9
184bytes).
185.en 28 ENOSPC "No space left on device
186During a
187.I write
188to an ordinary file,
189there is no free space left on the device.
190.en 29 ESPIPE "Illegal seek
191An
192.I lseek
193was issued to a pipe.
194This error should also be issued for
195other non-seekable devices.
196.en 30 EROFS "Read-only file system
197An attempt to modify a file or directory
198was made
199on a device mounted read-only.
200.en 31 EMLINK "Too many links
201An attempt to make more than 32767 links to a file.
202.en 32 EPIPE "Broken pipe
203A write on a pipe for which there is no process
204to read the data.
205This condition normally generates a signal;
206the error is returned if the signal is ignored.
207.en 33 EDOM "Math argument
208The argument of a function in the math package (3M)
209is out of the domain of the function.
210.en 34 ERANGE "Result too large
211The value of a function in the math package (3M)
212is unrepresentable within machine precision.
213.SH SEE ALSO
214intro(3)
215.SH "ASSEMBLER (PDP-11)"
216.B as /usr/include/sys.s file ...
217.PP
218The PDP11 assembly language interface is given for each
219system call.
220The assembler symbols are defined in `/usr/include/sys.s'.
221.PP
222Return values appear in registers r0 and r1;
223it is unwise to count on these registers being preserved
224when no value is expected.
225An erroneous call is always
226indicated by turning on the c-bit of the condition codes.
227The error number is returned in r0.
228The presence of an error is most easily tested
229by the instructions
230.I bes
231and
232.I bec
233(`branch on error set (or clear)').
234These are synonyms for
235the
236.I bcs
237and
238.I bcc
239instructions.
240.PP
241On the Interdata 8/32, the system call arguments
242correspond well to the arguments of the C routines.
243The sequence is:
244.IP
245.nf
246la %2,errno
247l %0,&callno
248svc 0,args
249.fi
250.PP
251Thus register 2 points to a word into which the error number will be
252stored as needed; it is cleared if no error occurs.
253Register 0 contains the system call number; the nomenclature
254is identical to that on the PDP11.
255The argument of the
256.I svc
257is the address of the arguments, laid out in storage
258as in the C calling sequence.
259The return value is in register 2 (possibly 3 also, as in
260.IR pipe )
261and is \-1 in case of error.
262The overflow bit in the program status word is also
263set when errors occur.
264.PP
265On the VAX-11 a system call follows exactly the same conventions as a
266C procedure. Namely, register
267.B ap
268points to a long word containing the number of arguments, and the
269arguments follow in successive long words. Values are returned in registers
270.B r0
271and
272.BR r1 .
273An error is indicated by setting the C (carry) bit in the processor status
274word; the error number is placed in
275.BR r0 .