1SYSCALLS(2)                Linux Programmer's Manual               SYSCALLS(2)
2
3
4

NAME

6       syscalls - Linux system calls
7

SYNOPSIS

9       Linux system calls.
10

DESCRIPTION

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.33 (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)
109       bind(2)
110       break(2)                                  Not implemented
111       brk(2)
112       cacheflush(2)               1.2           Not on i386
113       capget(2)                   2.2
114       capset(2)                   2.2
115       chdir(2)
116       chmod(2)
117       chown(2)
118       chown32(2)                  2.4
119       chroot(2)
120       clock_getres(2)             2.6
121       clock_gettime(2)            2.6
122       clock_nanosleep(2)          2.6
123       clock_settime(2)            2.6
124       clone(2)
125       close(2)
126       connect(2)
127       creat(2)
128       create_module(2)
129       delete_module(2)
130       dup(2)
131       dup2(2)
132
133       dup3(2)                     2.6.27
134       epoll_create(2)             2.6
135       epoll_create1(2)            2.6.27
136       epoll_ctl(2)                2.6
137       epoll_pwait(2)              2.6.19
138       epoll_wait(2)               2.6
139       eventfd(2)                  2.6.22
140       eventfd2(2)                 2.6.27
141       execve(2)
142       exit(2)
143       exit_group(2)               2.6
144       faccessat(2)                2.6.16
145       fadvise64(2)                2.6
146       fadvise64_64(2)             2.6
147       fallocate(2)                2.6.23
148       fchdir(2)
149       fchmod(2)
150       fchmodat(2)                 2.6.16
151       fchown(2)
152       fchown32(2)                 2.4
153       fchownat(2)                 2.6.16
154       fcntl(2)
155       fcntl64(2)                  2.4
156       fdatasync(2)
157       fgetxattr(2)                2.6; 2.4.18
158       flistxattr(2)               2.6; 2.4.18
159       flock(2)                    2.0
160       fork(2)
161       free_hugepages(2)           2.5.36        Removed in 2.5.44
162       fremovexattr(2)             2.6; 2.4.18
163       fsetxattr(2)                2.6; 2.4.18
164       fstat(2)
165       fstat64(2)                  2.4
166       fstatat64(2)                2.6.16
167       fstatfs(2)
168       fstatfs64(2)                2.6
169       fsync(2)
170       ftime(2)                                  Not implemented
171       ftruncate(2)
172       ftruncate64(2)              2.4
173       futex(2)                    2.6
174       futimesat(2)                2.6.16
175       get_kernel_syms(2)
176       get_mempolicy(2)            2.6.6
177       get_robust_list(2)          2.6.17
178       get_thread_area(2)          2.6
179       getcpu(2)                   2.6.19
180       getcwd(2)                   2.2
181       getdents(2)                 2.0
182       getdents64(2)               2.4
183       getegid(2)
184       getegid32(2)                2.4
185       geteuid(2)
186       geteuid32(2)                2.4
187       getgid(2)
188       getgid32(2)                 2.4
189       getgroups(2)
190       getgroups32(2)              2.4
191       getitimer(2)
192       getpeername(2)
193       getpagesize(2)              2.0           Not on i386
194       getpgid(2)
195       getpgrp(2)
196       getpid(2)
197       getpmsg(2)                                Not implemented
198
199       getppid(2)
200       getpriority(2)
201       getresgid(2)                2.2
202       getresgid32(2)              2.4
203       getresuid(2)                2.2
204       getresuid32(2)              2.4
205       getrlimit(2)
206       getrusage(2)
207       getsid(2)                   2.0
208       getsockname(2)
209       getsockopt(2)
210       gettid(2)                   2.4.11
211       gettimeofday(2)
212       getuid(2)
213       getuid32(2)                 2.4
214       getxattr(2)                 2.6; 2.4.18
215       gtty(2)                                   Not implemented
216       idle(2)                                   Not implemented
217       init_module(2)
218       inotify_add_watch(2)        2.6.13
219       inotify_init(2)             2.6.13
220       inotify_init1(2)            2.6.27
221       inotify_rm_watch(2)         2.6.13
222       io_cancel(2)                2.6
223       io_destroy(2)               2.6
224       io_getevents(2)             2.6
225       io_setup(2)                 2.6
226       io_submit(2)                2.6
227       ioctl(2)
228       ioperm(2)
229       iopl(2)
230       ioprio_get(2)               2.6.13
231       ioprio_set(2)               2.6.13
232       ipc(2)
233       kexec_load(2)               2.6.7
234       keyctl(2)                   2.6.11
235       kill(2)
236       lchown(2)                   2.2
237       lchown32(2)                 2.4
238       lgetxattr(2)                2.6; 2.4.18
239       link(2)
240       linkat(2)                   2.6.16
241       listen(2)
242       listxattr(2)                2.6; 2.4.18
243       llistxattr(2)               2.6; 2.4.18
244       lock(2)                                   Not implemented
245       lookup_dcookie(2)           2.6
246       lremovexattr(2)             2.6; 2.4.18
247       lseek(2)
248       lsetxattr(2)                2.6; 2.4.18
249       lstat(2)
250       lstat64(2)                  2.4
251       madvise(2)                  2.4
252       madvise1(2)                 2.4
253       mbind(2)                    2.6.6
254       migrate_pages(2)            2.6.16
255       mincore(2)                  2.4
256       mkdir(2)
257       mkdirat(2)                  2.6.16
258       mknod(2)
259       mknodat(2)                  2.6.16
260       mlock(2)
261       mlockall(2)
262       mmap(2)
263       mmap2(2)                    2.4
264
265       modify_ldt(2)
266       mount(2)
267       move_pages(2)               2.6.18
268       mprotect(2)
269       mpx(2)                                    Not implemented
270       mq_getsetattr(2)            2.6.6
271       mq_notify(2)                2.6.6
272       mq_open(2)                  2.6.6
273       mq_timedreceive(2)          2.6.6
274       mq_timedsend(2)             2.6.6
275       mq_unlink(2)
276       mremap(2)                   2.0
277       msgctl(2)
278       msgget(2)
279       msgrcv(2)
280       msgsnd(2)
281       msync(2)                    2.0
282       munlock(2)
283       munlockall(2)
284       munmap(2)
285       nanosleep(2)                2.0
286       nfsservctl(2)               2.2
287       nice(2)
288       oldfstat(2)
289       oldlstat(2)
290       oldolduname(2)
291       oldstat(2)
292       olduname(2)
293       open(2)
294       openat(2)                   2.6.16
295       pause(2)
296       pciconfig_iobase(2)         2.2.15; 2.4   Not on i386
297       pciconfig_read(2)           2.0.26; 2.2   Not on i386
298       pciconfig_write(2)          2.0.26; 2.2   Not on i386
299       perf_event_open(2)          2.6.31        Was called perf_counter_open()
300                                                 in 2.6.31; renamed in 2.6.32
301       personality(2)              1.2
302       phys(2)                                   Not implemented
303       pipe(2)
304       pipe2(2)                    2.6.27
305       pivot_root(2)               2.4
306       poll(2)                     2.2
307       ppoll(2)                    2.6.16
308       prctl(2)                    2.2
309       pread64(2)                                Added as "pread" in 2.2;
310                                                 renamed "pread64" in 2.6
311       preadv(2)                   2.6.30
312       prof(2)                                   Not implemented
313       profil(2)                                 Not implemented
314       pselect6(2)                 2.6.16
315       ptrace(2)
316       putpmsg(2)                                Not implemented
317       pwrite64(2)                               Added as "pwrite" in 2.2;
318                                                 renamed "pwrite64" in 2.6
319       pwritev(2)                  2.6.30
320       query_module(2)             2.2
321       quotactl(2)
322       read(2)
323       readahead(2)                2.4.13
324       readdir(2)
325       readlink(2)
326       readlinkat(2)               2.6.16
327       readv(2)                    2.0
328       reboot(2)
329       recv(2)
330
331       recvfrom(2)
332       recvmsg(2)
333       recvmmsg(2)                 2.6.33
334       remap_file_pages(2)         2.6
335       removexattr(2)              2.6; 2.4.18
336       rename(2)
337       renameat(2)                 2.6.16
338       request_key(2)              2.6.11
339       restart_syscall(2)          2.6
340       rmdir(2)
341       rt_sigaction(2)             2.2
342       rt_sigpending(2)            2.2
343       rt_sigprocmask(2)           2.2
344       rt_sigqueueinfo(2)          2.2
345       rt_sigreturn(2)             2.2
346       rt_sigsuspend(2)            2.2
347       rt_sigtimedwait(2)          2.2
348       rt_tgsigqueueinfo(2)        2.6.31
349       sched_get_priority_max(2)   2.0
350       sched_get_priority_min(2)   2.0
351       sched_getaffinity(2)        2.6
352       sched_getparam(2)           2.0
353       sched_getscheduler(2)       2.0
354       sched_rr_get_interval(2)    2.0
355       sched_setaffinity(2)        2.6
356       sched_setparam(2)           2.0
357       sched_setscheduler(2)       2.0
358       sched_yield(2)              2.0
359       security(2)                               Not implemented
360       select(2)
361       semctl(2)
362       semget(2)
363       semop(2)
364       semtimedop(2)               2.6; 2.4.22
365       send(2)
366       sendfile(2)                 2.2
367       sendfile64(2)               2.6; 2.4.19
368       sendmsg(2)
369       sendto(2)
370       set_mempolicy(2)            2.6.6
371       set_robust_list(2)          2.6.17
372       set_thread_area(2)          2.6
373       set_tid_address(2)          2.6
374       set_zone_reclaim(2)         2.6.13        Removed in 2.6.16 (was never
375                                                 available to userspace)
376       setdomainname(2)
377       setfsgid(2)                 1.2
378       setfsgid32(2)               2.4
379       setfsuid(2)                 1.2
380       setfsuid32(2)               2.4
381       setgid(2)
382       setgid32(2)                 2.4
383       setgroups(2)
384       setgroups32(2)              2.4
385       sethostname(2)
386       setitimer(2)
387       setpgid(2)
388       setpriority(2)
389       setregid(2)
390       setregid32(2)               2.4
391       setresgid(2)                2.2
392       setresgid32(2)              2.4
393       setresuid(2)                2.2
394       setresuid32(2)              2.4
395       setreuid(2)
396
397       setreuid32(2)               2.4
398       setrlimit(2)
399       setsid(2)
400       setsockopt(2)
401       settimeofday(2)
402       setuid(2)
403       setuid32(2)                 2.4
404       setup(2)                                  Removed in 2.2
405       setxattr(2)                 2.6; 2.4.18
406       sgetmask(2)
407       shmat(2)
408       shmctl(2)
409       shmdt(2)
410       shmget(2)
411       shutdown(2)
412       sigaction(2)
413       sigaltstack(2)              2.2
414       signal(2)
415       signalfd(2)                 2.6.22
416       signalfd4(2)                2.6.27
417       sigpending(2)
418       sigprocmask(2)
419       sigreturn(2)
420       sigsuspend(2)
421       socket(2)
422       socketcall(2)
423       socketpair(2)
424       splice(2)                   2.6.17
425       spu_create(2)               2.6.16        PowerPC only
426       spu_run(2)                  2.6.16        PowerPC only
427       ssetmask(2)
428       stat(2)
429       stat64(2)                   2.4
430       statfs(2)
431       statfs64(2)                 2.6
432       stime(2)
433       stty(2)                                   Not implemented
434       swapoff(2)
435       swapon(2)
436       symlink(2)
437       symlinkat(2)                2.6.16
438       sync(2)
439       sync_file_range(2)          2.6.17
440       sysfs(2)                    1.2
441       sysinfo(2)
442       syslog(2)
443       tee(2)                      2.6.17
444       tgkill(2)                   2.6
445       time(2)
446       timer_create(2)             2.6
447       timer_delete(2)             2.6
448       timer_getoverrun(2)         2.6
449       timer_gettime(2)            2.6
450       timer_settime(2)            2.6
451       timerfd_create(2)           2.6.25
452       timerfd_gettime(2)          2.6.25
453       timerfd_settime(2)          2.6.25
454       times(2)
455       tkill(2)                    2.6; 2.4.22
456       truncate(2)
457       truncate64(2)               2.4
458       tuxcall(2)                                Not implemented
459       ugetrlimit(2)               2.4
460       ulimit(2)                                 Not implemented
461       umask(2)
462
463       umount(2)
464       umount2(2)                  2.2
465       uname(2)
466       unlink(2)
467       unlinkat(2)                 2.6.16
468       unshare(2)                  2.6.16
469       uselib(2)
470       ustat(2)
471       utime(2)
472       utimensat(2)                2.6.22
473       utimes(2)                   2.2
474       vfork(2)
475       vhangup(2)
476       vm86old(2)
477       vmsplice(2)                 2.6.17
478       vserver(2)                                Not implemented
479       wait4(2)
480       waitid(2)                   2.6.10
481       waitpid(2)
482       write(2)
483       writev(2)                   2.0
484
485       On many platforms, including i386, socket  calls  are  all  multiplexed
486       (via  glibc wrapper functions) through socketcall(2) and similarly Sys‐
487       tem V IPC calls are multiplexed through ipc(2).
488

