shim_syscalls.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* Copyright (C) 2014 OSCAR lab, Stony Brook University
  4. This file is part of Graphene Library OS.
  5. Graphene Library OS is free software: you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation, either version 3 of the
  8. License, or (at your option) any later version.
  9. Graphene Library OS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /*
  16. * shim_syscalls.c
  17. *
  18. * This file contains macros to redirect all system calls to the system call
  19. * table in library OS.
  20. */
  21. #include <shim_internal.h>
  22. #include <shim_table.h>
  23. #include <shim_tls.h>
  24. #include <shim_thread.h>
  25. #include <shim_unistd.h>
  26. #include <shim_utils.h>
  27. #include <shim_profile.h>
  28. #include <pal.h>
  29. #include <pal_error.h>
  30. #include <asm/unistd.h>
  31. #include <asm/prctl.h>
  32. #include <errno.h>
  33. long int if_call_defined (long int sys_no)
  34. {
  35. return shim_table[sys_no] != 0;
  36. }
  37. DEFINE_PROFILE_CATAGORY(syscall, );
  38. //////////////////////////////////////////////////
  39. // Mappings from system calls to shim calls
  40. ///////////////////////////////////////////////////
  41. /*
  42. Missing, but need to be added:
  43. * clone
  44. * semctl
  45. from 'man unimplemented':
  46. NOT IMPLEMENTED in kernel (always return -ENOSYS)
  47. NAME
  48. afs_syscall, break, ftime, getpmsg, gtty, lock, madvise1, mpx, prof,
  49. profil, putpmsg, security, stty, tuxcall, ulimit, vserver -
  50. unimplemented system calls
  51. SYNOPSIS
  52. Unimplemented system calls.
  53. DESCRIPTION
  54. These system calls are not implemented in the Linux 2.6.22 kernel.
  55. RETURN VALUE
  56. These system calls always return -1 and set errno to ENOSYS.
  57. NOTES
  58. Note that ftime(3), profil(3) and ulimit(3) are implemented as library
  59. functions.
  60. Some system calls, like alloc_hugepages(2), free_hugepages(2), ioperm(2),
  61. iopl(2), and vm86(2) only exist on certain architectures.
  62. Some system calls, like ipc(2), create_module(2), init_module(2), and
  63. delete_module(2) only exist when the Linux kernel was built with support
  64. for them.
  65. SEE ALSO
  66. syscalls(2)
  67. COLOPHON
  68. This page is part of release 3.24 of the Linux man-pages project. A
  69. description of the project, and information about reporting bugs, can
  70. be found at http://www.kernel.org/doc/man-pages/.
  71. Linux 2007-07-05 UNIMPLEMENTED(2)
  72. Also missing from shim:
  73. * epoll_ctl_old
  74. * epoll_wait_old
  75. According to kernel man pages, glibc does not provide wrappers for
  76. every system call (append to this list as you come accross more):
  77. * io_setup
  78. * ioprio_get
  79. * ioprio_set
  80. * sysctl
  81. * getdents
  82. * tkill
  83. * tgkill
  84. Also not in libc (append to this list as you come accross more):
  85. * add_key: (removed in Changelog.17)
  86. * request_key: (removed in Changelog.17)
  87. * keyctl: (removed in Changelog.17)
  88. Although these are Linux system calls, they are not present in
  89. libc but can be found rather in libkeyutils. When linking,
  90. -lkeyutils should be specified to the linker.x
  91. There are probably other things of note, so put them here as you
  92. come across them.
  93. */
  94. /* Please move implemented system call to sys/ directory and name them as the
  95. * most important system call */
  96. /* read: sys/shim_open.c */
  97. DEFINE_SHIM_SYSCALL (read, 3, shim_do_read, size_t, int, fd, void *, buf,
  98. size_t, count)
  99. /* write: sys/shim_open.c */
  100. DEFINE_SHIM_SYSCALL (write, 3, shim_do_write, size_t, int, fd, const void *,
  101. buf, size_t, count)
  102. /* open: sys/shim_open.c */
  103. DEFINE_SHIM_SYSCALL (open, 3, shim_do_open, int, const char *, file, int, flags,
  104. mode_t, mode)
  105. /* close: sys/shim_open.c */
  106. DEFINE_SHIM_SYSCALL (close, 1, shim_do_close, int, int, fd)
  107. /* stat: sys/shim_stat.c */
  108. DEFINE_SHIM_SYSCALL (stat, 2, shim_do_stat, int, const char *, file,
  109. struct stat *, statbuf)
  110. /* fstat: sys/shim_stat.c */
  111. DEFINE_SHIM_SYSCALL (fstat, 2, shim_do_fstat, int, int, fd,
  112. struct stat *, statbuf)
  113. /* lstat: sys/shim_lstat.c */
  114. /* for now we don't support symbolic link, so lstat will work exactly the same
  115. as stat. */
  116. DEFINE_SHIM_SYSCALL (lstat, 2, shim_do_lstat, int, const char *, file,
  117. struct stat *, statbuf)
  118. /* poll: sys/shim_poll.c */
  119. DEFINE_SHIM_SYSCALL (poll, 3, shim_do_poll, int, struct pollfd *, fds, nfds_t,
  120. nfds, int, timeout)
  121. /* lseek: sys/shim_open.c */
  122. DEFINE_SHIM_SYSCALL (lseek, 3, shim_do_lseek, off_t, int, fd, off_t, offset,
  123. int, origin)
  124. /* mmap: sys/shim_mmap.c */
  125. DEFINE_SHIM_SYSCALL (mmap, 6, shim_do_mmap, void *, void *, addr,
  126. size_t, length, int, prot, int, flags, int, fd,
  127. off_t, offset)
  128. /* mprotect: sys/shim_mmap.c */
  129. DEFINE_SHIM_SYSCALL (mprotect, 3, shim_do_mprotect, int, void *, addr, size_t,
  130. len, int, prot)
  131. /* munmap: sys/shim_mmap.c */
  132. DEFINE_SHIM_SYSCALL (munmap, 2, shim_do_munmap, int, void *, addr, size_t, len)
  133. DEFINE_SHIM_SYSCALL (brk, 1, shim_do_brk, void *, void *, brk)
  134. #if 0 /* implemented */
  135. void * shim_do_brk (void * brk)
  136. {
  137. brk = NULL; /* fix the warning */
  138. /* lets return 0 ;
  139. * libc falls back to mmap options if brk fails
  140. * Following are comments from libc / malloc.c
  141. *
  142. * If you'd like mmap to ALWAYS be, used, you can define MORECORE to be
  143. * a function that always returns MORECORE_FAILURE.
  144. */
  145. return (void *) -ENOMEM;
  146. }
  147. #endif
  148. /* rt_sigaction: sys/shim_sigaction.c */
  149. DEFINE_SHIM_SYSCALL (rt_sigaction, 3, shim_do_sigaction, int, int, signum,
  150. const struct __kernel_sigaction *, act, struct __kernel_sigaction *, oldact)
  151. /* rt_sigprocmask: sys/shim_sigaction.c */
  152. DEFINE_SHIM_SYSCALL (rt_sigprocmask, 3, shim_do_sigprocmask, int, int, how,
  153. const __sigset_t *, set, __sigset_t *, oldset)
  154. /* rt_sigreturn: sys/shim_sigaction.c */
  155. DEFINE_SHIM_SYSCALL (rt_sigreturn, 1, shim_do_sigreturn, int, int, __unused)
  156. /* ioctl: sys/shim_ioctl.c */
  157. DEFINE_SHIM_SYSCALL (ioctl, 3, shim_do_ioctl, int, int, fd, int, cmd,
  158. unsigned long, arg)
  159. /* pread64 : sys/shim_open.c */
  160. DEFINE_SHIM_SYSCALL (pread64, 4, shim_do_pread64, size_t, int, fd, char *, buf,
  161. size_t, count, loff_t, pos)
  162. /* pwrite64 : sys/shim_open.c */
  163. DEFINE_SHIM_SYSCALL (pwrite64, 4, shim_do_pwrite64, size_t, int, fd, char *,
  164. buf, size_t, count, loff_t, pos)
  165. /* readv : sys/shim_wrappers.c */
  166. DEFINE_SHIM_SYSCALL (readv, 3, shim_do_readv, ssize_t, int, fd,
  167. const struct iovec *, vec, int, vlen)
  168. /* writev : sys/shim_wrappers.c */
  169. DEFINE_SHIM_SYSCALL (writev, 3, shim_do_writev, ssize_t, int, fd,
  170. const struct iovec *, vec, int, vlen)
  171. /* access: sys/shim_access.c */
  172. DEFINE_SHIM_SYSCALL (access, 2, shim_do_access, int, const char *, file,
  173. mode_t, mode)
  174. /* pipe: sys/shim_pipe.c */
  175. DEFINE_SHIM_SYSCALL (pipe, 1, shim_do_pipe, int, int *, fildes)
  176. /* select : sys/shim_poll.c*/
  177. DEFINE_SHIM_SYSCALL (select, 5, shim_do_select, int, int, nfds, fd_set *,
  178. readfds, fd_set *, writefds, fd_set *, errorfds,
  179. struct __kernel_timeval *, timeout)
  180. /* sched_yield: sys/shim_sched.c */
  181. DEFINE_SHIM_SYSCALL (sched_yield, 0, shim_do_sched_yield, int)
  182. SHIM_SYSCALL_PASSTHROUGH (mremap, 5, void *, void *, addr, size_t, old_len,
  183. size_t, new_len, int, flags, void *, new_addr)
  184. SHIM_SYSCALL_PASSTHROUGH (msync, 3, int, void *, start, size_t, len, int, flags)
  185. SHIM_SYSCALL_PASSTHROUGH (mincore, 3, int, void *, start, size_t, len,
  186. unsigned char *, vec)
  187. SHIM_SYSCALL_PASSTHROUGH (madvise, 3, int, void *, start, size_t, len,
  188. int, behavior)
  189. SHIM_SYSCALL_PASSTHROUGH (shmget, 3, int, key_t, key, size_t, size, int, shmflg)
  190. SHIM_SYSCALL_PASSTHROUGH (shmat, 3, void *, int, shmid, const void *, shmaddr,
  191. int, shmflg)
  192. SHIM_SYSCALL_PASSTHROUGH (shmctl, 3, int, int, shmid, int, cmd,
  193. struct shmid_ds *, buf)
  194. /* dup: sys/shim_dup.c */
  195. DEFINE_SHIM_SYSCALL (dup, 1, shim_do_dup, int, int, fd)
  196. /* dup2: sys/shim_dup.c */
  197. DEFINE_SHIM_SYSCALL (dup2, 2, shim_do_dup2, int, int, oldfd, int, newfd)
  198. /* pause: sys/shim_sleep.c */
  199. DEFINE_SHIM_SYSCALL (pause, 0, shim_do_pause, int)
  200. /* nanosleep: sys/shim_sleep.c */
  201. DEFINE_SHIM_SYSCALL (nanosleep, 2, shim_do_nanosleep, int,
  202. const struct __kernel_timespec *, rqtp,
  203. struct __kernel_timespec *, rmtp)
  204. /* getitimer: sys/shim_alarm.c */
  205. DEFINE_SHIM_SYSCALL (getitimer, 2, shim_do_getitimer, int, int, which,
  206. struct __kernel_itimerval *, value)
  207. /* alarm: sys/shim_alarm.c */
  208. DEFINE_SHIM_SYSCALL (alarm, 1, shim_do_alarm, int, unsigned int, seconds)
  209. /* setitimer: sys/shim_alarm.c */
  210. DEFINE_SHIM_SYSCALL (setitimer, 3, shim_do_setitimer, int, int, which,
  211. struct __kernel_itimerval *, value,
  212. struct __kernel_itimerval *, ovalue)
  213. /* getpid: sys/shim_getpid.c */
  214. DEFINE_SHIM_SYSCALL (getpid, 0, shim_do_getpid, pid_t)
  215. /* sendfile: sys/shim_fs.c */
  216. DEFINE_SHIM_SYSCALL (sendfile, 4, shim_do_sendfile, ssize_t, int, out_fd, int,
  217. in_fd, off_t *, offset, size_t, count)
  218. /* socket: sys/shim_socket.c */
  219. DEFINE_SHIM_SYSCALL (socket, 3, shim_do_socket, int, int, family, int, type,
  220. int, protocol)
  221. /* connect: sys/shim_socket.c */
  222. DEFINE_SHIM_SYSCALL (connect, 3, shim_do_connect, int, int, sockfd,
  223. struct sockaddr *, addr, int, addrlen)
  224. /* accept: sys/shim_socket.c */
  225. DEFINE_SHIM_SYSCALL (accept, 3, shim_do_accept, int, int, fd,
  226. struct sockaddr *, addr, socklen_t *, addrlen)
  227. /* sendto: sys/shim_socket.c */
  228. DEFINE_SHIM_SYSCALL (sendto, 6, shim_do_sendto, ssize_t, int, fd, const void *,
  229. buf, size_t, len, int, flags, const struct sockaddr *,
  230. dest_addr, socklen_t, addrlen)
  231. /* recvfrom : sys/shim_socket.c */
  232. DEFINE_SHIM_SYSCALL (recvfrom, 6, shim_do_recvfrom, ssize_t, int, fd, void *,
  233. buf, size_t, len, int, flags, struct sockaddr *, addr,
  234. socklen_t *, addrlen)
  235. /* bind: sys/shim_socket.c */
  236. DEFINE_SHIM_SYSCALL (bind, 3, shim_do_bind, int, int, sockfd,
  237. struct sockaddr *, addr, socklen_t, addrlen)
  238. /* listen: sys/shim_socket.c */
  239. DEFINE_SHIM_SYSCALL (listen, 2, shim_do_listen, int, int, sockfd, int, backlog)
  240. /* sendmsg: sys/shim_socket.c */
  241. DEFINE_SHIM_SYSCALL (sendmsg, 3, shim_do_sendmsg, ssize_t, int, fd,
  242. struct msghdr *, msg, int, flags)
  243. /* recvmsg: sys/shim_socket.c */
  244. DEFINE_SHIM_SYSCALL (recvmsg, 3, shim_do_recvmsg, ssize_t, int, fd,
  245. struct msghdr *, msg, int, flags)
  246. /* shutdown: sys/shim_socket.c */
  247. DEFINE_SHIM_SYSCALL (shutdown, 2, shim_do_shutdown, int, int, sockfd, int, how)
  248. /* getsockname: sys/shim_socket.c */
  249. DEFINE_SHIM_SYSCALL (getsockname, 3, shim_do_getsockname, int, int, sockfd,
  250. struct sockaddr *, addr, int *, addrlen)
  251. /* getpeername: sys/shim_socket.c */
  252. DEFINE_SHIM_SYSCALL (getpeername, 3, shim_do_getpeername, int, int, sockfd,
  253. struct sockaddr *, addr, int *, addrlen)
  254. /* socketpair: sys/shim_pipe.c */
  255. DEFINE_SHIM_SYSCALL (socketpair, 4, shim_do_socketpair, int, int, domain,
  256. int, type, int, protocol, int *, sv)
  257. /* setsockopt: sys/shim_socket.c */
  258. DEFINE_SHIM_SYSCALL (setsockopt, 5, shim_do_setsockopt, int, int, fd,
  259. int, level, int, optname, char *, optval, int, optlen)
  260. /* getsockopt: sys/shim_socket.c */
  261. DEFINE_SHIM_SYSCALL (getsockopt, 5, shim_do_getsockopt, int, int, fd,
  262. int, level, int, optname, char *, optval, int *, optlen)
  263. /* clone: sys/shim_clone.c */
  264. DEFINE_SHIM_SYSCALL (clone, 5, shim_do_clone, int, int, flags,
  265. void *, user_stack_addr, int *, parent_tidptr,
  266. int *, child_tidptr, void *, tls)
  267. /* fork: sys/shim_fork.c */
  268. DEFINE_SHIM_SYSCALL (fork, 0, shim_do_fork, int)
  269. /* vfork: sys/shim_vfork.c */
  270. DEFINE_SHIM_SYSCALL (vfork, 0, shim_do_vfork, int)
  271. /* execve: sys/shim_exec.c */
  272. DEFINE_SHIM_SYSCALL (execve, 3, shim_do_execve, int, const char *, file,
  273. const char **, argv, const char **, envp)
  274. /* exit: sys/shim_exit.c */
  275. DEFINE_SHIM_SYSCALL (exit, 1, shim_do_exit, int, int, error_code)
  276. /* wait4: sys/shim_wait.c */
  277. DEFINE_SHIM_SYSCALL (wait4, 4, shim_do_wait4, pid_t, pid_t, pid, int *,
  278. stat_addr, int, option, struct __kernel_rusage *, ru)
  279. /* kill: sys/shim_sigaction.c */
  280. DEFINE_SHIM_SYSCALL (kill, 2, shim_do_kill, int, pid_t, pid, int, sig)
  281. /* uname: sys/shim_uname.c */
  282. DEFINE_SHIM_SYSCALL (uname, 1, shim_do_uname, int, struct old_utsname *, buf)
  283. /* semget: sys/shim_semget.c */
  284. DEFINE_SHIM_SYSCALL (semget, 3, shim_do_semget, int, key_t, key, int, nsems,
  285. int, semflg)
  286. /* semop: sys/shim_semget.c */
  287. DEFINE_SHIM_SYSCALL (semop, 3, shim_do_semop, int, int, semid,
  288. struct sembuf *, sops, unsigned int, nsops)
  289. /* semctl: sys/shim_semctl.c */
  290. DEFINE_SHIM_SYSCALL (semctl, 4, shim_do_semctl, int, int, semid, int, semnum,
  291. int, cmd, unsigned long, arg)
  292. SHIM_SYSCALL_PASSTHROUGH (shmdt, 1, int, const void *, shmaddr)
  293. /* msgget: sys/shim_msgget.c */
  294. DEFINE_SHIM_SYSCALL (msgget, 2, shim_do_msgget, int, key_t, key, int, msgflg)
  295. /* msgsnd: sys/shim_msgget.c */
  296. DEFINE_SHIM_SYSCALL (msgsnd, 4, shim_do_msgsnd, int, int, msqid, const void *,
  297. msgp, size_t, msgsz, int, msgflg)
  298. /* msgrcv: sys/shim_msgget.c */
  299. DEFINE_SHIM_SYSCALL (msgrcv, 5, shim_do_msgrcv, int, int, msqid, void *, msgp,
  300. size_t, msgsz, long, msgtyp, int, msgflg)
  301. /* msgctl: sys/shim_msgget.c */
  302. DEFINE_SHIM_SYSCALL (msgctl, 3, shim_do_msgctl, int, int, msqid, int, cmd,
  303. struct msqid_ds *, buf)
  304. /* fcntl: sys/shim_fcntl.c */
  305. DEFINE_SHIM_SYSCALL (fcntl, 3, shim_do_fcntl, int, int, fd, int, cmd,
  306. unsigned long, arg)
  307. SHIM_SYSCALL_PASSTHROUGH (flock, 2, int, int, fd, int, cmd)
  308. /* fsync: sys/shim_open.c */
  309. DEFINE_SHIM_SYSCALL (fsync, 1, shim_do_fsync, int, int, fd)
  310. /* fdatasync: sys/shim_open.c */
  311. DEFINE_SHIM_SYSCALL (fdatasync, 1, shim_do_fdatasync, int, int, fd)
  312. /* truncate: sys/shim_open.c */
  313. DEFINE_SHIM_SYSCALL (truncate, 2, shim_do_truncate, int, const char *, path,
  314. loff_t, length)
  315. /* ftruncate: sys/shim_open.c */
  316. DEFINE_SHIM_SYSCALL (ftruncate, 2, shim_do_ftruncate, int, int, fd,
  317. loff_t, length)
  318. /* getdents: sys/shim_open.c */
  319. DEFINE_SHIM_SYSCALL (getdents, 3, shim_do_getdents, size_t, int, fd,
  320. struct linux_dirent *, buf, size_t, count)
  321. /* getcwd: sys/shim_getcwd.c */
  322. DEFINE_SHIM_SYSCALL (getcwd, 2, shim_do_getcwd, int, char *, buf, size_t,
  323. size)
  324. /* chdir: sys/shim_getcwd.c */
  325. DEFINE_SHIM_SYSCALL (chdir, 1, shim_do_chdir, int, const char *, filename)
  326. /* fchdir: sys/shim_getcwd.c */
  327. DEFINE_SHIM_SYSCALL (fchdir, 1, shim_do_fchdir, int, int, fd)
  328. /* rename: sys/shim_fs.c */
  329. DEFINE_SHIM_SYSCALL (rename, 2, shim_do_rename, int, const char *, oldname,
  330. const char *, newname)
  331. /* mkdir: sys/shim_fs.c */
  332. DEFINE_SHIM_SYSCALL (mkdir, 2, shim_do_mkdir, int, const char *, pathname,
  333. int, mode)
  334. /* rmdir: sys/shim_fs.c */
  335. DEFINE_SHIM_SYSCALL (rmdir, 1, shim_do_rmdir, int, const char *, pathname)
  336. DEFINE_SHIM_SYSCALL (creat, 2, shim_do_creat, int, const char *, path,
  337. mode_t, mode)
  338. SHIM_SYSCALL_PASSTHROUGH (link, 2, int, const char *, oldname, const char *,
  339. newname)
  340. /* unlink: sys/shim_fs.c */
  341. DEFINE_SHIM_SYSCALL (unlink, 1, shim_do_unlink, int, const char *, file)
  342. SHIM_SYSCALL_PASSTHROUGH (symlink, 2, int, const char *, old, const char *, new)
  343. /* readlink: sys/shim_stat.c */
  344. DEFINE_SHIM_SYSCALL (readlink, 3, shim_do_readlink, int, const char *, path,
  345. char *, buf, int, bufsize)
  346. DEFINE_SHIM_SYSCALL (chmod, 2, shim_do_chmod, int, const char *, filename,
  347. mode_t, mode)
  348. DEFINE_SHIM_SYSCALL (fchmod, 2, shim_do_fchmod, int, int, fd, mode_t, mode)
  349. DEFINE_SHIM_SYSCALL (chown, 3, shim_do_chown, int, const char *, filename,
  350. uid_t, user, gid_t, group)
  351. DEFINE_SHIM_SYSCALL (fchown, 3, shim_do_fchown, int, int, fd, uid_t, user, gid_t, group)
  352. SHIM_SYSCALL_PASSTHROUGH (lchown, 3, int, const char *, filename,
  353. uid_t, user, gid_t, group)
  354. DEFINE_SHIM_SYSCALL (umask, 1, shim_do_umask, mode_t, mode_t, mask)
  355. DEFINE_SHIM_SYSCALL (gettimeofday, 2, shim_do_gettimeofday, int,
  356. struct __kernel_timeval *, tv,
  357. struct __kernel_timezone *, tz)
  358. /* getrlimit: sys/shim_getrlimit.c */
  359. DEFINE_SHIM_SYSCALL (getrlimit, 2, shim_do_getrlimit, int, int, resource,
  360. struct __kernel_rlimit *, rlim)
  361. int shim_do_getrusage (int who, struct __kernel_rusage * ru)
  362. {
  363. memset(ru, 0, sizeof(struct __kernel_rusage));
  364. return -ENOSYS;
  365. }
  366. DEFINE_SHIM_SYSCALL (getrusage, 2, shim_do_getrusage, int, int, who,
  367. struct __kernel_rusage *, ru)
  368. SHIM_SYSCALL_PASSTHROUGH (sysinfo, 1, int, struct sysinfo *, info)
  369. SHIM_SYSCALL_PASSTHROUGH (times, 1, int, struct tms *, tbuf)
  370. SHIM_SYSCALL_PASSTHROUGH (ptrace, 4, int, long, request, pid_t, pid, void *,
  371. addr, void *, data)
  372. /* getuid: sys/shim_getpid.c */
  373. DEFINE_SHIM_SYSCALL (getuid, 0, shim_do_getuid, uid_t)
  374. SHIM_SYSCALL_PASSTHROUGH (syslog, 3, int, int, type, char *, buf, int, len)
  375. /* getgid: sys/shim_getgid.c */
  376. DEFINE_SHIM_SYSCALL (getgid, 0, shim_do_getgid, gid_t)
  377. /* setuid: sys/shim_getpid.c */
  378. DEFINE_SHIM_SYSCALL (setuid, 1, shim_do_setuid, int, uid_t, uid)
  379. /* setgid: sys/shim_getpid.c */
  380. DEFINE_SHIM_SYSCALL (setgid, 1, shim_do_setgid, int, gid_t, gid)
  381. /* geteuid: sys/shim_getpid.c */
  382. DEFINE_SHIM_SYSCALL (geteuid, 0, shim_do_geteuid, uid_t)
  383. /* getegid: sys/shim_getpid.c */
  384. DEFINE_SHIM_SYSCALL (getegid, 0, shim_do_getegid, gid_t)
  385. /* getpgid: sys/shim_getpid.c */
  386. DEFINE_SHIM_SYSCALL (setpgid, 2, shim_do_setpgid, int, pid_t, pid, pid_t, pgid)
  387. /* getppid: sys/shim_getpid.c */
  388. DEFINE_SHIM_SYSCALL (getppid, 0, shim_do_getppid, pid_t)
  389. /* getpgrp: sys/shim_getpid.c */
  390. DEFINE_SHIM_SYSCALL (getpgrp, 0, shim_do_getpgrp, pid_t)
  391. /* setsid: sys/shim_getpid.c */
  392. DEFINE_SHIM_SYSCALL (setsid, 0, shim_do_setsid, int)
  393. SHIM_SYSCALL_PASSTHROUGH (setreuid, 2, int, uid_t, ruid, uid_t, euid)
  394. SHIM_SYSCALL_PASSTHROUGH (setregid, 2, int, gid_t, rgid, gid_t, egid)
  395. SHIM_SYSCALL_PASSTHROUGH (getgroups, 2, int, int, gidsetsize, gid_t *,
  396. grouplist)
  397. SHIM_SYSCALL_PASSTHROUGH (setgroups, 2, int, int, gidsetsize, gid_t *,
  398. grouplist)
  399. SHIM_SYSCALL_PASSTHROUGH (setresuid, 3, int, uid_t, ruid, uid_t, euid, uid_t,
  400. suid)
  401. SHIM_SYSCALL_PASSTHROUGH (getresuid, 3, int, uid_t *, ruid, uid_t *, euid,
  402. uid_t *, suid)
  403. SHIM_SYSCALL_PASSTHROUGH (setresgid, 3, int, gid_t, rgid, gid_t, egid, gid_t,
  404. sgid)
  405. SHIM_SYSCALL_PASSTHROUGH (getresgid, 3, int, gid_t *, rgid, gid_t *, egid,
  406. gid_t *, sgid)
  407. DEFINE_SHIM_SYSCALL (getpgid, 1, shim_do_getpgid, int, pid_t, pid)
  408. SHIM_SYSCALL_PASSTHROUGH (setfsuid, 1, int, uid_t, uid)
  409. SHIM_SYSCALL_PASSTHROUGH (setfsgid, 1, int, gid_t, gid)
  410. DEFINE_SHIM_SYSCALL (getsid, 1, shim_do_getsid, int, pid_t, pid)
  411. SHIM_SYSCALL_PASSTHROUGH (capget, 2, int, cap_user_header_t, header,
  412. cap_user_data_t, dataptr)
  413. SHIM_SYSCALL_PASSTHROUGH (capset, 2, int, cap_user_header_t, header,
  414. const cap_user_data_t, data)
  415. SHIM_SYSCALL_PASSTHROUGH (rt_sigpending, 2, int, __sigset_t *, set, size_t,
  416. sigsetsize)
  417. SHIM_SYSCALL_PASSTHROUGH (rt_sigtimedwait, 4, int, const __sigset_t *, uthese,
  418. siginfo_t *, uinfo, const struct timespec *, uts,
  419. size_t, sigsetsize)
  420. SHIM_SYSCALL_PASSTHROUGH (rt_sigqueueinfo, 3, int, int, pid, int, sig,
  421. siginfo_t *, uinfo)
  422. DEFINE_SHIM_SYSCALL (rt_sigsuspend, 1, shim_do_sigsuspend, int, const __sigset_t *, mask)
  423. DEFINE_SHIM_SYSCALL (sigaltstack, 2, shim_do_sigaltstack, int, const stack_t *, ss,
  424. stack_t *, oss)
  425. SHIM_SYSCALL_PASSTHROUGH (utime, 2, int, char *, filename, struct utimbuf *,
  426. times)
  427. SHIM_SYSCALL_PASSTHROUGH (mknod, 3, int, const char *, filename, int, mode,
  428. unsigned, dev)
  429. SHIM_SYSCALL_PASSTHROUGH (uselib, 1, int, const char *, library)
  430. SHIM_SYSCALL_PASSTHROUGH (personality, 1, int, unsigned int, personality)
  431. SHIM_SYSCALL_PASSTHROUGH (ustat, 2, int, unsigned, dev,
  432. struct __kernel_ustat *, ubuf)
  433. SHIM_SYSCALL_PASSTHROUGH (statfs, 2, int, const char *, path, struct statfs *,
  434. buf)
  435. SHIM_SYSCALL_PASSTHROUGH (fstatfs, 2, int, int, fd, struct statfs *,
  436. buf)
  437. SHIM_SYSCALL_PASSTHROUGH (sysfs, 3, int, int, option, unsigned long, arg1,
  438. unsigned long, arg2)
  439. SHIM_SYSCALL_PASSTHROUGH (getpriority, 2, int, int, which, int, who)
  440. SHIM_SYSCALL_PASSTHROUGH (setpriority, 3, int, int, which, int, who, int,
  441. niceval)
  442. SHIM_SYSCALL_PASSTHROUGH (sched_setparam, 2, int, pid_t, pid,
  443. struct __kernel_sched_param *, param)
  444. SHIM_SYSCALL_PASSTHROUGH (sched_getparam, 2, int, pid_t, pid,
  445. struct __kernel_sched_param *, param)
  446. SHIM_SYSCALL_PASSTHROUGH (sched_setscheduler, 3, int, pid_t, pid, int, policy,
  447. struct __kernel_sched_param *, param)
  448. SHIM_SYSCALL_PASSTHROUGH (sched_getscheduler, 1, int, pid_t, pid)
  449. SHIM_SYSCALL_PASSTHROUGH (sched_get_priority_max, 1, int, int, policy)
  450. SHIM_SYSCALL_PASSTHROUGH (sched_get_priority_min, 1, int, int, policy)
  451. SHIM_SYSCALL_PASSTHROUGH (sched_rr_get_interval, 2, int, pid_t, pid,
  452. struct timespec *, interval)
  453. SHIM_SYSCALL_PASSTHROUGH (mlock, 2, int, void *, start, size_t, len)
  454. SHIM_SYSCALL_PASSTHROUGH (munlock, 2, int, void *, start, size_t, len)
  455. SHIM_SYSCALL_PASSTHROUGH (mlockall, 1, int, int, flags)
  456. SHIM_SYSCALL_PASSTHROUGH (munlockall, 0, int)
  457. SHIM_SYSCALL_PASSTHROUGH (vhangup, 0, int)
  458. SHIM_SYSCALL_PASSTHROUGH (modify_ldt, 3, int, int, func, void *, ptr,
  459. unsigned long, bytecount)
  460. SHIM_SYSCALL_PASSTHROUGH (pivot_root, 2, int, const char *, new_root,
  461. const char *, put_old)
  462. SHIM_SYSCALL_PASSTHROUGH (_sysctl, 1, int, struct __kernel_sysctl_args *, args)
  463. SHIM_SYSCALL_PASSTHROUGH (prctl, 5, int, int, option, unsigned long, arg2,
  464. unsigned long, arg3, unsigned long, arg4,
  465. unsigned long, arg5)
  466. DEFINE_SHIM_SYSCALL (arch_prctl, 2, shim_do_arch_prctl, void *, int, code,
  467. void *, addr)
  468. void * shim_do_arch_prctl (int code, void * addr)
  469. {
  470. /* We only support set fs. Die loudly if we see anything else. */
  471. assert(code == ARCH_SET_FS || code == ARCH_GET_FS);
  472. switch (code) {
  473. case ARCH_SET_FS:
  474. if (!addr)
  475. return (void *) -EINVAL;
  476. populate_tls(addr, true);
  477. debug("set tcb to %p\n", (void *) addr);
  478. return NULL;
  479. case ARCH_GET_FS:
  480. return (void *) DkSegmentRegister(PAL_SEGMENT_FS, NULL) ? :
  481. (void *) -PAL_ERRNO;
  482. }
  483. return (void *) -ENOSYS;
  484. }
  485. SHIM_SYSCALL_PASSTHROUGH (adjtimex, 1, int, struct __kernel_timex *, txc_p)
  486. /* setrlimit: sys/shim_getrlimit.c */
  487. DEFINE_SHIM_SYSCALL (setrlimit, 2, shim_do_setrlimit, int, int, resource,
  488. struct __kernel_rlimit *, rlim)
  489. /* chroot: sys/shim_isolate.c */
  490. DEFINE_SHIM_SYSCALL (chroot, 1, shim_do_chroot, int, const char *, filename)
  491. SHIM_SYSCALL_PASSTHROUGH (sync, 0, int)
  492. SHIM_SYSCALL_PASSTHROUGH (acct, 1, int, const char *, name)
  493. SHIM_SYSCALL_PASSTHROUGH (settimeofday, 2, int, struct timeval *, tv,
  494. struct __kernel_timezone *, tz)
  495. SHIM_SYSCALL_PASSTHROUGH (mount, 5, int, char *, dev_name, char *, dir_name,
  496. char *, type, unsigned long, flags, void *, data)
  497. SHIM_SYSCALL_PASSTHROUGH (umount2, 2, int, const char *, target, int, flags)
  498. SHIM_SYSCALL_PASSTHROUGH (swapon, 2, int, const char *, specialfile, int,
  499. swap_flags)
  500. SHIM_SYSCALL_PASSTHROUGH (swapoff, 1, int, const char *, specialfile)
  501. SHIM_SYSCALL_PASSTHROUGH (reboot, 4, int, int, magic1, int, magic2,
  502. int, cmd, void *, arg)
  503. SHIM_SYSCALL_PASSTHROUGH (sethostname, 2, int, char *, name, int, len)
  504. SHIM_SYSCALL_PASSTHROUGH (setdomainname, 2, int, char *, name, int, len)
  505. SHIM_SYSCALL_PASSTHROUGH (iopl, 1, int, int, level)
  506. SHIM_SYSCALL_PASSTHROUGH (ioperm, 3, int, unsigned long, from, unsigned long,
  507. num, int, on)
  508. SHIM_SYSCALL_PASSTHROUGH (create_module, 2, int, const char *, name, size_t,
  509. size)
  510. SHIM_SYSCALL_PASSTHROUGH (init_module, 3, int, void *, umod, unsigned long, len,
  511. const char *, uargs)
  512. SHIM_SYSCALL_PASSTHROUGH (delete_module, 2, int, const char *, name_user,
  513. unsigned int, flags)
  514. /*
  515. SHIM_SYSCALL_PASSTHROUGH (get_kernel_syms, 1, int, struct kernel_sym *, table)
  516. */
  517. SHIM_SYSCALL_PASSTHROUGH (query_module, 5, int, const char *, name, int, which,
  518. void *, buf, size_t, bufsize, size_t *, retsize)
  519. SHIM_SYSCALL_PASSTHROUGH (quotactl, 4, int, int, cmd, const char *,
  520. special, qid_t, id, void *, addr)
  521. /*
  522. SHIM_SYSCALL_PASSTHROUGH (nfsservctl, 3, int, int, cmd, struct nfsctl_arg *,
  523. arg, void *, res)
  524. */
  525. /* shim_getpmsg MISSING
  526. TODO: getpmsg syscall is not implemented (kernel always returns -ENOSYS),
  527. how should we handle this?*/
  528. /* shim_putpmsg MISSING
  529. TODO: putpmsg syscall is not implemented (kernel always returns -ENOSYS),
  530. how should we handle this?*/
  531. /* shim_afs_syscall MISSING
  532. TODO: afs_syscall is not implemented (kernel always returns -ENOSYS),
  533. how should we handle this?*/
  534. /* shim_tuxcall MISSING
  535. TODO: tuxcall syscall is not implemented (kernel always returns -ENOSYS),
  536. how should we handle this?*/
  537. /* shim_security MISSING
  538. TODO: security syscall is not implemented (kernel always returns -ENOSYS),
  539. how should we handle this?*/
  540. /* gettid: sys/shim_getpid.c */
  541. DEFINE_SHIM_SYSCALL (gettid, 0, shim_do_gettid, pid_t)
  542. SHIM_SYSCALL_PASSTHROUGH (readahead, 3, int, int, fd, loff_t, offset, size_t,
  543. count)
  544. SHIM_SYSCALL_PASSTHROUGH (setxattr, 5, int, const char *, path, const char *,
  545. name, const void *, value, size_t, size, int, flags)
  546. SHIM_SYSCALL_PASSTHROUGH (lsetxattr, 5, int, const char *, path, const char *,
  547. name, const void *, value, size_t, size, int, flags)
  548. SHIM_SYSCALL_PASSTHROUGH (fsetxattr, 5, int, int, fd, const char *, name,
  549. const void *, value, size_t, size, int, flags)
  550. SHIM_SYSCALL_PASSTHROUGH (getxattr, 4, int, const char *, path, const char *,
  551. name, void *, value, size_t, size)
  552. SHIM_SYSCALL_PASSTHROUGH (lgetxattr, 4, int, const char *, path, const char *,
  553. name, void *, value, size_t, size)
  554. SHIM_SYSCALL_PASSTHROUGH (fgetxattr, 4, int, int, fd, const char *, name,
  555. void *, value, size_t, size)
  556. SHIM_SYSCALL_PASSTHROUGH (listxattr, 3, int, const char *, path, char *, list,
  557. size_t, size)
  558. SHIM_SYSCALL_PASSTHROUGH (llistxattr, 3, int, const char *, path, char *, list,
  559. size_t, size)
  560. SHIM_SYSCALL_PASSTHROUGH (flistxattr, 3, int, int, fd, char *, list, size_t,
  561. size)
  562. SHIM_SYSCALL_PASSTHROUGH (removexattr, 2, int, const char *, path, const char *,
  563. name)
  564. SHIM_SYSCALL_PASSTHROUGH (lremovexattr, 2, int, const char *, path,
  565. const char *, name)
  566. SHIM_SYSCALL_PASSTHROUGH (fremovexattr, 2, int, int, fd, const char *, name)
  567. DEFINE_SHIM_SYSCALL (tkill, 2, shim_do_tkill, int, pid_t, pid, int, sig)
  568. DEFINE_SHIM_SYSCALL (time, 1, shim_do_time, time_t, time_t *, tloc)
  569. /* futex: sys/shim_futex.c */
  570. DEFINE_SHIM_SYSCALL (futex, 6, shim_do_futex, int, unsigned int *, uaddr,
  571. int, op, int, val, void *, utime, unsigned int *, uaddr2,
  572. int, val3)
  573. SHIM_SYSCALL_PASSTHROUGH (sched_setaffinity, 3, int, pid_t, pid, size_t, len,
  574. __kernel_cpu_set_t *, user_mask_ptr)
  575. SHIM_SYSCALL_PASSTHROUGH (sched_getaffinity, 3, int, pid_t, pid, size_t, len,
  576. __kernel_cpu_set_t *, user_mask_ptr)
  577. SHIM_SYSCALL_PASSTHROUGH (set_thread_area, 1, int, struct user_desc *, u_info)
  578. /* no glibc wrapper */
  579. SHIM_SYSCALL_PASSTHROUGH (io_setup, 2, int, unsigned, nr_reqs, aio_context_t *,
  580. ctx)
  581. SHIM_SYSCALL_PASSTHROUGH (io_destroy, 1, int, aio_context_t, ctx)
  582. SHIM_SYSCALL_PASSTHROUGH (io_getevents, 5, int, aio_context_t, ctx_id, long,
  583. min_nr, long, nr, struct io_event *, events,
  584. struct timespec *, timeout)
  585. SHIM_SYSCALL_PASSTHROUGH (io_submit, 3, int, aio_context_t, ctx_id, long, nr,
  586. struct iocb **, iocbpp)
  587. SHIM_SYSCALL_PASSTHROUGH (io_cancel, 3, int, aio_context_t, ctx_id,
  588. struct iocb *, iocb, struct io_event *, result)
  589. SHIM_SYSCALL_PASSTHROUGH (get_thread_area, 1, int, struct user_desc *, u_info)
  590. SHIM_SYSCALL_PASSTHROUGH (lookup_dcookie, 3, int, unsigned long, cookie64,
  591. char *, buf, size_t, len)
  592. DEFINE_SHIM_SYSCALL (epoll_create, 1, shim_do_epoll_create , int, int, size)
  593. /* shim_epoll_ctl_old MISSING
  594. TODO: epoll_ctl_old syscall is not implemented (kernel always returns -ENOSYS),
  595. how should we handle this?*/
  596. /* shim_epoll_wait_old MISSING
  597. TODO: epoll_wait_old syscall is not implemented (kernel always returns -ENOSYS),
  598. how should we handle this?*/
  599. SHIM_SYSCALL_PASSTHROUGH (remap_file_pages, 5, int, void *, start, size_t, size,
  600. int, prot, ssize_t, pgoff, int, flags)
  601. /* getdents64: sys/shim_open.c */
  602. DEFINE_SHIM_SYSCALL (getdents64, 3, shim_do_getdents64, size_t, int, fd,
  603. struct linux_dirent64 *, buf, size_t, count)
  604. /* set_tid_address: sys/shim_getpid.c */
  605. DEFINE_SHIM_SYSCALL (set_tid_address, 1, shim_do_set_tid_address, int, int *,
  606. tidptr)
  607. SHIM_SYSCALL_PASSTHROUGH (restart_syscall, 0, int)
  608. /* semtimedop: sys/shim_semget.c */
  609. DEFINE_SHIM_SYSCALL (semtimedop, 4, shim_do_semtimedop, int, int, semid,
  610. struct sembuf *, sops, unsigned int, nsops,
  611. const struct timespec *, timeout)
  612. SHIM_SYSCALL_PASSTHROUGH (fadvise64, 4, int, int, fd, loff_t, offset, size_t,
  613. len, int, advice)
  614. SHIM_SYSCALL_PASSTHROUGH (timer_create, 3, int, clockid_t, which_clock,
  615. struct sigevent *, timer_event_spec, timer_t *,
  616. created_timer_id)
  617. SHIM_SYSCALL_PASSTHROUGH (timer_settime, 4, int, timer_t, timer_id, int, flags,
  618. const struct __kernel_itimerspec *, new_setting,
  619. struct __kernel_itimerspec *, old_setting)
  620. SHIM_SYSCALL_PASSTHROUGH (timer_gettime, 2, int, timer_t, timer_id,
  621. struct __kernel_itimerspec *, setting)
  622. SHIM_SYSCALL_PASSTHROUGH (timer_getoverrun, 1, int, timer_t, timer_id)
  623. SHIM_SYSCALL_PASSTHROUGH (timer_delete, 1, int, timer_t, timer_id)
  624. SHIM_SYSCALL_PASSTHROUGH (clock_settime, 2, int, clockid_t, which_clock,
  625. const struct timespec *, tp)
  626. /* clock_gettime: sys/shim_time.c */
  627. DEFINE_SHIM_SYSCALL (clock_gettime, 2, shim_do_clock_gettime, int,
  628. clockid_t, which_clock, struct timespec *, tp)
  629. DEFINE_SHIM_SYSCALL (clock_getres, 2, shim_do_clock_getres, int,
  630. clockid_t, which_clock, struct timespec *, tp)
  631. SHIM_SYSCALL_PASSTHROUGH (clock_nanosleep, 4, int, clockid_t, which_clock,
  632. int, flags, const struct timespec *, rqtp,
  633. struct timespec *, rmtp)
  634. /* exit_group: sys/shim_exit.c */
  635. DEFINE_SHIM_SYSCALL (exit_group, 1, shim_do_exit_group, int, int, error_code)
  636. DEFINE_SHIM_SYSCALL (epoll_wait, 4, shim_do_epoll_wait, int, int, epfd,
  637. struct __kernel_epoll_event *, events,
  638. int, maxevents, int, timeout)
  639. DEFINE_SHIM_SYSCALL (epoll_ctl, 4, shim_do_epoll_ctl, int, int, epfd, int, op, int, fd,
  640. struct __kernel_epoll_event *, event)
  641. DEFINE_SHIM_SYSCALL (tgkill, 3, shim_do_tgkill, int, pid_t, tgid, pid_t, pid,
  642. int, sig)
  643. SHIM_SYSCALL_PASSTHROUGH (utimes, 2, int, char *, filename, struct timeval *,
  644. utimes)
  645. /* shim_vserver MISSING
  646. TODO: vserver syscall is not implemented (kernel always returns -ENOSYS),
  647. how should we handle this?*/
  648. SHIM_SYSCALL_PASSTHROUGH (mbind, 6, int, void *, start, unsigned long, len,
  649. int, mode, unsigned long *, nmask,
  650. unsigned long, maxnode, int, flags)
  651. SHIM_SYSCALL_PASSTHROUGH (set_mempolicy, 3, int, int, mode, unsigned long *,
  652. nmask, unsigned long, maxnode)
  653. SHIM_SYSCALL_PASSTHROUGH (get_mempolicy, 5, int, int *, policy, unsigned long *,
  654. nmask, unsigned long, maxnode, unsigned long, addr,
  655. unsigned long, flags)
  656. SHIM_SYSCALL_PASSTHROUGH (mq_open, 4, int, const char *, name, int, oflag,
  657. mode_t, mode, struct __kernel_mq_attr *, attr)
  658. SHIM_SYSCALL_PASSTHROUGH (mq_unlink, 1, int, const char *, name)
  659. SHIM_SYSCALL_PASSTHROUGH (mq_timedsend, 5, int, __kernel_mqd_t, mqdes,
  660. const char *, msg_ptr, size_t, msg_len, unsigned int,
  661. msg_prio, const struct timespec *, abs_timeout)
  662. SHIM_SYSCALL_PASSTHROUGH (mq_timedreceive, 5, int, __kernel_mqd_t, mqdes,
  663. char *, msg_ptr, size_t, msg_len, unsigned int *,
  664. msg_prio, const struct timespec *, abs_timeout)
  665. SHIM_SYSCALL_PASSTHROUGH (mq_notify, 2, int, __kernel_mqd_t, mqdes,
  666. const struct sigevent *, notification)
  667. SHIM_SYSCALL_PASSTHROUGH (mq_getsetattr, 3, int, __kernel_mqd_t, mqdes,
  668. const struct __kernel_mq_attr *, mqstat,
  669. struct __kernel_mq_attr *, omqstat)
  670. /*
  671. SHIM_SYSCALL_PASSTHROUGH (kexec_load, 4, int, unsigned long, entry,
  672. unsigned long, nr_segments, struct kexec_segment *,
  673. segments, unsigned long, flags)
  674. */
  675. SHIM_SYSCALL_PASSTHROUGH (waitid, 5, int, int, which, pid_t, pid,
  676. siginfo_t *, infop, int, options,
  677. struct __kernel_rusage *, ru)
  678. /*
  679. SHIM_SYSCALL_PASSTHROUGH (add_key, 5, int, const char *, type, const char *,
  680. description, const void *, payload, size_t, plen,
  681. key_serial_t, destringid)
  682. */
  683. /*
  684. SHIM_SYSCALL_PASSTHROUGH (request_key, 4, int, const char *, type,
  685. const char *, description, const char *, callout_info,
  686. key_serial_t, destringid)
  687. */
  688. /*
  689. SHIM_SYSCALL_PASSTHROUGH (keyctl, 5, int, int, cmd, unsigned long, arg2,
  690. unsigned long, arg3, unsigned long, arg4,
  691. unsigned long, arg5)
  692. */
  693. SHIM_SYSCALL_PASSTHROUGH (ioprio_set, 3, int, int, which, int, who, int, ioprio)
  694. SHIM_SYSCALL_PASSTHROUGH (ioprio_get, 2, int, int, which, int, who)
  695. SHIM_SYSCALL_PASSTHROUGH (inotify_init, 0, int)
  696. SHIM_SYSCALL_PASSTHROUGH (inotify_add_watch, 3, int, int, fd, const char *,
  697. path, unsigned int, mask)
  698. SHIM_SYSCALL_PASSTHROUGH (inotify_rm_watch, 2, int, int, fd, unsigned int, wd)
  699. SHIM_SYSCALL_PASSTHROUGH (migrate_pages, 4, int, pid_t, pid, unsigned long,
  700. maxnode, const unsigned long *, from,
  701. const unsigned long *, to)
  702. /* openat: sys/shim_open.c */
  703. DEFINE_SHIM_SYSCALL (openat, 4, shim_do_openat, int, int, dfd,
  704. const char *, filename, int, flags, int, mode)
  705. /* mkdirat: sys/shim_fs.c */
  706. DEFINE_SHIM_SYSCALL (mkdirat, 3, shim_do_mkdirat, int, int, dfd,
  707. const char *, pathname, int, mode)
  708. SHIM_SYSCALL_PASSTHROUGH (mknodat, 4, int, int, dfd, const char *, filename,
  709. int, mode, unsigned, dev)
  710. DEFINE_SHIM_SYSCALL (fchownat, 5, shim_do_fchownat, int, int, dfd,
  711. const char *, filename, uid_t, user, gid_t, group, int, flag)
  712. SHIM_SYSCALL_PASSTHROUGH (futimesat, 3, int, int, dfd, const char *, filename,
  713. struct timeval *, utimes)
  714. SHIM_SYSCALL_PASSTHROUGH (newfstatat, 4, int, int, dfd, const char *, filename,
  715. struct stat *, statbuf, int, flag)
  716. /* unlinkat: sys/shim_fs.c */
  717. DEFINE_SHIM_SYSCALL (unlinkat, 3, shim_do_unlinkat, int, int, dfd,
  718. const char *, pathname, int, flag)
  719. /* renameat: sys/shim_fs.c */
  720. DEFINE_SHIM_SYSCALL (renameat, 4, shim_do_renameat, int, int, olddfd,
  721. const char *, oldname, int, newdfd, const char *, newname)
  722. SHIM_SYSCALL_PASSTHROUGH (linkat, 5, int, int, olddfd, const char *, oldname,
  723. int, newdfd, const char *, newname, int, flags)
  724. SHIM_SYSCALL_PASSTHROUGH (symlinkat, 3, int, const char *, oldname, int,
  725. newdfd, const char *, newname)
  726. SHIM_SYSCALL_PASSTHROUGH (readlinkat, 4, int, int, dfd, const char *, path,
  727. char *, buf, int, bufsiz)
  728. /* fchmodat: sys/shim_fs.c */
  729. DEFINE_SHIM_SYSCALL (fchmodat, 3, shim_do_fchmodat, int, int, dfd,
  730. const char *, filename, mode_t, mode)
  731. /* faccessat: sys/shim_access.c */
  732. DEFINE_SHIM_SYSCALL (faccessat, 3, shim_do_faccessat, int, int, dfd,
  733. const char *, filename, int, mode)
  734. /* pselect6: sys/shim_poll.c */
  735. DEFINE_SHIM_SYSCALL (pselect6, 6, shim_do_pselect6, int, int, nfds,
  736. fd_set *, readfds, fd_set *, writefds, fd_set *, errorfds,
  737. const struct __kernel_timespec *, tsp,
  738. const __sigset_t *, sigmask)
  739. /* ppoll: sys/shim_poll.c */
  740. DEFINE_SHIM_SYSCALL (ppoll, 5, shim_do_ppoll, int, struct pollfd *, fds,
  741. int, nfds, struct timespec *, tsp,
  742. const __sigset_t *, sigmask, size_t, sigsetsize)
  743. SHIM_SYSCALL_PASSTHROUGH (unshare, 1, int, int, unshare_flags)
  744. /* set_robust_list: sys/shim_futex.c */
  745. DEFINE_SHIM_SYSCALL (set_robust_list, 2, shim_do_set_robust_list, int,
  746. struct robust_list_head *, head, size_t, len)
  747. /* get_roubust_list: sys/shim_futex.c */
  748. DEFINE_SHIM_SYSCALL (get_robust_list, 3, shim_do_get_robust_list, int, pid_t,
  749. pid, struct robust_list_head **, head, size_t *, len)
  750. SHIM_SYSCALL_PASSTHROUGH (splice, 6, int, int, fd_in, loff_t *, off_in, int,
  751. fd_out, loff_t *, off_out, size_t, len, int, flags)
  752. SHIM_SYSCALL_PASSTHROUGH (tee, 4, int, int, fdin, int, fdout, size_t, len,
  753. unsigned int, flags)
  754. SHIM_SYSCALL_PASSTHROUGH (sync_file_range, 4, int, int, fd, loff_t, offset,
  755. loff_t, nbytes, int, flags)
  756. SHIM_SYSCALL_PASSTHROUGH (vmsplice, 4, int, int, fd, const struct iovec *, iov,
  757. unsigned long, nr_segs, int, flags)
  758. SHIM_SYSCALL_PASSTHROUGH (move_pages, 6, int, pid_t, pid, unsigned long,
  759. nr_pages, void **, pages, const int *, nodes,
  760. int *, status, int, flags)
  761. SHIM_SYSCALL_PASSTHROUGH (utimensat, 4, int, int, dfd, const char *, filename,
  762. struct timespec *, utimes, int, flags)
  763. DEFINE_SHIM_SYSCALL (epoll_pwait, 6, shim_do_epoll_pwait, int, int, epfd,
  764. struct __kernel_epoll_event *, events, int, maxevents,
  765. int, timeout, const __sigset_t *, sigmask,
  766. size_t, sigsetsize)
  767. SHIM_SYSCALL_PASSTHROUGH (signalfd, 3, int, int, ufd, __sigset_t *, user_mask,
  768. size_t, sizemask)
  769. SHIM_SYSCALL_PASSTHROUGH (timerfd_create, 2, int, int, clockid, int, flags)
  770. SHIM_SYSCALL_PASSTHROUGH (eventfd, 1, int, int, count)
  771. SHIM_SYSCALL_PASSTHROUGH (fallocate, 4, int, int, fd, int, mode, loff_t, offset,
  772. loff_t, len)
  773. SHIM_SYSCALL_PASSTHROUGH (timerfd_settime, 4, int, int, ufd, int, flags,
  774. const struct __kernel_itimerspec *, utmr,
  775. struct __kernel_itimerspec *, otmr)
  776. SHIM_SYSCALL_PASSTHROUGH (timerfd_gettime, 2, int, int, ufd,
  777. struct __kernel_itimerspec *, otmr)
  778. /* accept4: sys/shim_socket.c */
  779. DEFINE_SHIM_SYSCALL (accept4, 4, shim_do_accept4, int, int, sockfd,
  780. struct sockaddr *, addr, socklen_t *, addrlen, int, flags)
  781. SHIM_SYSCALL_PASSTHROUGH (signalfd4, 4, int, int, ufd, __sigset_t *, user_mask,
  782. size_t, sizemask, int, flags)
  783. SHIM_SYSCALL_PASSTHROUGH (eventfd2, 2, int, int, count, int, flags)
  784. /* epoll_create1: sys/shim_epoll.c */
  785. DEFINE_SHIM_SYSCALL (epoll_create1, 1, shim_do_epoll_create1, int, int, flags)
  786. /* dup3: sys/shim_dup.c */
  787. DEFINE_SHIM_SYSCALL (dup3, 3, shim_do_dup3, int, int, oldfd, int, newfd,
  788. int, flags)
  789. /* pipe2: sys/shim_pipe.c */
  790. DEFINE_SHIM_SYSCALL (pipe2, 2, shim_do_pipe2, int, int *, fildes, int, flags)
  791. SHIM_SYSCALL_PASSTHROUGH (inotify_init1, 1, int, int, flags)
  792. SHIM_SYSCALL_PASSTHROUGH (preadv, 5, int, unsigned long, fd,
  793. const struct iovec *, vec, unsigned long, vlen,
  794. unsigned long, pos_l, unsigned long, pos_h)
  795. SHIM_SYSCALL_PASSTHROUGH (pwritev, 5, int, unsigned long, fd,
  796. const struct iovec *, vec, unsigned long, vlen,
  797. unsigned long, pos_l, unsigned long, pos_h)
  798. SHIM_SYSCALL_PASSTHROUGH (rt_tgsigqueueinfo, 4, int, pid_t, tgid, pid_t, pid,
  799. int, sig, siginfo_t *, uinfo)
  800. SHIM_SYSCALL_PASSTHROUGH (perf_event_open, 5, int, struct perf_event_attr *,
  801. attr_uptr, pid_t, pid, int, cpu, int, group_fd,
  802. int, flags)
  803. DEFINE_SHIM_SYSCALL (recvmmsg, 5, shim_do_recvmmsg, int, int, fd,
  804. struct mmsghdr *, msg, int, vlen, int, flags,
  805. struct __kernel_timespec *, timeout)
  806. SHIM_SYSCALL_PASSTHROUGH (fanotify_init, 2, int, int, flags, int, event_f_flags)
  807. SHIM_SYSCALL_PASSTHROUGH (fanotify_mark, 5, int, int, fanotify_fd, int, flags,
  808. unsigned long, mask, int, fd, const char *, pathname)
  809. SHIM_SYSCALL_PASSTHROUGH (prlimit64, 4, int, pid_t, pid, int, resource,
  810. const struct __kernel_rlimit64 *, new_rlim,
  811. struct __kernel_rlimit64 *, old_rlim)
  812. SHIM_SYSCALL_PASSTHROUGH (name_to_handle_at, 5, int, int, dfd,
  813. const char *, name,
  814. struct linux_file_handle *, handle, int *, mnt_id,
  815. int, flag)
  816. SHIM_SYSCALL_PASSTHROUGH (open_by_handle_at, 3, int, int, mountdirfd,
  817. struct linux_file_handle *, handle, int, flags)
  818. SHIM_SYSCALL_PASSTHROUGH (clock_adjtime, 2, int, clockid_t, which_clock,
  819. struct timex *, tx)
  820. SHIM_SYSCALL_PASSTHROUGH (syncfs, 1, int, int, fd)
  821. DEFINE_SHIM_SYSCALL (sendmmsg, 4, shim_do_sendmmsg, int, int, fd,
  822. struct mmsghdr *, msg, int, vlen, int, flags)
  823. SHIM_SYSCALL_PASSTHROUGH (setns, 2, int, int, fd, int, nstype)
  824. SHIM_SYSCALL_PASSTHROUGH (getcpu, 3, int, unsigned *, cpu, unsigned *, node,
  825. struct getcpu_cache *, cache)
  826. /* libos calls */
  827. DEFINE_SHIM_SYSCALL (sandbox_create, 3, shim_do_sandbox_create, long,
  828. int, flags, const char *, fs_sb, struct net_sb *, net_sb)
  829. DEFINE_SHIM_SYSCALL (sandbox_attach, 1, shim_do_sandbox_attach, int,
  830. unsigned int, sandboxid)
  831. DEFINE_SHIM_SYSCALL (sandbox_current, 0, shim_do_sandbox_current, long)
  832. DEFINE_SHIM_SYSCALL (msgpersist, 2, shim_do_msgpersist, int, int, msqid,
  833. int, cmd)
  834. DEFINE_SHIM_SYSCALL (benchmark_rpc, 4, shim_do_benchmark_rpc, int, pid_t, pid,
  835. int, times, const void *, buf, size_t, size)
  836. DEFINE_SHIM_SYSCALL (send_rpc, 3, shim_do_send_rpc, size_t, pid_t, pid,
  837. const void *, buf, size_t, size)
  838. DEFINE_SHIM_SYSCALL (recv_rpc, 3, shim_do_recv_rpc, size_t, pid_t *, pid,
  839. void *, buf, size_t, size)
  840. DEFINE_SHIM_SYSCALL (checkpoint, 1, shim_do_checkpoint, int,
  841. const char *, filename)