1 .\" Copyright (C) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" with some input from Stepan Kasal <kasal@ucw.cz>
4 .\" Some content retained from an earlier version of this page:
5 .\" Copyright (C) 1998 Andries Brouwer (aeb@cwi.nl)
6 .\" Modifications for 2.2 and 2.4 Copyright (C) 2002 Ian Redfern
7 .\" <redferni@logica.com>
9 .\" Permission is granted to make and distribute verbatim copies of this
10 .\" manual provided the copyright notice and this permission notice are
11 .\" preserved on all copies.
13 .\" Permission is granted to copy and distribute modified versions of this
14 .\" manual under the conditions for verbatim copying, provided that the
15 .\" entire resulting derived work is distributed under the terms of a
16 .\" permission notice identical to this one.
18 .\" Since the Linux kernel and libraries are constantly changing, this
19 .\" manual page may be incorrect or out-of-date. The author(s) assume no
20 .\" responsibility for errors or omissions, or for damages resulting from
21 .\" the use of the information contained herein. The author(s) may not
22 .\" have taken the same level of care in the production of this manual,
23 .\" which is licensed free of charge, as they might when working
26 .\" Formatted or processed versions of this manual, if unaccompanied by
27 .\" the source, must acknowledge the copyright and authors of this work.
29 .TH SYSCALLS 2 2007-09-01 "Linux" "Linux Programmer's Manual"
31 syscalls \- Linux system calls
35 The system call is the fundamental interface between an application
37 .SS System calls and library wrapper functions
38 System calls are generally not invoked directly,
39 but rather via wrapper functions in glibc (or perhaps some other library).
40 For details of direct invocation of a system call, see
42 Often, but not always, the name of the wrapper function is the same
43 as the name of the system call that it invokes.
44 For example, glibc contains a function
46 which invokes the underlying "truncate" system call.
48 Often the glibc wrapper function is quite thin, doing little work
49 before invoking the system call.
51 Sometimes, however, the wrapper function does some extra work
52 before invoking the system call.
53 For example, nowadays there are (for reasons described below) two
60 wrapper function checks which of those system calls
61 are provided by the kernel and determines which should be employed.
63 Below is a list of those system calls that are common to most platforms.
66 column indicates the kernel version
67 for those system calls that were new in Linux 2.2,
68 or have appeared since that kernel version.
69 Note the following points:
71 Where no kernel version is indicated,
72 the system call appeared in kernel 2.0 or earlier.
73 .\" kernel 1.2 was started from a branch of 1.0.6
75 .\" Was kernel 2.0 started from a branch of 1.2.10?
76 .\" At least from the timestamps of the tarballs of
77 .\" of 1.2.10 and 1.3.0, that's how it looks, but in
78 .\" fact the diff doesn't seem very clear, the
79 .\" 1.3.0 .tar.bz is much bigger (2.0 MB) than the
80 .\" 1.2.10 .tar.bz2 (1.8 MB), and AEB points out the
81 .\" timestamps of some files in 1.3.0 seem to be older
82 .\" than those in 1.2.10. All of this suggests
83 .\" that there might not have been a clean branch point.
85 Where a system call is marked "2.2"
86 this means the system call probably appeared in a 2.1.x kernel version,
87 and first appeared in a stable kernel with 2.2.0.
88 (Development of the 2.2 kernel was initiated from a branch of kernel
89 2.0.21 via the 2.1.x unstable kernel series.)
91 Where a system call is marked "2.4"
92 this means the system call probably appeared in a 2.3.x kernel version,
93 and first appeared in a stable kernel with 2.4.0.
94 (Development of the 2.4 kernel was initiated from a branch of
95 kernel 2.2.8 via the 2.3.x unstable kernel series.)
97 Where a system call is marked "2.6"
98 this means the system call probably appeared in a 2.5.x kernel version,
99 and first appeared in a stable kernel with 2.6.0.
100 (Development of kernel 2.6 was initiated from a branch
101 of kernel 2.4.15 via the 2.5.x unstable kernel series.)
103 Starting with kernel 2.6.0, the development model changed,
104 and new system calls may appear in each 2.6.x release.
105 In this case, the exact version number where the system call appeared
108 In some cases, a system call was added to a stable kernel
109 series after it branched from the previous stable kernel
110 series, and then backported into the earlier stable kernel series.
111 For example some system calls that appeared in 2.6.x were also backported
112 into a 2.4.x release after 2.4.15.
113 When this is so, the version where the system call appeared
114 in both of the major kernel series is listed.
116 The list of system calls that are available as at kernel 2.6.22
117 (or in a few cases only on older kernels) is as follows:
119 .\" Looking at scripts/checksyscalls.sh in the kernel source is
120 .\" instructive about i386 specifics.
126 \fBSystem call\fP \fBKernel\fP \fBNotes\fP
134 \fBadd_key\fP(2) 2.6.11
138 \fBalloc_hugepages\fP(2) 2.5.36 Removed in 2.5.44
143 \fBcacheflush\fP(2) Not on i386
151 \fBclock_getres\fP(2) 2.6
152 \fBclock_gettime\fP(2) 2.6
153 \fBclock_nanosleep\fP(2) 2.6
154 \fBclock_settime\fP(2) 2.6
159 \fBcreate_module\fP(2)
160 \fBdelete_module\fP(2)
163 \fBepoll_create\fP(2) 2.6
164 \fBepoll_ctl\fP(2) 2.6
165 \fBepoll_pwait\fP(2) 2.6.19
166 \fBepoll_wait\fP(2) 2.6
167 \fBeventfd\fP(2) 2.6.22
170 \fBexit_group\fP(2) 2.6; 2.4.20
171 \fBfaccessat\fP(2) 2.6.16
172 \fBfadvise64\fP(2) 2.6
173 .\" Implements \fBposix_fadvise\fP(2)
174 \fBfadvise64_64\fP(2) 2.6
175 .\" FIXME \fBfallocate\fP(2) 2.6.23
178 \fBfchmodat\fP(2) 2.6.16
180 \fBfchown32\fP(2) 2.4
181 \fBfchownat\fP(2) 2.6.16
185 \fBfgetxattr\fP(2) 2.6; 2.4.18
186 \fBflistxattr\fP(2) 2.6; 2.4.18
189 \fBfree_hugepages\fP(2) 2.5.36 Removed in 2.5.44
190 \fBfremovexattr\fP(2) 2.6; 2.4.18
191 \fBfsetxattr\fP(2) 2.6; 2.4.18
194 \fBfstatat64\fP(2) 2.6.16
196 \fBfstatfs64\fP(2) 2.6
199 .\" Implemented in glibc; see \fBftime\fP(3)
201 \fBftruncate64\fP(2) 2.4
202 \fBfutex\fP(2) 2.6; 2.4.19
203 \fBfutimesat\fP(2) 2.6.16
204 \fBget_kernel_syms\fP(2)
205 \fBget_mempolicy\fP(2) 2.6.6
206 \fBget_robust_list\fP(2) 2.6.17
207 \fBget_thread_area\fP(2) 2.6; 2.4.20
208 \fBgetcpu\fP(2) 2.6.19
211 \fBgetdents64\fP(2) 2.4
213 \fBgetegid32\fP(2) 2.4
215 \fBgeteuid32\fP(2) 2.4
217 \fBgetgid32\fP(2) 2.4
219 \fBgetgroups32\fP(2) 2.4
222 \fBgetpagesize\fP(2) Not on i386
227 .\" Reserved for STREAMS support
230 \fBgetresgid\fP(2) 2.2
231 \fBgetresgid32\fP(2) 2.4
232 \fBgetresuid\fP(2) 2.2
233 \fBgetresuid32\fP(2) 2.4
239 \fBgettid\fP(2) 2.4.11
240 \fBgettimeofday\fP(2)
242 \fBgetuid32\fP(2) 2.4
243 \fBgetxattr\fP(2) 2.6; 2.4.18
244 .\" \fBgetunwind\fP(2) ??? ia64; DEPRECATED
248 \fBinotify_add_watch\fP(2) 2.6.13
249 \fBinotify_init\fP(2) 2.6.13
250 \fBinotify_rm_watch\fP(2) 2.6.13
251 \fBio_cancel\fP(2) 2.6; 2.4.20
252 \fBio_destroy\fP(2) 2.6; 2.4.20
253 \fBio_getevents\fP(2) 2.6; 2.4.20
254 \fBio_setup\fP(2) 2.6; 2.4.20
255 \fBio_submit\fP(2) 2.6; 2.4.20
259 \fBioprio_get\fP(2) 2.6.13
260 \fBioprio_set\fP(2) 2.6.13
262 .\" Implements System V IPC calls
263 \fBkexec_load\fP(2) 2.6.7
264 .\" Was named sys_kexec_load() from 2.6.7 to 2.6.16
265 \fBkeyctl\fP(2) 2.6.11
268 \fBlchown32\fP(2) 2.4
269 \fBlgetxattr\fP(2) 2.6; 2.4.18
271 \fBlinkat\fP(2) 2.6.16
273 \fBlistxattr\fP(2) 2.6; 2.4.18
274 \fBllistxattr\fP(2) 2.6; 2.4.18
276 \fBlookup_dcookie\fP(2) 2.6
277 \fBlremovexattr\fP(2) 2.6; 2.4.18
279 \fBlsetxattr\fP(2) 2.6; 2.4.18
283 \fBmadvise1\fP(2) 2.4
285 .\" \fBmemory_ordering\fP(2) ??? Sparc64
286 \fBmigrate_pages\fP(2) 2.6.16
289 \fBmkdirat\fP(2) 2.6.16
291 \fBmknodat\fP(2) 2.6.16
298 \fBmove_pages\fP(2) 2.6.18
301 \fBmq_getsetattr\fP(2) 2.6.6
302 .\" Implements \fBmq_getattr\fP(3) and \fBmq_setattr\fP(3)
303 \fBmq_notify\fP(2) 2.6.6
304 \fBmq_open\fP(2) 2.6.6
305 \fBmq_timedreceive\fP(2) 2.6.6
306 \fBmq_timedsend\fP(2) 2.6.6
314 .\" \fBmultiplexer\fP(2) ?? __NR_multiplexer reserved on
315 .\" PowerPC, but unimplemented?
320 \fBnfsservctl\fP(2) 2.2
328 \fBopenat\fP(2) 2.6.16
330 \fBpciconfig_iobase\fP(2) 2.2.15; 2.4 Not on i386
331 .\" Alpha, PowerPC, ARM; not i386
332 \fBpciconfig_read\fP(2) 2.0.26; 2.2 Not on i386
333 .\" , PowerPC, ARM; not i386
334 \fBpciconfig_write\fP(2) 2.0.26; 2.2 Not on i386
335 .\" , PowerPC, ARM; not i386
337 .\" \fBperfctr\fP(2) ??? Sparc32, Sparc64
338 .\" \fBperfmonctl\fP(2) ??? ia64
340 .\" Unimplemented (no slot since 2.1.116)
342 \fBpivot_root\fP(2) 2.5
344 \fBppoll\fP(2) 2.6.16
346 \fBpread64\fP(2) Added as "pread" in 2.2;
347 renamed "pread64" in 2.6
350 .\" Implemented in glibc; see \fBprofil\fP(3)
351 \fBpselect6\fP(2) 2.6.16
352 .\" Implements \fBpselect\fP(2)
355 .\" Reserved for STREAMS support
356 \fBpwrite64\fP(2) Added as "pwrite" in 2.2;
357 renamed "pwrite64" in 2.6
358 \fBquery_module\fP(2) 2.2
361 \fBreadahead\fP(2) 2.4.13
363 .\" Supersedes \fBgetdents\fP(2)
365 \fBreadlinkat\fP(2) 2.6.16
371 \fBremap_file_pages\fP(2) 2.6
372 \fBremovexattr\fP(2) 2.6; 2.4.18
374 \fBrenameat\fP(2) 2.6.16
375 \fBrequest_key\fP(2) 2.6.11
376 \fBrestart_syscall\fP(2) 2.6
378 \fBrt_sigaction\fP(2) 2.2
379 \fBrt_sigpending\fP(2) 2.2
380 \fBrt_sigprocmask\fP(2) 2.2
381 \fBrt_sigqueueinfo\fP(2) 2.2
382 .\" Implements \fBsigqueue\fP(2)
383 \fBrt_sigreturn\fP(2) 2.2
384 \fBrt_sigsuspend\fP(2) 2.2
385 \fBrt_sigtimedwait\fP(2) 2.2
386 \fBsched_get_priority_max\fP(2)
387 \fBsched_get_priority_min\fP(2)
388 \fBsched_getaffinity\fP(2) 2.6; 2.4.19
389 \fBsched_getparam\fP(2)
390 \fBsched_getscheduler\fP(2)
391 \fBsched_rr_get_interval\fP(2)
392 \fBsched_setaffinity\fP(2) 2.6; 2.4.19
393 \fBsched_setparam\fP(2)
394 \fBsched_setscheduler\fP(2)
396 \fBsecurity\fP(2) 2.4.11
401 \fBsemtimedop\fP(2) 2.6; 2.4.22
403 \fBsendfile\fP(2) 2.2
404 \fBsendfile64\fP(2) 2.6; 2.4.19
407 \fBset_mempolicy\fP(2) 2.6.6
408 \fBset_robust_list\fP(2) 2.6.17
409 \fBset_thread_area\fP(2) 2.6; 2.4.20
410 \fBset_tid_address\fP(2) 2.6
411 \fBset_zone_reclaim\fP(2) 2.6.13 Removed in 2.6.16 (was never
412 available to userspace)
413 .\" See http://lkml.org/lkml/2005/8/1/83
414 .\" "[PATCH] remove sys_set_zone_reclaim()"
415 \fBsetdomainname\fP(2)
417 \fBsetfsgid32\fP(2) 2.4
419 \fBsetfsuid32\fP(2) 2.4
421 \fBsetgid32\fP(2) 2.4
423 \fBsetgroups32\fP(2) 2.4
429 \fBsetregid32\fP(2) 2.4
430 \fBsetresgid\fP(2) 2.2
431 \fBsetresgid32\fP(2) 2.4
432 \fBsetresuid\fP(2) 2.2
433 \fBsetresuid32\fP(2) 2.4
435 \fBsetreuid32\fP(2) 2.4
439 \fBsettimeofday\fP(2)
441 \fBsetuid32\fP(2) 2.4
442 \fBsetup\fP(2) Removed in 2.2
443 \fBsetxattr\fP(2) 2.6; 2.4.18
451 \fBsigaltstack\fP(2) 2.2
453 \fBsignalfd\fP(2) 2.6.22
460 .\" Implements BSD socket calls
462 \fBsplice\fP(2) 2.6.17
463 \fBspu_create\fP(2) 2.6.16 PowerPC only
464 \fBspu_run\fP(2) 2.6.16 PowerPC only
469 \fBstatfs64\fP(2) 2.6
475 \fBsymlinkat\fP(2) 2.6.16
477 \fBsync_file_range\fP(2) 2.6.17
478 .\" \fBsys_debug_setcontext\fP(2) ??? PowerPC if CONFIG_PPC32
482 .\" glibc interface is \fBklogctl\fP(3)
486 \fBtimer_create\fP(2) 2.6
487 \fBtimer_delete\fP(2) 2.6
488 \fBtimer_getoverrun\fP(2) 2.6
489 \fBtimer_gettime\fP(2) 2.6
490 \fBtimer_settime\fP(2) 2.6
491 \fBtimerfd\fP(2) 2.6.22
493 \fBtkill\fP(2) 2.6; 2.4.22
495 \fBtruncate64\fP(2) 2.4
497 .\" Unimplemented; no slot on i386
498 .\" As at 2.6.22, tuxcall has a slot on PowerPC, x86_64, and alpha
499 \fBugetrlimit\fP(2) 2.4
501 .\" Implemented in glibc; see \fBulimit\fP(3)
504 .\" sys_oldumount() -- __NR_umount
506 .\" sys_umount() -- __NR_umount2
509 \fBunlinkat\fP(2) 2.6.16
510 \fBunshare\fP(2) 2.6.16
514 \fButimensat\fP(2) 2.6.22
519 .\" Superseded by \fBvm86\fP(2)
520 \fBvmsplice\fP(2) 2.6.17
523 \fBwaitid\fP(2) 2.6.10
529 On many platforms, including i386, socket calls are all multiplexed
530 (via glibc wrapper functions) through
532 and similarly System V IPC calls are multiplexed through
535 Note the following points:
537 Although slots are reserved for them in the system call table,
538 the following system calls are not implemented in the standard kernel:
539 .BR afs_syscall (2), \" __NR_afs_syscall is 53 on Linux 2.6.22/i386
540 .BR break (2), \" __NR_break is 17 on Linux 2.6.22/i386
541 .BR ftime (2), \" __NR_ftime is 35 on Linux 2.6.22/i386
542 .BR getpmsg (2), \" __NR_getpmsg is 188 on Linux 2.6.22/i386
543 .BR gtty (2), \" __NR_gtty is 32 on Linux 2.6.22/i386
544 .BR idle (2), \" __NR_idle is 112 on Linux 2.6.22/i386
545 .BR lock (2), \" __NR_lock is 53 on Linux 2.6.22/i386
546 .BR madvise1 (2), \" __NR_madvise1 is 219 on Linux 2.6.22/i386
547 .BR mpx (2), \" __NR_mpx is 66 on Linux 2.6.22/i386
548 .BR phys (2), \" Slot has been re-used
549 .BR prof (2), \" __NR_prof is 44 on Linux 2.6.22/i386
550 .BR profil (2), \" __NR_profil is 98 on Linux 2.6.22/i386
551 .BR putpmsg (2), \" __NR_putpmsg is 189 on Linux 2.6.22/i386
552 .\" __NR_security is 223 on Linux 2.4/i386; absent on 2.6/i386, present
553 .\" on a couple of 2.6 architectures
554 .BR security (2), \" __NR_security is 223 on Linux 2.4/i386
555 .BR stty (2), \" __NR_stty is 31 on Linux 2.6.22/i386
556 .BR tuxcall (2), \" __NR_tuxcall is 184 on x86_64, also on PPC and alpha
557 .BR ulimit (2), \" __NR_ulimit is 58 on Linux 2.6.22/i386
559 .BR vserver (2) \" __NR_vserver is 273 on Linux 2.6.22/i386
561 .BR unimplemented (2)).
567 exist as library routines.
570 is in use since kernel 2.1.116 for
573 will never be implemented.
579 calls are for kernels patched to support STREAMS,
580 and may never be in the standard kernel.
581 .\" The security call is for future use.
583 Roughly speaking, the code belonging to the system call
584 with number __NR_xxx defined in
585 .I /usr/include/asm/unistd.h
586 can be found in the kernel source in the routine
588 (The dispatch table for i386 can be found in
589 .IR /usr/src/linux/arch/i386/kernel/entry.S .)
590 There are many exceptions, however, mostly because
591 older system calls were superseded by newer ones,
592 and this has been treated somewhat unsystematically.
594 proprietary OS emulation, such as parisc, sparc, sparc64 and alpha,
595 there are many additional system calls; mips64 also contains a full
596 set of 32-bit system calls.
598 Over time, changes to the interfaces of some system calls have been
600 One reason for such changes was the need to increase the size of
601 structures or scalar values passed to the system call.
602 Because of these changes, there are now various groups
603 of related system calls
608 which perform similar tasks, but which vary in
609 details such as the size of their arguments.
610 (As noted earlier, applications are generally unaware of this:
611 the glibc wrapper functions do some work to ensure that the right
612 system call is invoked, and that ABI compatibility is
613 preserved for old binaries.)
614 Examples of systems calls that exist in multiple versions are
617 By now there are three different versions of
629 with the last being the most current.
630 .\" e.g., on 2.6.22/i386: __NR_oldstat 18, __NR_stat 106, __NR_stat64 195
631 .\" The stat system calls deal with three different data structures,
632 .\" defined in include/asm-i386/stat.h: __old_kernel_stat, stat, stat64
633 A similar story applies for
638 Similarly, the defines
639 .IR __NR_oldolduname ,
643 refer to the routines
649 In Linux 2.0, a new version of
651 appeared, with the old and the new kernel routines being named
656 In Linux 2.4, a new version of
658 appeared, with the old and the new kernel routines being named
659 .IR sys_old_getrlimit ()
665 .IR __NR_ugetrlimit ).
667 Linux 2.4 increased the size of user and group IDs from 16 to 32 bits.
668 .\" 64 bit off_t changes: ftruncate64, *stat64,
669 .\" fcntl64 (because of the flock structure), getdents64, *statfs64
670 To support this change, a range of system calls were added
675 .BR setresuid32 (2)),
676 superseding earlier calls of the same name without the
679 Linux 2.4 added support for applications on 32-bit architectures
680 to access large files (i.e., files for which the sizes and
681 file offsets can't be represented in 32 bits.)
682 To support this change, replacements were required for system calls
683 that deal with file offsets and sizes.
684 Thus the following system calls were added:
690 and their analogs that work with file descriptors or
692 These system calls supersede the older system calls
693 which, except in the case of the "stat" calls,
694 have the same name without the "64" suffix.
696 On newer platforms that only have 64-bit file access and 32-bit uids
697 (e.g., alpha, ia64, s390x) there are no *64 or *32 calls.
698 Where the *64 and *32 calls exist, the other versions are obsolete.
702 calls were added in kernel 2.2 to support the addition
703 of real-time signals (see
705 These system calls supersede the older system calls of the same
706 name without the "rt_" prefix.
712 system calls use five or more parameters,
713 which caused problems the way
714 parameter passing on the i386 used to be set up.
715 Thus, while other architectures have
727 (routines that use a pointer to a
728 parameter block) instead.
729 These days passing five parameters
730 is not a problem any more, and there is a
733 that corresponds directly to
738 .\" Two system call numbers,
742 .\" have an additional underscore absent in
743 .\" .IR sys_llseek ()
745 .\" .IR sys_sysctl ().
747 .\" In kernel 2.1.81,
751 .\" were swapped; that is,
753 .\" was added with the semantics that were then current for
755 .\" and the semantics of the latter call were changed to what
759 .BR unimplemented (2)