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