NOTES

490       Note the following points:
491
492       *  Although slots are reserved for them in the system call  table,  the
493          following  system  calls are not implemented in the standard kernel:
494          afs_syscall(2), break(2), ftime(2),  getpmsg(2),  gtty(2),  idle(2),
495          lock(2),   madvise1(2),   mpx(2),   phys(2),   prof(2),   profil(2),
496          putpmsg(2),  security(2),  stty(2),   tuxcall(2),   ulimit(2),   and
497          vserver(2)  (see  also  unimplemented(2)).   However, ftime(3), pro‐
498          fil(3) and ulimit(3)  exist  as  library  routines.   The  slot  for
499          phys(2)  is  in use since kernel 2.1.116 for umount(2); phys(2) will
500          never be implemented.
501
502       *  The getpmsg(2) and putpmsg(2) calls are for kernels patched to  sup‐
503          port STREAMS, and may never be in the standard kernel.
504
505       Roughly  speaking,  the  code  belonging to the system call with number
506       __NR_xxx defined in /usr/include/asm/unistd.h can be found in the  ker‐
507       nel  source in the routine sys_xxx().  (The dispatch table for i386 can
508       be found in /usr/src/linux/arch/i386/kernel/entry.S.)  There  are  many
509       exceptions,  however, mostly because older system calls were superseded
510       by newer ones, and this has been treated somewhat unsystematically.  On
511       platforms with proprietary OS emulation, such as parisc, sparc, sparc64
512       and alpha, there are many additional system calls; mips64 also contains
513       a full set of 32-bit system calls.
514
515       Over  time,  changes  to  the interfaces of some system calls have been
516       necessary.  One reason for such changes was the need  to  increase  the
517       size of structures or scalar values passed to the system call.  Because
518       of these changes, there are now various groups of related system  calls
519       (e.g.,  truncate(2) and truncate64(2)) which perform similar tasks, but
520       which vary in details such as the size of their arguments.   (As  noted
521       earlier,  applications are generally unaware of this: the glibc wrapper
522       functions do some work to ensure that the right system call is invoked,
523       and that ABI compatibility is preserved for old binaries.)  Examples of
524       systems calls that exist in multiple versions are the following:
525
526       *  By now there are three different  versions  of  stat(2):  sys_stat()
527          (slot    __NR_oldstat),    sys_newstat()   (slot   __NR_stat),   and
528          sys_stat64() (slot __NR_stat64), with the last being the  most  cur‐
529          rent.  A similar story applies for lstat(2) and fstat(2).
530
531       *  Similarly,   the   defines   __NR_oldolduname,   __NR_olduname,  and
532          __NR_uname refer to the  routines  sys_olduname(),  sys_uname()  and
533          sys_newuname().
534
535       *  In  Linux  2.0,  a new version of vm86(2) appeared, with the old and
536          the new kernel routines being named sys_vm86old() and sys_vm86().
537
538       *  In Linux 2.4, a new version of getrlimit(2) appeared, with  the  old
539          and  the  new  kernel routines being named sys_old_getrlimit() (slot
540          __NR_getrlimit) and sys_getrlimit() (slot __NR_ugetrlimit).
541
542       *  Linux 2.4 increased the size of user and group IDs  from  16  to  32
543          bits.   To  support  this change, a range of system calls were added
544          (e.g.,  chown32(2),  getuid32(2),  getgroups32(2),  setresuid32(2)),
545          superseding earlier calls of the same name without the "32" suffix.
546
547       *  Linux  2.4 added support for applications on 32-bit architectures to
548          access large files (i.e., files for which the sizes and file offsets
549          can't  be represented in 32 bits.)  To support this change, replace‐
550          ments were required for system calls that deal with file offsets and
551          sizes.   Thus  the  following  system  calls were added: fcntl64(2),
552          ftruncate64(2), getdents64(2),  stat64(2),  statfs64(2),  and  their
553          analogs  that  work  with file descriptors or symbolic links.  These
554          system calls supersede the older system calls which, except  in  the
555          case  of  the "stat" calls, have the same name without the "64" suf‐
556          fix.
557
558          On newer platforms that only have 64-bit file access and 32-bit uids
559          (e.g., alpha, ia64, s390x) there are no *64 or *32 calls.  Where the
560          *64 and *32 calls exist, the other versions are obsolete.
561
562       *  The rt_sig* calls were added in kernel 2.2 to support  the  addition
563          of  real-time signals (see signal(7)).  These system calls supersede
564          the older system calls of the same name without the "rt_" prefix.
565
566       *  The select(2) and mmap(2) system calls use five or  more  arguments,
567          which  caused  problems the way argument passing on the i386 used to
568          be set up.  Thus, while other architectures  have  sys_select()  and
569          sys_mmap()  corresponding  to __NR_select and __NR_mmap, on i386 one
570          finds old_select() and old_mmap() (routines that use a pointer to  a
571          argument block) instead.  These days passing five arguments is not a
572          problem any more, and there is a  __NR__newselect  that  corresponds
573          directly to sys_select() and similarly __NR_mmap2.
574

SEE ALSO

576       syscall(2), unimplemented(2), libc(7)
577

COLOPHON

579       This  page  is  part of release 3.25 of the Linux man-pages project.  A
580       description of the project, and information about reporting  bugs,  can
581       be found at http://www.kernel.org/doc/man-pages/.
582
583
584
585Linux                             2010-03-06                       SYSCALLS(2)
Impressum