shim_syscalls.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205
  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 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 Lesser 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 Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser 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, 4, shim_do_sigaction, int, int, signum,
  150. const struct __kernel_sigaction *, act,
  151. struct __kernel_sigaction *, oldact, size_t, sigsetsize)
  152. /* rt_sigprocmask: sys/shim_sigaction.c */
  153. DEFINE_SHIM_SYSCALL (rt_sigprocmask, 3, shim_do_sigprocmask, int, int, how,
  154. const __sigset_t *, set, __sigset_t *, oldset)
  155. /* rt_sigreturn: sys/shim_sigaction.c */
  156. DEFINE_SHIM_SYSCALL (rt_sigreturn, 1, shim_do_sigreturn, int, int, __unused)
  157. /* ioctl: sys/shim_ioctl.c */
  158. DEFINE_SHIM_SYSCALL (ioctl, 3, shim_do_ioctl, int, int, fd, int, cmd,
  159. unsigned long, arg)
  160. /* pread64 : sys/shim_open.c */
  161. DEFINE_SHIM_SYSCALL (pread64, 4, shim_do_pread64, size_t, int, fd, char *, buf,
  162. size_t, count, loff_t, pos)
  163. /* pwrite64 : sys/shim_open.c */
  164. DEFINE_SHIM_SYSCALL (pwrite64, 4, shim_do_pwrite64, size_t, int, fd, char *,
  165. buf, size_t, count, loff_t, pos)
  166. /* readv : sys/shim_wrappers.c */
  167. DEFINE_SHIM_SYSCALL (readv, 3, shim_do_readv, ssize_t, int, fd,
  168. const struct iovec *, vec, int, vlen)
  169. /* writev : sys/shim_wrappers.c */
  170. DEFINE_SHIM_SYSCALL (writev, 3, shim_do_writev, ssize_t, int, fd,
  171. const struct iovec *, vec, int, vlen)
  172. /* access: sys/shim_access.c */
  173. DEFINE_SHIM_SYSCALL (access, 2, shim_do_access, int, const char *, file,
  174. mode_t, mode)
  175. /* pipe: sys/shim_pipe.c */
  176. DEFINE_SHIM_SYSCALL (pipe, 1, shim_do_pipe, int, int *, fildes)
  177. /* select : sys/shim_poll.c*/
  178. DEFINE_SHIM_SYSCALL (select, 5, shim_do_select, int, int, nfds, fd_set *,
  179. readfds, fd_set *, writefds, fd_set *, errorfds,
  180. struct __kernel_timeval *, timeout)
  181. /* sched_yield: sys/shim_sched.c */
  182. DEFINE_SHIM_SYSCALL (sched_yield, 0, shim_do_sched_yield, int)
  183. SHIM_SYSCALL_PASSTHROUGH (mremap, 5, void *, void *, addr, size_t, old_len,
  184. size_t, new_len, int, flags, void *, new_addr)
  185. SHIM_SYSCALL_PASSTHROUGH (msync, 3, int, void *, start, size_t, len, int, flags)
  186. SHIM_SYSCALL_PASSTHROUGH (mincore, 3, int, void *, start, size_t, len,
  187. unsigned char *, vec)
  188. SHIM_SYSCALL_PASSTHROUGH (madvise, 3, int, void *, start, size_t, len,
  189. int, behavior)
  190. SHIM_SYSCALL_PASSTHROUGH (shmget, 3, int, key_t, key, size_t, size, int, shmflg)
  191. SHIM_SYSCALL_PASSTHROUGH (shmat, 3, void *, int, shmid, const void *, shmaddr,
  192. int, shmflg)
  193. SHIM_SYSCALL_PASSTHROUGH (shmctl, 3, int, int, shmid, int, cmd,
  194. struct shmid_ds *, buf)
  195. /* dup: sys/shim_dup.c */
  196. DEFINE_SHIM_SYSCALL (dup, 1, shim_do_dup, int, int, fd)
  197. /* dup2: sys/shim_dup.c */
  198. DEFINE_SHIM_SYSCALL (dup2, 2, shim_do_dup2, int, int, oldfd, int, newfd)
  199. /* pause: sys/shim_sleep.c */
  200. DEFINE_SHIM_SYSCALL (pause, 0, shim_do_pause, int)
  201. /* nanosleep: sys/shim_sleep.c */
  202. DEFINE_SHIM_SYSCALL (nanosleep, 2, shim_do_nanosleep, int,
  203. const struct __kernel_timespec *, rqtp,
  204. struct __kernel_timespec *, rmtp)
  205. /* getitimer: sys/shim_alarm.c */
  206. DEFINE_SHIM_SYSCALL (getitimer, 2, shim_do_getitimer, int, int, which,
  207. struct __kernel_itimerval *, value)
  208. /* alarm: sys/shim_alarm.c */
  209. DEFINE_SHIM_SYSCALL (alarm, 1, shim_do_alarm, int, unsigned int, seconds)
  210. /* setitimer: sys/shim_alarm.c */
  211. DEFINE_SHIM_SYSCALL (setitimer, 3, shim_do_setitimer, int, int, which,
  212. struct __kernel_itimerval *, value,
  213. struct __kernel_itimerval *, ovalue)
  214. /* getpid: sys/shim_getpid.c */
  215. DEFINE_SHIM_SYSCALL (getpid, 0, shim_do_getpid, pid_t)
  216. /* sendfile: sys/shim_fs.c */
  217. DEFINE_SHIM_SYSCALL (sendfile, 4, shim_do_sendfile, ssize_t, int, out_fd, int,
  218. in_fd, off_t *, offset, size_t, count)
  219. /* socket: sys/shim_socket.c */
  220. DEFINE_SHIM_SYSCALL (socket, 3, shim_do_socket, int, int, family, int, type,
  221. int, protocol)
  222. /* connect: sys/shim_socket.c */
  223. DEFINE_SHIM_SYSCALL (connect, 3, shim_do_connect, int, int, sockfd,
  224. struct sockaddr *, addr, int, addrlen)
  225. /* accept: sys/shim_socket.c */
  226. DEFINE_SHIM_SYSCALL (accept, 3, shim_do_accept, int, int, fd,
  227. struct sockaddr *, addr, socklen_t *, addrlen)
  228. /* sendto: sys/shim_socket.c */
  229. DEFINE_SHIM_SYSCALL (sendto, 6, shim_do_sendto, ssize_t, int, fd, const void *,
  230. buf, size_t, len, int, flags, const struct sockaddr *,
  231. dest_addr, socklen_t, addrlen)
  232. /* recvfrom : sys/shim_socket.c */
  233. DEFINE_SHIM_SYSCALL (recvfrom, 6, shim_do_recvfrom, ssize_t, int, fd, void *,
  234. buf, size_t, len, int, flags, struct sockaddr *, addr,
  235. socklen_t *, addrlen)
  236. /* bind: sys/shim_socket.c */
  237. DEFINE_SHIM_SYSCALL (bind, 3, shim_do_bind, int, int, sockfd,
  238. struct sockaddr *, addr, socklen_t, addrlen)
  239. /* listen: sys/shim_socket.c */
  240. DEFINE_SHIM_SYSCALL (listen, 2, shim_do_listen, int, int, sockfd, int, backlog)
  241. /* sendmsg: sys/shim_socket.c */
  242. DEFINE_SHIM_SYSCALL (sendmsg, 3, shim_do_sendmsg, ssize_t, int, fd,
  243. struct msghdr *, msg, int, flags)
  244. /* recvmsg: sys/shim_socket.c */
  245. DEFINE_SHIM_SYSCALL (recvmsg, 3, shim_do_recvmsg, ssize_t, int, fd,
  246. struct msghdr *, msg, int, flags)
  247. /* shutdown: sys/shim_socket.c */
  248. DEFINE_SHIM_SYSCALL (shutdown, 2, shim_do_shutdown, int, int, sockfd, int, how)
  249. /* getsockname: sys/shim_socket.c */
  250. DEFINE_SHIM_SYSCALL (getsockname, 3, shim_do_getsockname, int, int, sockfd,
  251. struct sockaddr *, addr, int *, addrlen)
  252. /* getpeername: sys/shim_socket.c */
  253. DEFINE_SHIM_SYSCALL (getpeername, 3, shim_do_getpeername, int, int, sockfd,
  254. struct sockaddr *, addr, int *, addrlen)
  255. /* socketpair: sys/shim_pipe.c */
  256. DEFINE_SHIM_SYSCALL (socketpair, 4, shim_do_socketpair, int, int, domain,
  257. int, type, int, protocol, int *, sv)
  258. /* setsockopt: sys/shim_socket.c */
  259. DEFINE_SHIM_SYSCALL (setsockopt, 5, shim_do_setsockopt, int, int, fd,
  260. int, level, int, optname, char *, optval, int, optlen)
  261. /* getsockopt: sys/shim_socket.c */
  262. DEFINE_SHIM_SYSCALL (getsockopt, 5, shim_do_getsockopt, int, int, fd,
  263. int, level, int, optname, char *, optval, int *, optlen)
  264. /* clone: sys/shim_clone.c */
  265. DEFINE_SHIM_SYSCALL (clone, 5, shim_do_clone, int, int, flags,
  266. void *, user_stack_addr, int *, parent_tidptr,
  267. int *, child_tidptr, void *, tls)
  268. /* fork: sys/shim_fork.c */
  269. DEFINE_SHIM_SYSCALL (fork, 0, shim_do_fork, int)
  270. /* vfork: sys/shim_vfork.c */
  271. DEFINE_SHIM_SYSCALL (vfork, 0, shim_do_vfork, int)
  272. /* execve: sys/shim_exec.c */
  273. DEFINE_SHIM_SYSCALL (execve, 3, shim_do_execve, int, const char *, file,
  274. const char **, argv, const char **, envp)
  275. /* exit: sys/shim_exit.c */
  276. DEFINE_SHIM_SYSCALL (exit, 1, shim_do_exit, int, int, error_code)
  277. /* wait4: sys/shim_wait.c */
  278. DEFINE_SHIM_SYSCALL (wait4, 4, shim_do_wait4, pid_t, pid_t, pid, int *,
  279. stat_addr, int, option, struct __kernel_rusage *, ru)
  280. /* kill: sys/shim_sigaction.c */
  281. DEFINE_SHIM_SYSCALL (kill, 2, shim_do_kill, int, pid_t, pid, int, sig)
  282. /* uname: sys/shim_uname.c */
  283. DEFINE_SHIM_SYSCALL (uname, 1, shim_do_uname, int, struct old_utsname *, buf)
  284. /* semget: sys/shim_semget.c */
  285. DEFINE_SHIM_SYSCALL (semget, 3, shim_do_semget, int, key_t, key, int, nsems,
  286. int, semflg)
  287. /* semop: sys/shim_semget.c */
  288. DEFINE_SHIM_SYSCALL (semop, 3, shim_do_semop, int, int, semid,
  289. struct sembuf *, sops, unsigned int, nsops)
  290. /* semctl: sys/shim_semctl.c */
  291. DEFINE_SHIM_SYSCALL (semctl, 4, shim_do_semctl, int, int, semid, int, semnum,
  292. int, cmd, unsigned long, arg)
  293. SHIM_SYSCALL_PASSTHROUGH (shmdt, 1, int, const void *, shmaddr)
  294. /* msgget: sys/shim_msgget.c */
  295. DEFINE_SHIM_SYSCALL (msgget, 2, shim_do_msgget, int, key_t, key, int, msgflg)
  296. /* msgsnd: sys/shim_msgget.c */
  297. DEFINE_SHIM_SYSCALL (msgsnd, 4, shim_do_msgsnd, int, int, msqid, const void *,
  298. msgp, size_t, msgsz, int, msgflg)
  299. /* msgrcv: sys/shim_msgget.c */
  300. DEFINE_SHIM_SYSCALL (msgrcv, 5, shim_do_msgrcv, int, int, msqid, void *, msgp,
  301. size_t, msgsz, long, msgtyp, int, msgflg)
  302. /* msgctl: sys/shim_msgget.c */
  303. DEFINE_SHIM_SYSCALL (msgctl, 3, shim_do_msgctl, int, int, msqid, int, cmd,
  304. struct msqid_ds *, buf)
  305. /* fcntl: sys/shim_fcntl.c */
  306. DEFINE_SHIM_SYSCALL (fcntl, 3, shim_do_fcntl, int, int, fd, int, cmd,
  307. unsigned long, arg)
  308. SHIM_SYSCALL_PASSTHROUGH (flock, 2, int, int, fd, int, cmd)
  309. /* fsync: sys/shim_open.c */
  310. DEFINE_SHIM_SYSCALL (fsync, 1, shim_do_fsync, int, int, fd)
  311. /* fdatasync: sys/shim_open.c */
  312. DEFINE_SHIM_SYSCALL (fdatasync, 1, shim_do_fdatasync, int, int, fd)
  313. /* truncate: sys/shim_open.c */
  314. DEFINE_SHIM_SYSCALL (truncate, 2, shim_do_truncate, int, const char *, path,
  315. loff_t, length)
  316. /* ftruncate: sys/shim_open.c */
  317. DEFINE_SHIM_SYSCALL (ftruncate, 2, shim_do_ftruncate, int, int, fd,
  318. loff_t, length)
  319. /* getdents: sys/shim_open.c */
  320. DEFINE_SHIM_SYSCALL (getdents, 3, shim_do_getdents, size_t, int, fd,
  321. struct linux_dirent *, buf, size_t, count)
  322. /* getcwd: sys/shim_getcwd.c */
  323. DEFINE_SHIM_SYSCALL (getcwd, 2, shim_do_getcwd, int, char *, buf, size_t,
  324. size)
  325. /* chdir: sys/shim_getcwd.c */
  326. DEFINE_SHIM_SYSCALL (chdir, 1, shim_do_chdir, int, const char *, filename)
  327. /* fchdir: sys/shim_getcwd.c */
  328. DEFINE_SHIM_SYSCALL (fchdir, 1, shim_do_fchdir, int, int, fd)
  329. /* rename: sys/shim_fs.c */
  330. DEFINE_SHIM_SYSCALL (rename, 2, shim_do_rename, int, const char *, oldname,
  331. const char *, newname)
  332. /* mkdir: sys/shim_fs.c */
  333. DEFINE_SHIM_SYSCALL (mkdir, 2, shim_do_mkdir, int, const char *, pathname,
  334. int, mode)
  335. /* rmdir: sys/shim_fs.c */
  336. DEFINE_SHIM_SYSCALL (rmdir, 1, shim_do_rmdir, int, const char *, pathname)
  337. DEFINE_SHIM_SYSCALL (creat, 2, shim_do_creat, int, const char *, path,
  338. mode_t, mode)
  339. SHIM_SYSCALL_PASSTHROUGH (link, 2, int, const char *, oldname, const char *,
  340. newname)
  341. /* unlink: sys/shim_fs.c */
  342. DEFINE_SHIM_SYSCALL (unlink, 1, shim_do_unlink, int, const char *, file)
  343. SHIM_SYSCALL_PASSTHROUGH (symlink, 2, int, const char *, old, const char *, new)
  344. /* readlink: sys/shim_stat.c */
  345. DEFINE_SHIM_SYSCALL (readlink, 3, shim_do_readlink, int, const char *, path,
  346. char *, buf, int, bufsize)
  347. DEFINE_SHIM_SYSCALL (chmod, 2, shim_do_chmod, int, const char *, filename,
  348. mode_t, mode)
  349. DEFINE_SHIM_SYSCALL (fchmod, 2, shim_do_fchmod, int, int, fd, mode_t, mode)
  350. DEFINE_SHIM_SYSCALL (chown, 3, shim_do_chown, int, const char *, filename,
  351. uid_t, user, gid_t, group)
  352. DEFINE_SHIM_SYSCALL (fchown, 3, shim_do_fchown, int, int, fd, uid_t, user, gid_t, group)
  353. SHIM_SYSCALL_PASSTHROUGH (lchown, 3, int, const char *, filename,
  354. uid_t, user, gid_t, group)
  355. DEFINE_SHIM_SYSCALL (umask, 1, shim_do_umask, mode_t, mode_t, mask)
  356. DEFINE_SHIM_SYSCALL (gettimeofday, 2, shim_do_gettimeofday, int,
  357. struct __kernel_timeval *, tv,
  358. struct __kernel_timezone *, tz)
  359. /* getrlimit: sys/shim_getrlimit.c */
  360. DEFINE_SHIM_SYSCALL (getrlimit, 2, shim_do_getrlimit, int, int, resource,
  361. struct __kernel_rlimit *, rlim)
  362. int shim_do_getrusage (int who, struct __kernel_rusage * ru)
  363. {
  364. memset(ru, 0, sizeof(struct __kernel_rusage));
  365. return -ENOSYS;
  366. }
  367. DEFINE_SHIM_SYSCALL (getrusage, 2, shim_do_getrusage, int, int, who,
  368. struct __kernel_rusage *, ru)
  369. SHIM_SYSCALL_PASSTHROUGH (sysinfo, 1, int, struct sysinfo *, info)
  370. SHIM_SYSCALL_PASSTHROUGH (times, 1, int, struct tms *, tbuf)
  371. SHIM_SYSCALL_PASSTHROUGH (ptrace, 4, int, long, request, pid_t, pid, void *,
  372. addr, void *, data)
  373. /* getuid: sys/shim_getpid.c */
  374. DEFINE_SHIM_SYSCALL (getuid, 0, shim_do_getuid, uid_t)
  375. SHIM_SYSCALL_PASSTHROUGH (syslog, 3, int, int, type, char *, buf, int, len)
  376. /* getgid: sys/shim_getgid.c */
  377. DEFINE_SHIM_SYSCALL (getgid, 0, shim_do_getgid, gid_t)
  378. /* setuid: sys/shim_getpid.c */
  379. DEFINE_SHIM_SYSCALL (setuid, 1, shim_do_setuid, int, uid_t, uid)
  380. /* setgid: sys/shim_getpid.c */
  381. DEFINE_SHIM_SYSCALL (setgid, 1, shim_do_setgid, int, gid_t, gid)
  382. /* geteuid: sys/shim_getpid.c */
  383. DEFINE_SHIM_SYSCALL (geteuid, 0, shim_do_geteuid, uid_t)
  384. /* getegid: sys/shim_getpid.c */
  385. DEFINE_SHIM_SYSCALL (getegid, 0, shim_do_getegid, gid_t)
  386. /* getpgid: sys/shim_getpid.c */
  387. DEFINE_SHIM_SYSCALL (setpgid, 2, shim_do_setpgid, int, pid_t, pid, pid_t, pgid)
  388. /* getppid: sys/shim_getpid.c */
  389. DEFINE_SHIM_SYSCALL (getppid, 0, shim_do_getppid, pid_t)
  390. /* getpgrp: sys/shim_getpid.c */
  391. DEFINE_SHIM_SYSCALL (getpgrp, 0, shim_do_getpgrp, pid_t)
  392. /* setsid: sys/shim_getpid.c */
  393. DEFINE_SHIM_SYSCALL (setsid, 0, shim_do_setsid, int)
  394. SHIM_SYSCALL_PASSTHROUGH (setreuid, 2, int, uid_t, ruid, uid_t, euid)
  395. SHIM_SYSCALL_PASSTHROUGH (setregid, 2, int, gid_t, rgid, gid_t, egid)
  396. SHIM_SYSCALL_PASSTHROUGH (getgroups, 2, int, int, gidsetsize, gid_t *,
  397. grouplist)
  398. SHIM_SYSCALL_PASSTHROUGH (setgroups, 2, int, int, gidsetsize, gid_t *,
  399. grouplist)
  400. SHIM_SYSCALL_PASSTHROUGH (setresuid, 3, int, uid_t, ruid, uid_t, euid, uid_t,
  401. suid)
  402. SHIM_SYSCALL_PASSTHROUGH (getresuid, 3, int, uid_t *, ruid, uid_t *, euid,
  403. uid_t *, suid)
  404. SHIM_SYSCALL_PASSTHROUGH (setresgid, 3, int, gid_t, rgid, gid_t, egid, gid_t,
  405. sgid)
  406. SHIM_SYSCALL_PASSTHROUGH (getresgid, 3, int, gid_t *, rgid, gid_t *, egid,
  407. gid_t *, sgid)
  408. DEFINE_SHIM_SYSCALL (getpgid, 1, shim_do_getpgid, int, pid_t, pid)
  409. SHIM_SYSCALL_PASSTHROUGH (setfsuid, 1, int, uid_t, uid)
  410. SHIM_SYSCALL_PASSTHROUGH (setfsgid, 1, int, gid_t, gid)
  411. DEFINE_SHIM_SYSCALL (getsid, 1, shim_do_getsid, int, pid_t, pid)
  412. SHIM_SYSCALL_PASSTHROUGH (capget, 2, int, cap_user_header_t, header,
  413. cap_user_data_t, dataptr)
  414. SHIM_SYSCALL_PASSTHROUGH (capset, 2, int, cap_user_header_t, header,
  415. const cap_user_data_t, data)
  416. DEFINE_SHIM_SYSCALL (rt_sigpending, 2, shim_do_sigpending, int,
  417. __sigset_t *, set, size_t, sigsetsize)
  418. SHIM_SYSCALL_PASSTHROUGH (rt_sigtimedwait, 4, int, const __sigset_t *, uthese,
  419. siginfo_t *, uinfo, const struct timespec *, uts,
  420. size_t, sigsetsize)
  421. SHIM_SYSCALL_PASSTHROUGH (rt_sigqueueinfo, 3, int, int, pid, int, sig,
  422. siginfo_t *, uinfo)
  423. DEFINE_SHIM_SYSCALL (rt_sigsuspend, 1, shim_do_sigsuspend, int, const __sigset_t *, mask)
  424. DEFINE_SHIM_SYSCALL (sigaltstack, 2, shim_do_sigaltstack, int, const stack_t *, ss,
  425. stack_t *, oss)
  426. SHIM_SYSCALL_PASSTHROUGH (utime, 2, int, char *, filename, struct utimbuf *,
  427. times)
  428. SHIM_SYSCALL_PASSTHROUGH (mknod, 3, int, const char *, filename, int, mode,
  429. unsigned, dev)
  430. SHIM_SYSCALL_PASSTHROUGH (uselib, 1, int, const char *, library)
  431. SHIM_SYSCALL_PASSTHROUGH (personality, 1, int, unsigned int, personality)
  432. SHIM_SYSCALL_PASSTHROUGH (ustat, 2, int, unsigned, dev,
  433. struct __kernel_ustat *, ubuf)
  434. SHIM_SYSCALL_PASSTHROUGH (statfs, 2, int, const char *, path, struct statfs *,
  435. buf)
  436. SHIM_SYSCALL_PASSTHROUGH (fstatfs, 2, int, int, fd, struct statfs *,
  437. buf)
  438. SHIM_SYSCALL_PASSTHROUGH (sysfs, 3, int, int, option, unsigned long, arg1,
  439. unsigned long, arg2)
  440. SHIM_SYSCALL_PASSTHROUGH (getpriority, 2, int, int, which, int, who)
  441. SHIM_SYSCALL_PASSTHROUGH (setpriority, 3, int, int, which, int, who, int,
  442. niceval)
  443. SHIM_SYSCALL_PASSTHROUGH (sched_setparam, 2, int, pid_t, pid,
  444. struct __kernel_sched_param *, param)
  445. SHIM_SYSCALL_PASSTHROUGH (sched_getparam, 2, int, pid_t, pid,
  446. struct __kernel_sched_param *, param)
  447. SHIM_SYSCALL_PASSTHROUGH (sched_setscheduler, 3, int, pid_t, pid, int, policy,
  448. struct __kernel_sched_param *, param)
  449. SHIM_SYSCALL_PASSTHROUGH (sched_getscheduler, 1, int, pid_t, pid)
  450. SHIM_SYSCALL_PASSTHROUGH (sched_get_priority_max, 1, int, int, policy)
  451. SHIM_SYSCALL_PASSTHROUGH (sched_get_priority_min, 1, int, int, policy)
  452. SHIM_SYSCALL_PASSTHROUGH (sched_rr_get_interval, 2, int, pid_t, pid,
  453. struct timespec *, interval)
  454. SHIM_SYSCALL_PASSTHROUGH (mlock, 2, int, void *, start, size_t, len)
  455. SHIM_SYSCALL_PASSTHROUGH (munlock, 2, int, void *, start, size_t, len)
  456. SHIM_SYSCALL_PASSTHROUGH (mlockall, 1, int, int, flags)
  457. SHIM_SYSCALL_PASSTHROUGH (munlockall, 0, int)
  458. SHIM_SYSCALL_PASSTHROUGH (vhangup, 0, int)
  459. SHIM_SYSCALL_PASSTHROUGH (modify_ldt, 3, int, int, func, void *, ptr,
  460. unsigned long, bytecount)
  461. SHIM_SYSCALL_PASSTHROUGH (pivot_root, 2, int, const char *, new_root,
  462. const char *, put_old)
  463. SHIM_SYSCALL_PASSTHROUGH (_sysctl, 1, int, struct __kernel_sysctl_args *, args)
  464. SHIM_SYSCALL_PASSTHROUGH (prctl, 5, int, int, option, unsigned long, arg2,
  465. unsigned long, arg3, unsigned long, arg4,
  466. unsigned long, arg5)
  467. DEFINE_SHIM_SYSCALL (arch_prctl, 2, shim_do_arch_prctl, void *, int, code,
  468. void *, addr)
  469. void * shim_do_arch_prctl (int code, void * addr)
  470. {
  471. /* We only support set fs. Die loudly if we see anything else. */
  472. assert(code == ARCH_SET_FS || code == ARCH_GET_FS);
  473. switch (code) {
  474. case ARCH_SET_FS:
  475. if (!addr)
  476. return (void *) -EINVAL;
  477. populate_tls(addr, true);
  478. debug("set tcb to %p\n", (void *) addr);
  479. return NULL;
  480. case ARCH_GET_FS:
  481. return (void *) DkSegmentRegister(PAL_SEGMENT_FS, NULL) ? :
  482. (void *) -PAL_ERRNO;
  483. }
  484. return (void *) -ENOSYS;
  485. }
  486. SHIM_SYSCALL_PASSTHROUGH (adjtimex, 1, int, struct __kernel_timex *, txc_p)
  487. /* setrlimit: sys/shim_getrlimit.c */
  488. DEFINE_SHIM_SYSCALL (setrlimit, 2, shim_do_setrlimit, int, int, resource,
  489. struct __kernel_rlimit *, rlim)
  490. /* chroot: sys/shim_isolate.c */
  491. DEFINE_SHIM_SYSCALL (chroot, 1, shim_do_chroot, int, const char *, filename)
  492. SHIM_SYSCALL_PASSTHROUGH (sync, 0, int)
  493. SHIM_SYSCALL_PASSTHROUGH (acct, 1, int, const char *, name)
  494. SHIM_SYSCALL_PASSTHROUGH (settimeofday, 2, int, struct timeval *, tv,
  495. struct __kernel_timezone *, tz)
  496. SHIM_SYSCALL_PASSTHROUGH (mount, 5, int, char *, dev_name, char *, dir_name,
  497. char *, type, unsigned long, flags, void *, data)
  498. SHIM_SYSCALL_PASSTHROUGH (umount2, 2, int, const char *, target, int, flags)
  499. SHIM_SYSCALL_PASSTHROUGH (swapon, 2, int, const char *, specialfile, int,
  500. swap_flags)
  501. SHIM_SYSCALL_PASSTHROUGH (swapoff, 1, int, const char *, specialfile)
  502. SHIM_SYSCALL_PASSTHROUGH (reboot, 4, int, int, magic1, int, magic2,
  503. int, cmd, void *, arg)
  504. SHIM_SYSCALL_PASSTHROUGH (sethostname, 2, int, char *, name, int, len)
  505. SHIM_SYSCALL_PASSTHROUGH (setdomainname, 2, int, char *, name, int, len)
  506. SHIM_SYSCALL_PASSTHROUGH (iopl, 1, int, int, level)
  507. SHIM_SYSCALL_PASSTHROUGH (ioperm, 3, int, unsigned long, from, unsigned long,
  508. num, int, on)
  509. SHIM_SYSCALL_PASSTHROUGH (create_module, 2, int, const char *, name, size_t,
  510. size)
  511. SHIM_SYSCALL_PASSTHROUGH (init_module, 3, int, void *, umod, unsigned long, len,
  512. const char *, uargs)
  513. SHIM_SYSCALL_PASSTHROUGH (delete_module, 2, int, const char *, name_user,
  514. unsigned int, flags)
  515. /*
  516. SHIM_SYSCALL_PASSTHROUGH (get_kernel_syms, 1, int, struct kernel_sym *, table)
  517. */
  518. SHIM_SYSCALL_PASSTHROUGH (query_module, 5, int, const char *, name, int, which,
  519. void *, buf, size_t, bufsize, size_t *, retsize)
  520. SHIM_SYSCALL_PASSTHROUGH (quotactl, 4, int, int, cmd, const char *,
  521. special, qid_t, id, void *, addr)
  522. /*
  523. SHIM_SYSCALL_PASSTHROUGH (nfsservctl, 3, int, int, cmd, struct nfsctl_arg *,
  524. arg, void *, res)
  525. */
  526. /* shim_getpmsg MISSING
  527. TODO: getpmsg syscall is not implemented (kernel always returns -ENOSYS),
  528. how should we handle this?*/
  529. /* shim_putpmsg MISSING
  530. TODO: putpmsg syscall is not implemented (kernel always returns -ENOSYS),
  531. how should we handle this?*/
  532. /* shim_afs_syscall MISSING
  533. TODO: afs_syscall is not implemented (kernel always returns -ENOSYS),
  534. how should we handle this?*/
  535. /* shim_tuxcall MISSING
  536. TODO: tuxcall syscall is not implemented (kernel always returns -ENOSYS),
  537. how should we handle this?*/
  538. /* shim_security MISSING
  539. TODO: security syscall is not implemented (kernel always returns -ENOSYS),
  540. how should we handle this?*/
  541. /* gettid: sys/shim_getpid.c */
  542. DEFINE_SHIM_SYSCALL (gettid, 0, shim_do_gettid, pid_t)
  543. SHIM_SYSCALL_PASSTHROUGH (readahead, 3, int, int, fd, loff_t, offset, size_t,
  544. count)
  545. SHIM_SYSCALL_PASSTHROUGH (setxattr, 5, int, const char *, path, const char *,
  546. name, const void *, value, size_t, size, int, flags)
  547. SHIM_SYSCALL_PASSTHROUGH (lsetxattr, 5, int, const char *, path, const char *,
  548. name, const void *, value, size_t, size, int, flags)
  549. SHIM_SYSCALL_PASSTHROUGH (fsetxattr, 5, int, int, fd, const char *, name,
  550. const void *, value, size_t, size, int, flags)
  551. SHIM_SYSCALL_PASSTHROUGH (getxattr, 4, int, const char *, path, const char *,
  552. name, void *, value, size_t, size)
  553. SHIM_SYSCALL_PASSTHROUGH (lgetxattr, 4, int, const char *, path, const char *,
  554. name, void *, value, size_t, size)
  555. SHIM_SYSCALL_PASSTHROUGH (fgetxattr, 4, int, int, fd, const char *, name,
  556. void *, value, size_t, size)
  557. SHIM_SYSCALL_PASSTHROUGH (listxattr, 3, int, const char *, path, char *, list,
  558. size_t, size)
  559. SHIM_SYSCALL_PASSTHROUGH (llistxattr, 3, int, const char *, path, char *, list,
  560. size_t, size)
  561. SHIM_SYSCALL_PASSTHROUGH (flistxattr, 3, int, int, fd, char *, list, size_t,
  562. size)
  563. SHIM_SYSCALL_PASSTHROUGH (removexattr, 2, int, const char *, path, const char *,
  564. name)
  565. SHIM_SYSCALL_PASSTHROUGH (lremovexattr, 2, int, const char *, path,
  566. const char *, name)
  567. SHIM_SYSCALL_PASSTHROUGH (fremovexattr, 2, int, int, fd, const char *, name)
  568. DEFINE_SHIM_SYSCALL (tkill, 2, shim_do_tkill, int, pid_t, pid, int, sig)
  569. DEFINE_SHIM_SYSCALL (time, 1, shim_do_time, time_t, time_t *, tloc)
  570. /* futex: sys/shim_futex.c */
  571. DEFINE_SHIM_SYSCALL (futex, 6, shim_do_futex, int, unsigned int *, uaddr,
  572. int, op, int, val, void *, utime, unsigned int *, uaddr2,
  573. int, val3)
  574. SHIM_SYSCALL_PASSTHROUGH (sched_setaffinity, 3, int, pid_t, pid, size_t, len,
  575. __kernel_cpu_set_t *, user_mask_ptr)
  576. SHIM_SYSCALL_PASSTHROUGH (sched_getaffinity, 3, int, pid_t, pid, size_t, len,
  577. __kernel_cpu_set_t *, user_mask_ptr)
  578. SHIM_SYSCALL_PASSTHROUGH (set_thread_area, 1, int, struct user_desc *, u_info)
  579. /* no glibc wrapper */
  580. SHIM_SYSCALL_PASSTHROUGH (io_setup, 2, int, unsigned, nr_reqs, aio_context_t *,
  581. ctx)
  582. SHIM_SYSCALL_PASSTHROUGH (io_destroy, 1, int, aio_context_t, ctx)
  583. SHIM_SYSCALL_PASSTHROUGH (io_getevents, 5, int, aio_context_t, ctx_id, long,
  584. min_nr, long, nr, struct io_event *, events,
  585. struct timespec *, timeout)
  586. SHIM_SYSCALL_PASSTHROUGH (io_submit, 3, int, aio_context_t, ctx_id, long, nr,
  587. struct iocb **, iocbpp)
  588. SHIM_SYSCALL_PASSTHROUGH (io_cancel, 3, int, aio_context_t, ctx_id,
  589. struct iocb *, iocb, struct io_event *, result)
  590. SHIM_SYSCALL_PASSTHROUGH (get_thread_area, 1, int, struct user_desc *, u_info)
  591. SHIM_SYSCALL_PASSTHROUGH (lookup_dcookie, 3, int, unsigned long, cookie64,
  592. char *, buf, size_t, len)
  593. DEFINE_SHIM_SYSCALL (epoll_create, 1, shim_do_epoll_create , int, int, size)
  594. /* shim_epoll_ctl_old MISSING
  595. TODO: epoll_ctl_old syscall is not implemented (kernel always returns -ENOSYS),
  596. how should we handle this?*/
  597. /* shim_epoll_wait_old MISSING
  598. TODO: epoll_wait_old syscall is not implemented (kernel always returns -ENOSYS),
  599. how should we handle this?*/
  600. SHIM_SYSCALL_PASSTHROUGH (remap_file_pages, 5, int, void *, start, size_t, size,
  601. int, prot, ssize_t, pgoff, int, flags)
  602. /* getdents64: sys/shim_open.c */
  603. DEFINE_SHIM_SYSCALL (getdents64, 3, shim_do_getdents64, size_t, int, fd,
  604. struct linux_dirent64 *, buf, size_t, count)
  605. /* set_tid_address: sys/shim_getpid.c */
  606. DEFINE_SHIM_SYSCALL (set_tid_address, 1, shim_do_set_tid_address, int, int *,
  607. tidptr)
  608. SHIM_SYSCALL_PASSTHROUGH (restart_syscall, 0, int)
  609. /* semtimedop: sys/shim_semget.c */
  610. DEFINE_SHIM_SYSCALL (semtimedop, 4, shim_do_semtimedop, int, int, semid,
  611. struct sembuf *, sops, unsigned int, nsops,
  612. const struct timespec *, timeout)
  613. SHIM_SYSCALL_PASSTHROUGH (fadvise64, 4, int, int, fd, loff_t, offset, size_t,
  614. len, int, advice)
  615. SHIM_SYSCALL_PASSTHROUGH (timer_create, 3, int, clockid_t, which_clock,
  616. struct sigevent *, timer_event_spec, timer_t *,
  617. created_timer_id)
  618. SHIM_SYSCALL_PASSTHROUGH (timer_settime, 4, int, timer_t, timer_id, int, flags,
  619. const struct __kernel_itimerspec *, new_setting,
  620. struct __kernel_itimerspec *, old_setting)
  621. SHIM_SYSCALL_PASSTHROUGH (timer_gettime, 2, int, timer_t, timer_id,
  622. struct __kernel_itimerspec *, setting)
  623. SHIM_SYSCALL_PASSTHROUGH (timer_getoverrun, 1, int, timer_t, timer_id)
  624. SHIM_SYSCALL_PASSTHROUGH (timer_delete, 1, int, timer_t, timer_id)
  625. SHIM_SYSCALL_PASSTHROUGH (clock_settime, 2, int, clockid_t, which_clock,
  626. const struct timespec *, tp)
  627. /* clock_gettime: sys/shim_time.c */
  628. DEFINE_SHIM_SYSCALL (clock_gettime, 2, shim_do_clock_gettime, int,
  629. clockid_t, which_clock, struct timespec *, tp)
  630. DEFINE_SHIM_SYSCALL (clock_getres, 2, shim_do_clock_getres, int,
  631. clockid_t, which_clock, struct timespec *, tp)
  632. SHIM_SYSCALL_PASSTHROUGH (clock_nanosleep, 4, int, clockid_t, which_clock,
  633. int, flags, const struct timespec *, rqtp,
  634. struct timespec *, rmtp)
  635. /* exit_group: sys/shim_exit.c */
  636. DEFINE_SHIM_SYSCALL (exit_group, 1, shim_do_exit_group, int, int, error_code)
  637. DEFINE_SHIM_SYSCALL (epoll_wait, 4, shim_do_epoll_wait, int, int, epfd,
  638. struct __kernel_epoll_event *, events,
  639. int, maxevents, int, timeout)
  640. DEFINE_SHIM_SYSCALL (epoll_ctl, 4, shim_do_epoll_ctl, int, int, epfd, int, op, int, fd,
  641. struct __kernel_epoll_event *, event)
  642. DEFINE_SHIM_SYSCALL (tgkill, 3, shim_do_tgkill, int, pid_t, tgid, pid_t, pid,
  643. int, sig)
  644. SHIM_SYSCALL_PASSTHROUGH (utimes, 2, int, char *, filename, struct timeval *,
  645. utimes)
  646. /* shim_vserver MISSING
  647. TODO: vserver syscall is not implemented (kernel always returns -ENOSYS),
  648. how should we handle this?*/
  649. SHIM_SYSCALL_PASSTHROUGH (mbind, 6, int, void *, start, unsigned long, len,
  650. int, mode, unsigned long *, nmask,
  651. unsigned long, maxnode, int, flags)
  652. SHIM_SYSCALL_PASSTHROUGH (set_mempolicy, 3, int, int, mode, unsigned long *,
  653. nmask, unsigned long, maxnode)
  654. SHIM_SYSCALL_PASSTHROUGH (get_mempolicy, 5, int, int *, policy, unsigned long *,
  655. nmask, unsigned long, maxnode, unsigned long, addr,
  656. unsigned long, flags)
  657. SHIM_SYSCALL_PASSTHROUGH (mq_open, 4, int, const char *, name, int, oflag,
  658. mode_t, mode, struct __kernel_mq_attr *, attr)
  659. SHIM_SYSCALL_PASSTHROUGH (mq_unlink, 1, int, const char *, name)
  660. SHIM_SYSCALL_PASSTHROUGH (mq_timedsend, 5, int, __kernel_mqd_t, mqdes,
  661. const char *, msg_ptr, size_t, msg_len, unsigned int,
  662. msg_prio, const struct timespec *, abs_timeout)
  663. SHIM_SYSCALL_PASSTHROUGH (mq_timedreceive, 5, int, __kernel_mqd_t, mqdes,
  664. char *, msg_ptr, size_t, msg_len, unsigned int *,
  665. msg_prio, const struct timespec *, abs_timeout)
  666. SHIM_SYSCALL_PASSTHROUGH (mq_notify, 2, int, __kernel_mqd_t, mqdes,
  667. const struct sigevent *, notification)
  668. SHIM_SYSCALL_PASSTHROUGH (mq_getsetattr, 3, int, __kernel_mqd_t, mqdes,
  669. const struct __kernel_mq_attr *, mqstat,
  670. struct __kernel_mq_attr *, omqstat)
  671. /*
  672. SHIM_SYSCALL_PASSTHROUGH (kexec_load, 4, int, unsigned long, entry,
  673. unsigned long, nr_segments, struct kexec_segment *,
  674. segments, unsigned long, flags)
  675. */
  676. SHIM_SYSCALL_PASSTHROUGH (waitid, 5, int, int, which, pid_t, pid,
  677. siginfo_t *, infop, int, options,
  678. struct __kernel_rusage *, ru)
  679. /*
  680. SHIM_SYSCALL_PASSTHROUGH (add_key, 5, int, const char *, type, const char *,
  681. description, const void *, payload, size_t, plen,
  682. key_serial_t, destringid)
  683. */
  684. /*
  685. SHIM_SYSCALL_PASSTHROUGH (request_key, 4, int, const char *, type,
  686. const char *, description, const char *, callout_info,
  687. key_serial_t, destringid)
  688. */
  689. /*
  690. SHIM_SYSCALL_PASSTHROUGH (keyctl, 5, int, int, cmd, unsigned long, arg2,
  691. unsigned long, arg3, unsigned long, arg4,
  692. unsigned long, arg5)
  693. */
  694. SHIM_SYSCALL_PASSTHROUGH (ioprio_set, 3, int, int, which, int, who, int, ioprio)
  695. SHIM_SYSCALL_PASSTHROUGH (ioprio_get, 2, int, int, which, int, who)
  696. SHIM_SYSCALL_PASSTHROUGH (inotify_init, 0, int)
  697. SHIM_SYSCALL_PASSTHROUGH (inotify_add_watch, 3, int, int, fd, const char *,
  698. path, unsigned int, mask)
  699. SHIM_SYSCALL_PASSTHROUGH (inotify_rm_watch, 2, int, int, fd, unsigned int, wd)
  700. SHIM_SYSCALL_PASSTHROUGH (migrate_pages, 4, int, pid_t, pid, unsigned long,
  701. maxnode, const unsigned long *, from,
  702. const unsigned long *, to)
  703. /* openat: sys/shim_open.c */
  704. DEFINE_SHIM_SYSCALL (openat, 4, shim_do_openat, int, int, dfd,
  705. const char *, filename, int, flags, int, mode)
  706. /* mkdirat: sys/shim_fs.c */
  707. DEFINE_SHIM_SYSCALL (mkdirat, 3, shim_do_mkdirat, int, int, dfd,
  708. const char *, pathname, int, mode)
  709. SHIM_SYSCALL_PASSTHROUGH (mknodat, 4, int, int, dfd, const char *, filename,
  710. int, mode, unsigned, dev)
  711. DEFINE_SHIM_SYSCALL (fchownat, 5, shim_do_fchownat, int, int, dfd,
  712. const char *, filename, uid_t, user, gid_t, group, int, flag)
  713. SHIM_SYSCALL_PASSTHROUGH (futimesat, 3, int, int, dfd, const char *, filename,
  714. struct timeval *, utimes)
  715. SHIM_SYSCALL_PASSTHROUGH (newfstatat, 4, int, int, dfd, const char *, filename,
  716. struct stat *, statbuf, int, flag)
  717. /* unlinkat: sys/shim_fs.c */
  718. DEFINE_SHIM_SYSCALL (unlinkat, 3, shim_do_unlinkat, int, int, dfd,
  719. const char *, pathname, int, flag)
  720. /* renameat: sys/shim_fs.c */
  721. DEFINE_SHIM_SYSCALL (renameat, 4, shim_do_renameat, int, int, olddfd,
  722. const char *, oldname, int, newdfd, const char *, newname)
  723. SHIM_SYSCALL_PASSTHROUGH (linkat, 5, int, int, olddfd, const char *, oldname,
  724. int, newdfd, const char *, newname, int, flags)
  725. SHIM_SYSCALL_PASSTHROUGH (symlinkat, 3, int, const char *, oldname, int,
  726. newdfd, const char *, newname)
  727. SHIM_SYSCALL_PASSTHROUGH (readlinkat, 4, int, int, dfd, const char *, path,
  728. char *, buf, int, bufsiz)
  729. /* fchmodat: sys/shim_fs.c */
  730. DEFINE_SHIM_SYSCALL (fchmodat, 3, shim_do_fchmodat, int, int, dfd,
  731. const char *, filename, mode_t, mode)
  732. /* faccessat: sys/shim_access.c */
  733. DEFINE_SHIM_SYSCALL (faccessat, 3, shim_do_faccessat, int, int, dfd,
  734. const char *, filename, int, mode)
  735. /* pselect6: sys/shim_poll.c */
  736. DEFINE_SHIM_SYSCALL (pselect6, 6, shim_do_pselect6, int, int, nfds,
  737. fd_set *, readfds, fd_set *, writefds, fd_set *, errorfds,
  738. const struct __kernel_timespec *, tsp,
  739. const __sigset_t *, sigmask)
  740. /* ppoll: sys/shim_poll.c */
  741. DEFINE_SHIM_SYSCALL (ppoll, 5, shim_do_ppoll, int, struct pollfd *, fds,
  742. int, nfds, struct timespec *, tsp,
  743. const __sigset_t *, sigmask, size_t, sigsetsize)
  744. SHIM_SYSCALL_PASSTHROUGH (unshare, 1, int, int, unshare_flags)
  745. /* set_robust_list: sys/shim_futex.c */
  746. DEFINE_SHIM_SYSCALL (set_robust_list, 2, shim_do_set_robust_list, int,
  747. struct robust_list_head *, head, size_t, len)
  748. /* get_roubust_list: sys/shim_futex.c */
  749. DEFINE_SHIM_SYSCALL (get_robust_list, 3, shim_do_get_robust_list, int, pid_t,
  750. pid, struct robust_list_head **, head, size_t *, len)
  751. SHIM_SYSCALL_PASSTHROUGH (splice, 6, int, int, fd_in, loff_t *, off_in, int,
  752. fd_out, loff_t *, off_out, size_t, len, int, flags)
  753. SHIM_SYSCALL_PASSTHROUGH (tee, 4, int, int, fdin, int, fdout, size_t, len,
  754. unsigned int, flags)
  755. SHIM_SYSCALL_PASSTHROUGH (sync_file_range, 4, int, int, fd, loff_t, offset,
  756. loff_t, nbytes, int, flags)
  757. SHIM_SYSCALL_PASSTHROUGH (vmsplice, 4, int, int, fd, const struct iovec *, iov,
  758. unsigned long, nr_segs, int, flags)
  759. SHIM_SYSCALL_PASSTHROUGH (move_pages, 6, int, pid_t, pid, unsigned long,
  760. nr_pages, void **, pages, const int *, nodes,
  761. int *, status, int, flags)
  762. SHIM_SYSCALL_PASSTHROUGH (utimensat, 4, int, int, dfd, const char *, filename,
  763. struct timespec *, utimes, int, flags)
  764. DEFINE_SHIM_SYSCALL (epoll_pwait, 6, shim_do_epoll_pwait, int, int, epfd,
  765. struct __kernel_epoll_event *, events, int, maxevents,
  766. int, timeout, const __sigset_t *, sigmask,
  767. size_t, sigsetsize)
  768. SHIM_SYSCALL_PASSTHROUGH (signalfd, 3, int, int, ufd, __sigset_t *, user_mask,
  769. size_t, sizemask)
  770. SHIM_SYSCALL_PASSTHROUGH (timerfd_create, 2, int, int, clockid, int, flags)
  771. SHIM_SYSCALL_PASSTHROUGH (eventfd, 1, int, int, count)
  772. SHIM_SYSCALL_PASSTHROUGH (fallocate, 4, int, int, fd, int, mode, loff_t, offset,
  773. loff_t, len)
  774. SHIM_SYSCALL_PASSTHROUGH (timerfd_settime, 4, int, int, ufd, int, flags,
  775. const struct __kernel_itimerspec *, utmr,
  776. struct __kernel_itimerspec *, otmr)
  777. SHIM_SYSCALL_PASSTHROUGH (timerfd_gettime, 2, int, int, ufd,
  778. struct __kernel_itimerspec *, otmr)
  779. /* accept4: sys/shim_socket.c */
  780. DEFINE_SHIM_SYSCALL (accept4, 4, shim_do_accept4, int, int, sockfd,
  781. struct sockaddr *, addr, socklen_t *, addrlen, int, flags)
  782. SHIM_SYSCALL_PASSTHROUGH (signalfd4, 4, int, int, ufd, __sigset_t *, user_mask,
  783. size_t, sizemask, int, flags)
  784. SHIM_SYSCALL_PASSTHROUGH (eventfd2, 2, int, int, count, int, flags)
  785. /* epoll_create1: sys/shim_epoll.c */
  786. DEFINE_SHIM_SYSCALL (epoll_create1, 1, shim_do_epoll_create1, int, int, flags)
  787. /* dup3: sys/shim_dup.c */
  788. DEFINE_SHIM_SYSCALL (dup3, 3, shim_do_dup3, int, int, oldfd, int, newfd,
  789. int, flags)
  790. /* pipe2: sys/shim_pipe.c */
  791. DEFINE_SHIM_SYSCALL (pipe2, 2, shim_do_pipe2, int, int *, fildes, int, flags)
  792. SHIM_SYSCALL_PASSTHROUGH (inotify_init1, 1, int, int, flags)
  793. SHIM_SYSCALL_PASSTHROUGH (preadv, 5, int, unsigned long, fd,
  794. const struct iovec *, vec, unsigned long, vlen,
  795. unsigned long, pos_l, unsigned long, pos_h)
  796. SHIM_SYSCALL_PASSTHROUGH (pwritev, 5, int, unsigned long, fd,
  797. const struct iovec *, vec, unsigned long, vlen,
  798. unsigned long, pos_l, unsigned long, pos_h)
  799. SHIM_SYSCALL_PASSTHROUGH (rt_tgsigqueueinfo, 4, int, pid_t, tgid, pid_t, pid,
  800. int, sig, siginfo_t *, uinfo)
  801. SHIM_SYSCALL_PASSTHROUGH (perf_event_open, 5, int, struct perf_event_attr *,
  802. attr_uptr, pid_t, pid, int, cpu, int, group_fd,
  803. int, flags)
  804. DEFINE_SHIM_SYSCALL (recvmmsg, 5, shim_do_recvmmsg, int, int, fd,
  805. struct mmsghdr *, msg, int, vlen, int, flags,
  806. struct __kernel_timespec *, timeout)
  807. SHIM_SYSCALL_PASSTHROUGH (fanotify_init, 2, int, int, flags, int, event_f_flags)
  808. SHIM_SYSCALL_PASSTHROUGH (fanotify_mark, 5, int, int, fanotify_fd, int, flags,
  809. unsigned long, mask, int, fd, const char *, pathname)
  810. SHIM_SYSCALL_PASSTHROUGH (prlimit64, 4, int, pid_t, pid, int, resource,
  811. const struct __kernel_rlimit64 *, new_rlim,
  812. struct __kernel_rlimit64 *, old_rlim)
  813. SHIM_SYSCALL_PASSTHROUGH (name_to_handle_at, 5, int, int, dfd,
  814. const char *, name,
  815. struct linux_file_handle *, handle, int *, mnt_id,
  816. int, flag)
  817. SHIM_SYSCALL_PASSTHROUGH (open_by_handle_at, 3, int, int, mountdirfd,
  818. struct linux_file_handle *, handle, int, flags)
  819. SHIM_SYSCALL_PASSTHROUGH (clock_adjtime, 2, int, clockid_t, which_clock,
  820. struct timex *, tx)
  821. SHIM_SYSCALL_PASSTHROUGH (syncfs, 1, int, int, fd)
  822. DEFINE_SHIM_SYSCALL (sendmmsg, 4, shim_do_sendmmsg, int, int, fd,
  823. struct mmsghdr *, msg, int, vlen, int, flags)
  824. SHIM_SYSCALL_PASSTHROUGH (setns, 2, int, int, fd, int, nstype)
  825. SHIM_SYSCALL_PASSTHROUGH (getcpu, 3, int, unsigned *, cpu, unsigned *, node,
  826. struct getcpu_cache *, cache)
  827. /* libos calls */
  828. DEFINE_SHIM_SYSCALL (sandbox_create, 3, shim_do_sandbox_create, long,
  829. int, flags, const char *, fs_sb, struct net_sb *, net_sb)
  830. DEFINE_SHIM_SYSCALL (sandbox_attach, 1, shim_do_sandbox_attach, int,
  831. unsigned int, sandboxid)
  832. DEFINE_SHIM_SYSCALL (sandbox_current, 0, shim_do_sandbox_current, long)
  833. DEFINE_SHIM_SYSCALL (msgpersist, 2, shim_do_msgpersist, int, int, msqid,
  834. int, cmd)
  835. DEFINE_SHIM_SYSCALL (benchmark_rpc, 4, shim_do_benchmark_rpc, int, pid_t, pid,
  836. int, times, const void *, buf, size_t, size)
  837. DEFINE_SHIM_SYSCALL (send_rpc, 3, shim_do_send_rpc, size_t, pid_t, pid,
  838. const void *, buf, size_t, size)
  839. DEFINE_SHIM_SYSCALL (recv_rpc, 3, shim_do_recv_rpc, size_t, pid_t *, pid,
  840. void *, buf, size_t, size)
  841. DEFINE_SHIM_SYSCALL (checkpoint, 1, shim_do_checkpoint, int,
  842. const char *, filename)