1SYSCALLS(2) Linux Programmer's Manual SYSCALLS(2)
2
3
4
6 syscalls - Linux system calls
7
9 Linux system calls.
10
12 The system call is the fundamental interface between an application and
13 the Linux kernel.
14
15 System calls and library wrapper functions
16 System calls are generally not invoked directly, but rather via wrapper
17 functions in glibc (or perhaps some other library). For details of
18 direct invocation of a system call, see intro(2). Often, but not
19 always, the name of the wrapper function is the same as the name of the
20 system call that it invokes. For example, glibc contains a function
21 truncate() which invokes the underlying "truncate" system call.
22
23 Often the glibc wrapper function is quite thin, doing little work other
24 than copying arguments to the right registers before invoking the sys‐
25 tem call, and then setting errno appropriately after the system call
26 has returned. (These are the same steps that are performed by
27 syscall(2), which can be used to invoke system calls for which no wrap‐
28 per function is provided.) Note: system calls indicate a failure by
29 returning a negative error number to the caller; when this happens, the
30 wrapper function negates the returned error number (to make it posi‐
31 tive), copies it to errno, and returns -1 to the caller of the wrapper.
32
33 Sometimes, however, the wrapper function does some extra work before
34 invoking the system call. For example, nowadays there are (for reasons
35 described below) two related system calls, truncate(2) and trun‐
36 cate64(2), and the glibc truncate() wrapper function checks which of
37 those system calls are provided by the kernel and determines which
38 should be employed.
39
40 System call list
41 Below is a list of those system calls that are common to most plat‐
42 forms. In the list, the Kernel column indicates the kernel version for
43 those system calls that were new in Linux 2.2, or have appeared since
44 that kernel version. Note the following points:
45
46 * Where no kernel version is indicated, the system call appeared in
47 kernel 1.0 or earlier.
48
49 * Where a system call is marked "1.2" this means the system call prob‐
50 ably appeared in a 1.1.x kernel version, and first appeared in a
51 stable kernel with 1.2. (Development of the 1.2 kernel was initi‐
52 ated from a branch of kernel 1.0.6 via the 1.1.x unstable kernel
53 series.)
54
55 * Where a system call is marked "2.0" this means the system call prob‐
56 ably appeared in a 1.3.x kernel version, and first appeared in a
57 stable kernel with 2.0. (Development of the 2.0 kernel was initi‐
58 ated from a branch of kernel 1.2.x, somewhere around 1.2.10, via the
59 1.3.x unstable kernel series.)
60
61 * Where a system call is marked "2.2" this means the system call prob‐
62 ably appeared in a 2.1.x kernel version, and first appeared in a
63 stable kernel with 2.2.0. (Development of the 2.2 kernel was initi‐
64 ated from a branch of kernel 2.0.21 via the 2.1.x unstable kernel
65 series.)
66
67 * Where a system call is marked "2.4" this means the system call prob‐
68 ably appeared in a 2.3.x kernel version, and first appeared in a
69 stable kernel with 2.4.0. (Development of the 2.4 kernel was initi‐
70 ated from a branch of kernel 2.2.8 via the 2.3.x unstable kernel
71 series.)
72
73 * Where a system call is marked "2.6" this means the system call prob‐
74 ably appeared in a 2.5.x kernel version, and first appeared in a
75 stable kernel with 2.6.0. (Development of kernel 2.6 was initiated
76 from a branch of kernel 2.4.15 via the 2.5.x unstable kernel
77 series.)
78
79 * Starting with kernel 2.6.0, the development model changed, and new
80 system calls may appear in each 2.6.x release. In this case, the
81 exact version number where the system call appeared is shown.
82
83 * In some cases, a system call was added to a stable kernel series
84 after it branched from the previous stable kernel series, and then
85 backported into the earlier stable kernel series. For example some
86 system calls that appeared in 2.6.x were also backported into a
87 2.4.x release after 2.4.15. When this is so, the version where the
88 system call appeared in both of the major kernel series is listed.
89
90 The list of system calls that are available as at kernel 2.6.28 (or in
91 a few cases only on older kernels) is as follows:
92
93 System call Kernel Notes
94 ───────────────────────────────────────────────────────────────────────
95
96 _llseek(2) 1.2
97 _newselect(2)
98 _sysctl(2)
99 accept(2)
100 accept4(2) 2.6.28
101 access(2)
102 acct(2)
103 add_key(2) 2.6.11
104 adjtimex(2)
105 afs_syscall(2) Not implemented
106 alarm(2)
107 alloc_hugepages(2) 2.5.36 Removed in 2.5.44
108 bdflush(2) Deprecated (does nothing)
109 since 2.6
110 bind(2)
111 break(2) Not implemented
112 brk(2)
113 cacheflush(2) 1.2 Not on i386
114 capget(2) 2.2
115 capset(2) 2.2
116 chdir(2)
117 chmod(2)
118 chown(2)
119 chown32(2) 2.4
120 chroot(2)
121 clock_getres(2) 2.6
122 clock_gettime(2) 2.6
123 clock_nanosleep(2) 2.6
124 clock_settime(2) 2.6
125 clone(2)
126 close(2)
127 connect(2)
128 creat(2)
129 create_module(2)
130 delete_module(2)
131 dup(2)
132
133 dup2(2)
134 dup3(2) 2.6.27
135 epoll_create(2) 2.6
136 epoll_create1(2) 2.6.27
137 epoll_ctl(2) 2.6
138 epoll_pwait(2) 2.6.19
139 epoll_wait(2) 2.6
140 eventfd(2) 2.6.22
141 eventfd2(2) 2.6.27
142 execve(2)
143 exit(2)
144 exit_group(2) 2.6
145 faccessat(2) 2.6.16
146 fadvise64(2) 2.6
147 fadvise64_64(2) 2.6
148 fallocate(2) 2.6.23
149 fchdir(2)
150 fchmod(2)
151 fchmodat(2) 2.6.16
152 fchown(2)
153 fchown32(2) 2.4
154 fchownat(2) 2.6.16
155 fcntl(2)
156 fcntl64(2) 2.4
157 fdatasync(2)
158 fgetxattr(2) 2.6; 2.4.18
159 flistxattr(2) 2.6; 2.4.18
160 flock(2) 2.0
161 fork(2)
162 free_hugepages(2) 2.5.36 Removed in 2.5.44
163 fremovexattr(2) 2.6; 2.4.18
164 fsetxattr(2) 2.6; 2.4.18
165 fstat(2)
166 fstat64(2) 2.4
167 fstatat64(2) 2.6.16
168 fstatfs(2)
169 fstatfs64(2) 2.6
170 fsync(2)
171 ftime(2) Not implemented
172 ftruncate(2)
173 ftruncate64(2) 2.4
174 futex(2) 2.6
175 futimesat(2) 2.6.16
176 get_kernel_syms(2)
177 get_mempolicy(2) 2.6.6
178 get_robust_list(2) 2.6.17
179 get_thread_area(2) 2.6
180 getcpu(2) 2.6.19
181 getcwd(2) 2.2
182 getdents(2) 2.0
183 getdents64(2) 2.4
184 getegid(2)
185 getegid32(2) 2.4
186 geteuid(2)
187 geteuid32(2) 2.4
188 getgid(2)
189 getgid32(2) 2.4
190 getgroups(2)
191 getgroups32(2) 2.4
192 getitimer(2)
193 getpeername(2)
194 getpagesize(2) 2.0 Not on i386
195 getpgid(2)
196 getpgrp(2)
197 getpid(2)
198
199 getpmsg(2) Not implemented
200 getppid(2)
201 getpriority(2)
202 getresgid(2) 2.2
203 getresgid32(2) 2.4
204 getresuid(2) 2.2
205 getresuid32(2) 2.4
206 getrlimit(2)
207 getrusage(2)
208 getsid(2) 2.0
209 getsockname(2)
210 getsockopt(2)
211 gettid(2) 2.4.11
212 gettimeofday(2)
213 getuid(2)
214 getuid32(2) 2.4
215 getxattr(2) 2.6; 2.4.18
216 gtty(2) Not implemented
217 idle(2) Not implemented
218 init_module(2)
219 inotify_add_watch(2) 2.6.13
220 inotify_init(2) 2.6.13
221 inotify_init1(2) 2.6.27
222 inotify_rm_watch(2) 2.6.13
223 io_cancel(2) 2.6
224 io_destroy(2) 2.6
225 io_getevents(2) 2.6
226 io_setup(2) 2.6
227 io_submit(2) 2.6
228 ioctl(2)
229 ioperm(2)
230 iopl(2)
231 ioprio_get(2) 2.6.13
232 ioprio_set(2) 2.6.13
233 ipc(2)
234 kexec_load(2) 2.6.7
235 keyctl(2) 2.6.11
236 kill(2)
237 lchown(2) 2.2
238 lchown32(2) 2.4
239 lgetxattr(2) 2.6; 2.4.18
240 link(2)
241 linkat(2) 2.6.16
242 listen(2)
243 listxattr(2) 2.6; 2.4.18
244 llistxattr(2) 2.6; 2.4.18
245 lock(2) Not implemented
246 lookup_dcookie(2) 2.6
247 lremovexattr(2) 2.6; 2.4.18
248 lseek(2)
249 lsetxattr(2) 2.6; 2.4.18
250 lstat(2)
251 lstat64(2) 2.4
252 madvise(2) 2.4
253 madvise1(2) 2.4
254 mbind(2) 2.6.6
255 migrate_pages(2) 2.6.16
256 mincore(2) 2.4
257 mkdir(2)
258 mkdirat(2) 2.6.16
259 mknod(2)
260 mknodat(2) 2.6.16
261 mlock(2)
262 mlockall(2)
263 mmap(2)
264
265 mmap2(2) 2.4
266 modify_ldt(2)
267 mount(2)
268 move_pages(2) 2.6.18
269 mprotect(2)
270 mpx(2) Not implemented
271 mq_getsetattr(2) 2.6.6
272 mq_notify(2) 2.6.6
273 mq_open(2) 2.6.6
274 mq_timedreceive(2) 2.6.6
275 mq_timedsend(2) 2.6.6
276 mq_unlink(2)
277 mremap(2) 2.0
278 msgctl(2)
279 msgget(2)
280 msgrcv(2)
281 msgsnd(2)
282 msync(2) 2.0
283 munlock(2)
284 munlockall(2)
285 munmap(2)
286 nanosleep(2) 2.0
287 nfsservctl(2) 2.2
288 nice(2)
289 oldfstat(2)
290 oldlstat(2)
291 oldolduname(2)
292 oldstat(2)
293 olduname(2)
294 open(2)
295 openat(2) 2.6.16
296 pause(2)
297 pciconfig_iobase(2) 2.2.15; 2.4 Not on i386
298 pciconfig_read(2) 2.0.26; 2.2 Not on i386
299 pciconfig_write(2) 2.0.26; 2.2 Not on i386
300 personality(2) 1.2
301 phys(2) Not implemented
302 pipe(2)
303 pipe2(2) 2.6.27
304 pivot_root(2) 2.4
305 poll(2) 2.2
306 ppoll(2) 2.6.16
307 prctl(2) 2.2
308 pread64(2) Added as "pread" in 2.2;
309 renamed "pread64" in 2.6
310 preadv(2) 2.6.30
311 prof(2) Not implemented
312 profil(2) Not implemented
313 pselect6(2) 2.6.16
314 ptrace(2)
315 putpmsg(2) Not implemented
316 pwrite64(2) Added as "pwrite" in 2.2;
317 renamed "pwrite64" in 2.6
318 pwritev(2) 2.6.30
319 query_module(2) 2.2
320 quotactl(2)
321 read(2)
322 readahead(2) 2.4.13
323 readdir(2)
324 readlink(2)
325 readlinkat(2) 2.6.16
326 readv(2) 2.0
327 reboot(2)
328 recv(2)
329 recvfrom(2)
330
331 recvmsg(2)
332 remap_file_pages(2) 2.6
333 removexattr(2) 2.6; 2.4.18
334 rename(2)
335 renameat(2) 2.6.16
336 request_key(2) 2.6.11
337 restart_syscall(2) 2.6
338 rmdir(2)
339 rt_sigaction(2) 2.2
340 rt_sigpending(2) 2.2
341 rt_sigprocmask(2) 2.2
342 rt_sigqueueinfo(2) 2.2
343 rt_sigreturn(2) 2.2
344 rt_sigsuspend(2) 2.2
345 rt_sigtimedwait(2) 2.2
346 sched_get_priority_max(2) 2.0
347 sched_get_priority_min(2) 2.0
348 sched_getaffinity(2) 2.6
349 sched_getparam(2) 2.0
350 sched_getscheduler(2) 2.0
351 sched_rr_get_interval(2) 2.0
352 sched_setaffinity(2) 2.6
353 sched_setparam(2) 2.0
354 sched_setscheduler(2) 2.0
355 sched_yield(2) 2.0
356 security(2) Not implemented
357 select(2)
358 semctl(2)
359 semget(2)
360 semop(2)
361 semtimedop(2) 2.6; 2.4.22
362 send(2)
363 sendfile(2) 2.2
364 sendfile64(2) 2.6; 2.4.19
365 sendmsg(2)
366 sendto(2)
367 set_mempolicy(2) 2.6.6
368 set_robust_list(2) 2.6.17
369 set_thread_area(2) 2.6
370 set_tid_address(2) 2.6
371 set_zone_reclaim(2) 2.6.13 Removed in 2.6.16 (was never
372 available to userspace)
373 setdomainname(2)
374 setfsgid(2) 1.2
375 setfsgid32(2) 2.4
376 setfsuid(2) 1.2
377 setfsuid32(2) 2.4
378 setgid(2)
379 setgid32(2) 2.4
380 setgroups(2)
381 setgroups32(2) 2.4
382 sethostname(2)
383 setitimer(2)
384 setpgid(2)
385 setpriority(2)
386 setregid(2)
387 setregid32(2) 2.4
388 setresgid(2) 2.2
389 setresgid32(2) 2.4
390 setresuid(2) 2.2
391 setresuid32(2) 2.4
392 setreuid(2)
393 setreuid32(2) 2.4
394 setrlimit(2)
395 setsid(2)
396
397 setsockopt(2)
398 settimeofday(2)
399 setuid(2)
400 setuid32(2) 2.4
401 setup(2) Removed in 2.2
402 setxattr(2) 2.6; 2.4.18
403 sgetmask(2)
404 shmat(2)
405 shmctl(2)
406 shmdt(2)
407 shmget(2)
408 shutdown(2)
409 sigaction(2)
410 sigaltstack(2) 2.2
411 signal(2)
412 signalfd(2) 2.6.22
413 signalfd4(2) 2.6.27
414 sigpending(2)
415 sigprocmask(2)
416 sigreturn(2)
417 sigsuspend(2)
418 socket(2)
419 socketcall(2)
420 socketpair(2)
421 splice(2) 2.6.17
422 spu_create(2) 2.6.16 PowerPC only
423 spu_run(2) 2.6.16 PowerPC only
424 ssetmask(2)
425 stat(2)
426 stat64(2) 2.4
427 statfs(2)
428 statfs64(2) 2.6
429 stime(2)
430 stty(2) Not implemented
431 swapoff(2)
432 swapon(2)
433 symlink(2)
434 symlinkat(2) 2.6.16
435 sync(2)
436 sync_file_range(2) 2.6.17
437 sysfs(2) 1.2
438 sysinfo(2)
439 syslog(2)
440 tee(2) 2.6.17
441 tgkill(2) 2.6
442 time(2)
443 timer_create(2) 2.6
444 timer_delete(2) 2.6
445 timer_getoverrun(2) 2.6
446 timer_gettime(2) 2.6
447 timer_settime(2) 2.6
448 timerfd_create(2) 2.6.25
449 timerfd_gettime(2) 2.6.25
450 timerfd_settime(2) 2.6.25
451 times(2)
452 tkill(2) 2.6; 2.4.22
453 truncate(2)
454 truncate64(2) 2.4
455 tuxcall(2) Not implemented
456 ugetrlimit(2) 2.4
457 ulimit(2) Not implemented
458 umask(2)
459 umount(2)
460 umount2(2) 2.2
461 uname(2)
462
463 unlink(2)
464 unlinkat(2) 2.6.16
465 unshare(2) 2.6.16
466 uselib(2)
467 ustat(2)
468 utime(2)
469 utimensat(2) 2.6.22
470 utimes(2) 2.6
471 vfork(2)
472 vhangup(2)
473 vm86old(2)
474 vmsplice(2) 2.6.17
475 vserver(2) Not implemented
476 wait4(2)
477 waitid(2) 2.6.10
478 waitpid(2)
479 write(2)
480 writev(2) 2.0
481
482 On many platforms, including i386, socket calls are all multiplexed
483 (via glibc wrapper functions) through socketcall(2) and similarly Sys‐
484 tem V IPC calls are multiplexed through ipc(2).
485
487 Note the following points:
488
489 * Although slots are reserved for them in the system call table, the
490 following system calls are not implemented in the standard kernel:
491 afs_syscall(2), break(2), ftime(2), getpmsg(2), gtty(2), idle(2),
492 lock(2), madvise1(2), mpx(2), phys(2), prof(2), profil(2),
493 putpmsg(2), security(2), stty(2), tuxcall(2), ulimit(2), and
494 vserver(2) (see also unimplemented(2)). However, ftime(3), pro‐
495 fil(3) and ulimit(3) exist as library routines. The slot for
496 phys(2) is in use since kernel 2.1.116 for umount(2); phys(2) will
497 never be implemented.
498
499 * The getpmsg(2) and putpmsg(2) calls are for kernels patched to sup‐
500 port STREAMS, and may never be in the standard kernel.
501
502 Roughly speaking, the code belonging to the system call with number
503 __NR_xxx defined in /usr/include/asm/unistd.h can be found in the ker‐
504 nel source in the routine sys_xxx(). (The dispatch table for i386 can
505 be found in /usr/src/linux/arch/i386/kernel/entry.S.) There are many
506 exceptions, however, mostly because older system calls were superseded
507 by newer ones, and this has been treated somewhat unsystematically. On
508 platforms with proprietary OS emulation, such as parisc, sparc, sparc64
509 and alpha, there are many additional system calls; mips64 also contains
510 a full set of 32-bit system calls.
511
512 Over time, changes to the interfaces of some system calls have been
513 necessary. One reason for such changes was the need to increase the
514 size of structures or scalar values passed to the system call. Because
515 of these changes, there are now various groups of related system calls
516 (e.g., truncate(2) and truncate64(2)) which perform similar tasks, but
517 which vary in details such as the size of their arguments. (As noted
518 earlier, applications are generally unaware of this: the glibc wrapper
519 functions do some work to ensure that the right system call is invoked,
520 and that ABI compatibility is preserved for old binaries.) Examples of
521 systems calls that exist in multiple versions are the following:
522
523 * By now there are three different versions of stat(2): sys_stat()
524 (slot __NR_oldstat), sys_newstat() (slot __NR_stat), and
525 sys_stat64() (slot __NR_stat64), with the last being the most cur‐
526 rent. A similar story applies for lstat(2) and fstat(2).
527
528 * Similarly, the defines __NR_oldolduname, __NR_olduname, and
529 __NR_uname refer to the routines sys_olduname(), sys_uname() and
530 sys_newuname().
531
532 * In Linux 2.0, a new version of vm86(2) appeared, with the old and
533 the new kernel routines being named sys_vm86old() and sys_vm86().
534
535 * In Linux 2.4, a new version of getrlimit(2) appeared, with the old
536 and the new kernel routines being named sys_old_getrlimit() (slot
537 __NR_getrlimit) and sys_getrlimit() (slot __NR_ugetrlimit).
538
539 * Linux 2.4 increased the size of user and group IDs from 16 to 32
540 bits. To support this change, a range of system calls were added
541 (e.g., chown32(2), getuid32(2), getgroups32(2), setresuid32(2)),
542 superseding earlier calls of the same name without the "32" suffix.
543
544 * Linux 2.4 added support for applications on 32-bit architectures to
545 access large files (i.e., files for which the sizes and file offsets
546 can't be represented in 32 bits.) To support this change, replace‐
547 ments were required for system calls that deal with file offsets and
548 sizes. Thus the following system calls were added: fcntl64(2),
549 ftruncate64(2), getdents64(2), stat64(2), statfs64(2), and their
550 analogs that work with file descriptors or symbolic links. These
551 system calls supersede the older system calls which, except in the
552 case of the "stat" calls, have the same name without the "64" suf‐
553 fix.
554
555 On newer platforms that only have 64-bit file access and 32-bit uids
556 (e.g., alpha, ia64, s390x) there are no *64 or *32 calls. Where the
557 *64 and *32 calls exist, the other versions are obsolete.
558
559 * The rt_sig* calls were added in kernel 2.2 to support the addition
560 of real-time signals (see signal(7)). These system calls supersede
561 the older system calls of the same name without the "rt_" prefix.
562
563 * The select(2) and mmap(2) system calls use five or more arguments,
564 which caused problems the way argument passing on the i386 used to
565 be set up. Thus, while other architectures have sys_select() and
566 sys_mmap() corresponding to __NR_select and __NR_mmap, on i386 one
567 finds old_select() and old_mmap() (routines that use a pointer to a
568 argument block) instead. These days passing five arguments is not a
569 problem any more, and there is a __NR__newselect that corresponds
570 directly to sys_select() and similarly __NR_mmap2.
571
573 syscall(2), unimplemented(2), libc(7)
574
576 This page is part of release 3.22 of the Linux man-pages project. A
577 description of the project, and information about reporting bugs, can
578 be found at http://www.kernel.org/doc/man-pages/.
579
580
581
582Linux 2009-05-06 SYSCALLS(2)