1 /*--------------------------------------------------------------------*/
2 /*--- FreeBSD-specific syscalls, etc. syswrap-freebsd.c ---*/
3 /*--------------------------------------------------------------------*/
6 This file is part of Valgrind, a dynamic binary instrumentation
9 Copyright (C) 2000-2008 Nicholas Nethercote
11 Copyright (C) 2018-2021 Paul Floyd
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License as
16 published by the Free Software Foundation; either version 2 of the
17 License, or (at your option) any later version.
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, see <http://www.gnu.org/licenses/>.
27 The GNU General Public License is contained in the file COPYING.
30 #if defined(VGO_freebsd)
32 #include "pub_core_basics.h"
33 #include "pub_core_vki.h"
34 #include "pub_core_vkiscnums.h"
35 #include "pub_core_threadstate.h"
36 #include "pub_core_aspacemgr.h"
37 #include "pub_core_debuginfo.h" // VG_(di_notify_*)
38 #include "pub_core_transtab.h" // VG_(discard_translations)
39 #include "pub_core_xarray.h"
40 #include "pub_core_clientstate.h"
41 #include "pub_core_debuglog.h"
42 #include "pub_core_libcbase.h"
43 #include "pub_core_libcassert.h"
44 #include "pub_core_libcfile.h"
45 #include "pub_core_libcprint.h"
46 #include "pub_core_libcproc.h"
47 #include "pub_core_libcsignal.h"
48 #include "pub_core_machine.h"
49 #include "pub_core_mallocfree.h"
50 #include "pub_core_tooliface.h"
51 #include "pub_core_options.h"
52 #include "pub_core_scheduler.h"
53 #include "pub_core_signals.h"
54 #include "pub_core_stacks.h"
55 #include "pub_core_syscall.h"
56 #include "pub_core_syswrap.h"
57 #include "pub_core_inner.h"
58 #if defined(ENABLE_INNER_CLIENT_REQUEST)
59 #include "pub_core_clreq.h"
62 #include "priv_types_n_macros.h"
63 #include "priv_syswrap-generic.h"
64 #include "priv_syswrap-main.h"
65 #include "priv_syswrap-freebsd.h"
67 static Bool capabiltyMode
= False
;
69 Bool
VG_(get_capability_mode
)(void)
75 // Run a thread from beginning to end and return the thread's
76 // scheduler-return-code.
77 static VgSchedReturnCode
thread_wrapper(Word
/*ThreadId*/ tidW
)
79 VgSchedReturnCode ret
;
80 ThreadId tid
= (ThreadId
)tidW
;
81 Int lwpid
= VG_(gettid
)();
82 ThreadState
* tst
= VG_(get_ThreadState
)(tid
);
84 VG_(debugLog
)(1, "syswrap-freebsd",
85 "thread_wrapper(tid=%u,lwpid=%d): entry\n",
88 vg_assert(tst
->status
== VgTs_Init
);
90 /* make sure we get the CPU lock before doing anything significant */
91 VG_(acquire_BigLock
)(tid
, "thread_wrapper(starting new thread)");
94 VG_(printf
)("thread tid %u started: stack = %p\n",
97 /* Make sure error reporting is enabled in the new thread. */
98 tst
->err_disablement_level
= 0;
100 VG_TRACK(pre_thread_first_insn
, tid
);
102 tst
->os_state
.lwpid
= lwpid
;
103 /* Set the threadgroup for real. This overwrites the provisional value set
104 in do_clone(). See comments in do_clone for background, also #226116. */
105 tst
->os_state
.threadgroup
= VG_(getpid
)();
107 /* Thread created with all signals blocked; scheduler will set the
110 ret
= VG_(scheduler
)(tid
);
112 vg_assert(VG_(is_exiting
)(tid
));
114 vg_assert(tst
->status
== VgTs_Runnable
);
115 vg_assert(VG_(is_running_thread
)(tid
));
117 VG_(debugLog
)(1, "syswrap-freebsd",
118 "thread_wrapper(tid=%u,lwpid=%d): exit, schedreturncode %s\n",
119 tid
, lwpid
, VG_(name_of_VgSchedReturnCode
)(ret
));
121 /* Return to caller, still holding the lock. */
126 /* ---------------------------------------------------------------------
128 ------------------------------------------------------------------ */
130 /* Run a thread all the way to the end, then do appropriate exit actions
131 (this is the last-one-out-turn-off-the-lights bit). */
132 __attribute__((noreturn
))
133 static void run_a_thread_NORETURN ( Word tidW
)
135 ThreadId tid
= (ThreadId
)tidW
;
136 VgSchedReturnCode src
;
139 #ifdef ENABLE_INNER_CLIENT_REQUEST
140 Int registered_vgstack_id
;
143 VG_(debugLog
)(1, "syswrap-freebsd",
144 "run_a_thread_NORETURN(tid=%u): pre-thread_wrapper\n",
147 tst
= VG_(get_ThreadState
)(tid
);
150 /* An thread has two stacks:
151 * the simulated stack (used by the synthetic cpu. Guest process
152 is using this stack).
153 * the valgrind stack (used by the real cpu. Valgrind code is running
155 When Valgrind runs as an inner, it must signals that its (real) stack
156 is the stack to use by the outer to e.g. do stacktraces.
159 (registered_vgstack_id
160 = VALGRIND_STACK_REGISTER (tst
->os_state
.valgrind_stack_base
,
161 tst
->os_state
.valgrind_stack_init_SP
));
163 /* Run the thread all the way through. */
164 src
= thread_wrapper(tid
);
166 VG_(debugLog
)(1, "syswrap-freebsd",
167 "run_a_thread_NORETURN(tid=%u): post-thread_wrapper\n",
170 c
= VG_(count_living_threads
)();
171 vg_assert(c
>= 1); /* stay sane */
173 /* Deregister thread's stack. */
174 if (tst
->os_state
.stk_id
!= NULL_STK_ID
)
175 VG_(deregister_stack
)(tst
->os_state
.stk_id
);
177 // Tell the tool this thread is exiting
178 VG_TRACK( pre_thread_ll_exit
, tid
);
180 /* If the thread is exiting with errors disabled, complain loudly;
181 doing so is bad (does the user know this has happened?) Also,
182 in all cases, be paranoid and clear the flag anyway so that the
183 thread slot is safe in this respect if later reallocated. This
184 should be unnecessary since the flag should be cleared when the
185 slot is reallocated, in thread_wrapper(). */
186 if (tst
->err_disablement_level
> 0) {
188 "WARNING: exiting thread has error reporting disabled.\n"
189 "WARNING: possibly as a result of some mistake in the use\n"
190 "WARNING: of the VALGRIND_DISABLE_ERROR_REPORTING macros.\n"
193 1, "syswrap-freebsd",
194 "run_a_thread_NORETURN(tid=%u): "
195 "WARNING: exiting thread has err_disablement_level = %u\n",
196 tid
, tst
->err_disablement_level
199 tst
->err_disablement_level
= 0;
203 VG_(debugLog
)(1, "syswrap-freebsd",
204 "run_a_thread_NORETURN(tid=%u): "
205 "last one standing\n",
208 /* We are the last one standing. Keep hold of the lock and
209 carry on to show final tool results, then exit the entire system.
210 Use the continuation pointer set at startup in m_main. */
211 ( * VG_(address_of_m_main_shutdown_actions_NORETURN
) ) (tid
, src
);
214 VG_(debugLog
)(1, "syswrap-freebsd",
215 "run_a_thread_NORETURN(tid=%u): "
216 "not last one standing\n",
219 /* OK, thread is dead, but others still exist. Just exit. */
221 /* This releases the run lock */
222 VG_(exit_thread
)(tid
);
223 vg_assert(tst
->status
== VgTs_Zombie
);
224 vg_assert(sizeof(tst
->status
) == 4);
225 vg_assert(sizeof(tst
->os_state
.exitcode
) == sizeof(Word
));
227 INNER_REQUEST (VALGRIND_STACK_DEREGISTER (registered_vgstack_id
));
229 /* We have to use this sequence to terminate the thread to
230 prevent a subtle race. If VG_(exit_thread)() had left the
231 ThreadState as Empty, then it could have been reallocated,
232 reusing the stack while we're doing these last cleanups.
233 Instead, VG_(exit_thread) leaves it as Zombie to prevent
234 reallocation. We need to make sure we don't touch the stack
235 between marking it Empty and exiting. Hence the
237 #if defined(VGP_x86_freebsd) /* FreeBSD has args on the stack */
239 "movl %1, %0\n" /* set tst->status = VgTs_Empty */
240 "movl %2, %%eax\n" /* set %eax = __NR_thr_exit */
241 "movl %3, %%ebx\n" /* set %ebx = tst->os_state.exitcode */
242 "pushl %%ebx\n" /* arg on stack */
243 "pushl %%ebx\n" /* fake return address */
244 "int $0x80\n" /* thr_exit(tst->os_state.exitcode) */
245 "popl %%ebx\n" /* fake return address */
246 "popl %%ebx\n" /* arg off stack */
248 : "n" (VgTs_Empty
), "n" (__NR_thr_exit
), "m" (tst
->os_state
.exitcode
)
251 #elif defined(VGP_amd64_freebsd)
253 "movl %1, %0\n" /* set tst->status = VgTs_Empty */
254 "movq %2, %%rax\n" /* set %rax = __NR_thr_exit */
255 "movq %3, %%rdi\n" /* set %rdi = tst->os_state.exitcode */
256 "pushq %%rdi\n" /* fake return address */
257 "syscall\n" /* thr_exit(tst->os_state.exitcode) */
258 "popq %%rdi\n" /* fake return address */
260 : "n" (VgTs_Empty
), "n" (__NR_thr_exit
), "m" (tst
->os_state
.exitcode
)
264 # error Unknown platform
267 VG_(core_panic
)("Thread exit failed?\n");
274 Word
ML_(start_thread_NORETURN
) ( void* arg
)
276 ThreadState
* tst
= (ThreadState
*)arg
;
277 ThreadId tid
= tst
->tid
;
279 run_a_thread_NORETURN ( (Word
)tid
);
284 /* Allocate a stack for this thread, if it doesn't already have one.
285 They're allocated lazily, and never freed. Returns the initial stack
286 pointer value to use, or 0 if allocation failed. */
287 Addr
ML_(allocstack
)(ThreadId tid
)
289 ThreadState
* tst
= VG_(get_ThreadState
)(tid
);
293 /* Either the stack_base and stack_init_SP are both zero (in which
294 case a stack hasn't been allocated) or they are both non-zero,
295 in which case it has. */
297 if (tst
->os_state
.valgrind_stack_base
== 0)
298 vg_assert(tst
->os_state
.valgrind_stack_init_SP
== 0);
300 if (tst
->os_state
.valgrind_stack_base
!= 0)
301 vg_assert(tst
->os_state
.valgrind_stack_init_SP
!= 0);
303 /* If no stack is present, allocate one. */
305 if (tst
->os_state
.valgrind_stack_base
== 0) {
306 stack
= VG_(am_alloc_VgStack
)( &initial_SP
);
308 tst
->os_state
.valgrind_stack_base
= (Addr
)stack
;
309 tst
->os_state
.valgrind_stack_init_SP
= initial_SP
;
314 VG_(printf
)( "stack for tid %u at %p; init_SP=%p\n",
316 (void*)tst
->os_state
.valgrind_stack_base
,
317 (void*)tst
->os_state
.valgrind_stack_init_SP
);
319 return tst
->os_state
.valgrind_stack_init_SP
;
322 /* Allocate a stack for the main thread, and run it all the way to the
323 end. Although we already have a working VgStack
324 (VG_(interim_stack)) it's better to allocate a new one, so that
325 overflow detection works uniformly for all threads.
327 __attribute__((noreturn
))
328 void VG_(main_thread_wrapper_NORETURN
)(ThreadId tid
)
331 VG_(debugLog
)(1, "syswrap-freebsd",
332 "entering VG_(main_thread_wrapper_NORETURN)\n");
334 sp
= ML_(allocstack
)(tid
);
335 #if defined(ENABLE_INNER_CLIENT_REQUEST)
337 // we must register the main thread stack before the call
338 // to ML_(call_on_new_stack_0_1), otherwise the outer valgrind
339 // reports 'write error' on the non registered stack.
340 ThreadState
* tst
= VG_(get_ThreadState
)(tid
);
343 VALGRIND_STACK_REGISTER (tst
->os_state
.valgrind_stack_base
,
344 tst
->os_state
.valgrind_stack_init_SP
));
348 /* If we can't even allocate the first thread's stack, we're hosed.
350 vg_assert2(sp
!= 0, "%s", "Cannot allocate main thread's stack.");
352 /* shouldn't be any other threads around yet */
353 vg_assert( VG_(count_living_threads
)() == 1 );
355 ML_(call_on_new_stack_0_1
)(
356 (Addr
)sp
, /* stack */
357 0, /* bogus return address */
358 run_a_thread_NORETURN
, /* fn to call */
359 (Word
)tid
/* arg to give it */
368 SysRes
ML_(do_fork
) ( ThreadId tid
)
370 vki_sigset_t fork_saved_mask
;
374 /* Block all signals during fork, so that we can fix things up in
375 the child without being interrupted. */
376 VG_(sigfillset
)(&mask
);
377 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &mask
, &fork_saved_mask
);
379 VG_(do_atfork_pre
)(tid
);
381 res
= VG_(do_syscall0
)( __NR_fork
);
383 if (!sr_isError(res
)) {
384 if (sr_Res(res
) == 0) {
386 VG_(do_atfork_child
)(tid
);
388 /* restore signal mask */
389 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &fork_saved_mask
, NULL
);
393 VG_(do_atfork_parent
)(tid
);
395 if (VG_(clo_trace_syscalls
))
396 VG_(printf
)(" clone(fork): process %d created child %lu\n",
397 VG_(getpid
)(), sr_Res(res
));
399 /* restore signal mask */
400 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &fork_saved_mask
, NULL
);
407 static Addr
ML_(make_safe_mask
) ( const HChar
* malloc_message
, Addr mask_pointer
)
409 vki_sigset_t
* new_mask
;
410 const vki_sigset_t
* old_mask
= (vki_sigset_t
*)mask_pointer
;
412 if (!ML_(safe_to_deref
)(old_mask
, sizeof(vki_sigset_t
))) {
413 new_mask
= (vki_sigset_t
*)1; /* Something recognisable to POST() hook. */
415 new_mask
= VG_(malloc
)(malloc_message
, sizeof(vki_sigset_t
));
416 *new_mask
= *old_mask
;
417 VG_(sanitize_client_sigmask
)(new_mask
);
420 return (Addr
)new_mask
;
423 static void ML_(free_safe_mask
) ( Addr mask_pointer
)
425 if (mask_pointer
!= 0 && mask_pointer
!= 1) {
426 VG_(free
)((vki_sigset_t
*) mask_pointer
);
431 /* ---------------------------------------------------------------------
432 PRE/POST wrappers for arch-generic, FreeBSD-specific syscalls
433 ------------------------------------------------------------------ */
435 // Nb: See the comment above the generic PRE/POST wrappers in
436 // m_syswrap/syswrap-generic.c for notes about how they work.
438 #define PRE(name) DEFN_PRE_TEMPLATE(freebsd, name)
439 #define POST(name) DEFN_POST_TEMPLATE(freebsd, name)
441 /* On FreeBSD, if any thread calls exit(2), then they are all shut down, pretty
442 * much like linux's exit_group().
445 // void exit(int status);
450 PRINT("exit( %" FMT_REGWORD
"u )", ARG1
);
451 PRE_REG_READ1(void, "exit", int, status
);
453 /* Mark all threads (including this one) to exit. */
454 for (t
= 1; t
< VG_N_THREADS
; t
++) {
455 if ( /* not alive */ VG_(threads
)[t
].status
== VgTs_Empty
)
458 //VG_(threads)[t].exitreason = VgSrc_ExitThread;
459 VG_(threads
)[t
].os_state
.exitcode
= ARG1
;
462 // VG_(get_thread_out_of_syscall)(t); /* unblock it, if blocked */
465 VG_(nuke_all_threads_except
)( tid
, VgSrc_ExitProcess
);
466 VG_(reap_threads
)(tid
);
467 VG_(threads
)[tid
].exitreason
= VgSrc_ExitThread
;
469 /* We have to claim the syscall already succeeded. */
470 SET_STATUS_Success(0);
477 PRINT("%s", "sys_fork ()");
478 PRE_REG_READ0(pid_t
, "fork");
480 SET_STATUS_from_SysRes( ML_(do_fork
)(tid
) );
482 /* Thread creation was successful; let the child have the chance
484 *flags
|= SfYieldAfter
;
514 // SYS_freebsd11_mknod 14
530 // int mount(const char *type, const char *dir, int flags, void *data);
533 // Nb: depending on 'flags', the 'type' and 'data' args may be ignored.
534 // We are conservative and check everything, except the memory pointed to
536 *flags
|= SfMayBlock
;
537 PRINT( "sys_mount( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )",ARG1
,ARG2
,ARG3
,ARG4
);
538 PRE_REG_READ4(int, "mount",
539 const char *, type
, char *, dir
, int, flags
,
541 PRE_MEM_RASCIIZ( "mount(type)", ARG1
);
542 PRE_MEM_RASCIIZ( "mount(path)", ARG2
);
546 // int unmount(const char *dir, int flags);
549 PRINT("sys_umount( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
, ARG2
);
550 PRE_REG_READ2(int, "unmount", const char *, dir
, int, flags
);
551 PRE_MEM_RASCIIZ( "unmount(path)", ARG1
);
564 // int ptrace(int request, pid_t pid, caddr_t addr, int data);
567 struct vki_ptrace_io_desc
*io_desc
;
568 PRINT("sys_ptrace ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, 0x%" FMT_REGWORD
"x, %" FMT_REGWORD
"u)", ARG1
, ARG2
, ARG3
, ARG4
);
570 PRE_REG_READ4(int, "ptrace", int, request
, pid_t
, pid
, caddr_t
, addr
, int, data
);
573 case VKI_PTRACE_TRACEME
:
575 case VKI_PTRACE_READ_I
:
576 case VKI_PTRACE_READ_D
:
579 case VKI_PTRACE_WRITE_I
:
580 case VKI_PTRACE_WRITE_D
:
584 PRE_MEM_READ("ptrace", ARG3
, sizeof(struct vki_ptrace_io_desc
));
585 io_desc
= (struct vki_ptrace_io_desc
*)ARG3
;
586 switch (io_desc
->piod_op
) {
587 case VKI_PIOD_READ_D
:
588 case VKI_PIOD_READ_I
:
589 PRE_MEM_WRITE( "ptrace", (UWord
)io_desc
->piod_addr
, io_desc
->piod_len
);
591 case VKI_PIOD_WRITE_D
:
592 case VKI_PIOD_WRITE_I
:
593 PRE_MEM_READ( "ptrace", (UWord
)io_desc
->piod_addr
, io_desc
->piod_len
);
598 case VKI_PTRACE_CONTINUE
:
601 case VKI_PTRACE_STEP
:
604 case VKI_PTRACE_KILL
:
607 case VKI_PTRACE_ATTACH
:
610 case VKI_PTRACE_DETACH
:
613 case VKI_PTRACE_GETREGS
:
614 PRE_MEM_WRITE( "ptrace", ARG3
, sizeof(struct vki_user_regs_struct
));
617 case VKI_PTRACE_SETREGS
:
618 PRE_MEM_READ( "ptrace", ARG3
, sizeof(struct vki_user_regs_struct
));
621 case VKI_PTRACE_GETFPREGS
:
622 PRE_MEM_WRITE( "ptrace", ARG3
, sizeof(struct vki_fpreg
));
625 case VKI_PTRACE_SETFPREGS
:
626 PRE_MEM_READ( "ptrace", ARG3
, sizeof(struct vki_fpreg
));
629 case VKI_PTRACE_GETDBREGS
:
630 PRE_MEM_WRITE( "ptrace", ARG3
, sizeof(struct vki_dbreg
));
633 case VKI_PTRACE_SETDBREGS
:
634 PRE_MEM_READ( "ptrace", ARG3
, sizeof(struct vki_dbreg
));
637 case VKI_PTRACE_LWPINFO
:
638 PRE_MEM_WRITE( "ptrace", ARG3
, sizeof(struct vki_ptrace_lwpinfo
));
641 case VKI_PTRACE_GETNUMLWPS
:
644 case VKI_PTRACE_GETLWPLIST
:
645 PRE_MEM_WRITE( "ptrace", ARG3
, sizeof(vki_lwpid_t
) * ARG4
);
648 case VKI_PTRACE_SETSTEP
:
651 case VKI_PTRACE_CLEARSTEP
:
654 case VKI_PTRACE_SUSPEND
:
657 case VKI_PTRACE_RESUME
:
660 case VKI_PTRACE_TO_SCE
:
663 case VKI_PTRACE_TO_SCX
:
666 case VKI_PTRACE_SYSCALL
:
669 case VKI_PTRACE_VM_TIMESTAMP
:
672 case VKI_PTRACE_VM_ENTRY
:
673 PRE_MEM_WRITE( "ptrace", ARG3
, sizeof(struct vki_ptrace_vm_entry
));
680 struct vki_ptrace_io_desc
*io_desc
;
683 case VKI_PTRACE_TRACEME
:
685 case VKI_PTRACE_READ_I
:
686 case VKI_PTRACE_READ_D
:
689 case VKI_PTRACE_WRITE_I
:
690 case VKI_PTRACE_WRITE_D
:
694 io_desc
= (struct vki_ptrace_io_desc
*)ARG3
;
695 switch (io_desc
->piod_op
) {
696 case VKI_PIOD_READ_D
:
697 case VKI_PIOD_READ_I
:
699 POST_MEM_WRITE((UWord
)io_desc
->piod_addr
, io_desc
->piod_len
);
701 case VKI_PIOD_WRITE_D
:
702 case VKI_PIOD_WRITE_I
:
707 case VKI_PTRACE_CONTINUE
:
710 case VKI_PTRACE_STEP
:
713 case VKI_PTRACE_KILL
:
716 case VKI_PTRACE_ATTACH
:
719 case VKI_PTRACE_DETACH
:
722 case VKI_PTRACE_GETREGS
:
724 POST_MEM_WRITE(ARG3
, sizeof(struct vki_user_regs_struct
));
727 case VKI_PTRACE_SETREGS
:
730 case VKI_PTRACE_GETFPREGS
:
732 POST_MEM_WRITE(ARG3
, sizeof(struct vki_fpreg
));
735 case VKI_PTRACE_SETFPREGS
:
738 case VKI_PTRACE_GETDBREGS
:
740 POST_MEM_WRITE(ARG3
, sizeof(struct vki_dbreg
));
743 case VKI_PTRACE_SETDBREGS
:
746 case VKI_PTRACE_LWPINFO
:
748 POST_MEM_WRITE(ARG3
, sizeof(struct vki_ptrace_lwpinfo
));
751 case VKI_PTRACE_GETNUMLWPS
:
754 case VKI_PTRACE_GETLWPLIST
:
756 POST_MEM_WRITE(ARG3
, sizeof(vki_lwpid_t
) * RES
);
759 case VKI_PTRACE_SETSTEP
:
762 case VKI_PTRACE_CLEARSTEP
:
765 case VKI_PTRACE_SUSPEND
:
768 case VKI_PTRACE_RESUME
:
771 case VKI_PTRACE_TO_SCE
:
774 case VKI_PTRACE_TO_SCX
:
777 case VKI_PTRACE_SYSCALL
:
780 case VKI_PTRACE_VM_TIMESTAMP
:
783 case VKI_PTRACE_VM_ENTRY
:
785 POST_MEM_WRITE(ARG3
, sizeof(struct vki_ptrace_vm_entry
));
791 // ssize_t recvmsg(int s, struct msghdr *msg, int flags);
794 *flags
|= SfMayBlock
;
795 PRINT("sys_recvmsg ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d )",SARG1
,ARG2
,SARG3
);
796 PRE_REG_READ3(vki_ssize_t
, "recvmsg", int, s
, struct msghdr
*, msg
, int, flags
);
797 ML_(generic_PRE_sys_recvmsg
)(tid
, "recvmsg", (struct vki_msghdr
*)ARG2
);
803 ML_(generic_POST_sys_recvmsg
)(tid
, "recvmsg", (struct vki_msghdr
*)ARG2
, RES
);
807 // ssize_t sendmsg(int s, const struct msghdr *msg, int flags);
810 *flags
|= SfMayBlock
;
811 PRINT("sys_sendmsg ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
812 PRE_REG_READ3(ssize_t
, "sendmsg",
813 int, s
, const struct msghdr
*, msg
, int, flags
);
814 ML_(generic_PRE_sys_sendmsg
)(tid
, "sendmsg", (struct vki_msghdr
*)ARG2
);
818 // ssize_t recvfrom(int s, void *buf, size_t len, int flags,
819 // struct sockaddr * restrict from, socklen_t * restrict fromlen);
822 *flags
|= SfMayBlock
;
823 PRINT("sys_recvfrom ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",SARG1
,ARG2
,ARG3
,SARG4
,ARG5
,ARG6
);
824 PRE_REG_READ6(ssize_t
, "recvfrom",
825 int, s
, void *, buf
, size_t, len
, int, flags
,
826 struct sockaddr
*, from
, int *, fromlen
);
827 ML_(generic_PRE_sys_recvfrom
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
833 ML_(generic_POST_sys_recvfrom
)(tid
, VG_(mk_SysRes_Success
)(RES
),
834 ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
838 // int accept(int s, struct sockaddr * restrict addr,
839 // socklen_t * restrict addrlen);
842 *flags
|= SfMayBlock
;
843 PRINT("sys_accept ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
844 PRE_REG_READ3(int, "accept",
845 int, s
, struct sockaddr
*, addr
, int, *addrlen
);
846 ML_(generic_PRE_sys_accept
)(tid
, ARG1
,ARG2
,ARG3
);
853 r
= ML_(generic_POST_sys_accept
)(tid
, VG_(mk_SysRes_Success
)(RES
),
855 SET_STATUS_from_SysRes(r
);
858 // SYS_getpeername 31
859 // int getpeername(int s, struct sockaddr * restrict name,
860 // socklen_t * restrict namelen);
863 PRINT("sys_getpeername ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",ARG1
,ARG2
,ARG3
);
864 PRE_REG_READ3(int, "getpeername",
865 int, s
, struct sockaddr
*, name
, socklen_t
*, namelen
);
866 ML_(generic_PRE_sys_getpeername
)(tid
, ARG1
,ARG2
,ARG3
);
869 POST(sys_getpeername
)
872 ML_(generic_POST_sys_getpeername
)(tid
, VG_(mk_SysRes_Success
)(RES
),
876 // SYS_getsockname 32
877 // int getsockname(int s, struct sockaddr * restrict name,
878 // socklen_t * restrict namelen);
881 PRINT("sys_getsockname ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",SARG1
,ARG2
,ARG3
);
882 PRE_REG_READ3(long, "getsockname",
883 int, s
, struct sockaddr
*, name
, int *, namelen
);
884 ML_(generic_PRE_sys_getsockname
)(tid
, ARG1
,ARG2
,ARG3
);
887 POST(sys_getsockname
)
890 ML_(generic_POST_sys_getsockname
)(tid
, VG_(mk_SysRes_Success
)(RES
),
898 // int chflags(const char *path, unsigned long flags)
901 PRINT("sys_chflags ( %#" FMT_REGWORD
"x(%s), 0x%" FMT_REGWORD
"x )", ARG1
,(char *)ARG1
,ARG2
);
902 PRE_REG_READ2(int, "chflags",
903 const char *, path
, unsigned long, flags
);
904 PRE_MEM_RASCIIZ( "chflags(path)", ARG1
);
908 // int fchflags(int fd, unsigned long flags);
911 PRINT("sys_fchflags ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )", ARG1
,ARG2
);
912 PRE_REG_READ2(int, "fchflags", int, fd
, unsigned long, flags
);
927 // Pipe on freebsd doesn't have args, and uses dual returns!
928 // SYS_freebsd10_pipe 42
932 PRINT("%s", "sys_pipe ()");
937 if (!ML_(fd_allowed
)(RES
, "pipe", tid
, True
) ||
938 !ML_(fd_allowed
)(RESHI
, "pipe", tid
, True
)) {
941 SET_STATUS_Failure( VKI_EMFILE
);
943 if (VG_(clo_track_fds
)) {
944 ML_(record_fd_open_nameless
)(tid
, RES
);
945 ML_(record_fd_open_nameless
)(tid
, RESHI
);
963 // syscall.master refers to namelen and namebuf for the argument names
964 // man getlogin has just getlogin(void) but also
965 // int getlogin_r(char *name, int len);
966 // so let's go with those names
969 PRINT("sys_getlogin ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",ARG1
,ARG2
);
970 PRE_REG_READ2(int, "getlogin", char *, buf
, u_int
, len
);
971 PRE_MEM_WRITE( "getlogin(name)", ARG1
, ARG2
);
976 POST_MEM_WRITE(ARG1
, ARG2
);
980 // int setlogin(const char *name);
983 PRINT("sys_setlogin ( %#" FMT_REGWORD
"x )",ARG1
);
984 PRE_REG_READ1(long, "setlogin", char *, buf
);
985 PRE_MEM_RASCIIZ( "setlogin(buf)", ARG1
);
991 // SYS_sigaltstack 53
995 // int ioctl(int fd, unsigned long request, ...);
998 UInt dir
= _VKI_IOC_DIR(ARG2
);
999 UInt size
= _VKI_IOC_SIZE(ARG2
);
1000 *flags
|= SfMayBlock
;
1001 // @todo PJF presumably the presence of ARG3 depends on ARG2
1002 PRINT("sys_ioctl ( %" FMT_REGWORD
"u, 0x%" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",ARG1
,ARG2
,ARG3
);
1003 PRE_REG_READ3(int, "ioctl",
1004 int, fd
, unsigned long, request
, unsigned long, arg
);
1006 /* On FreeBSD, ALL ioctl's are IOR/IOW encoded. Just use the default decoder */
1007 if (SimHintiS(SimHint_lax_ioctls
, VG_(clo_sim_hints
))) {
1009 * Be very lax about ioctl handling; the only
1010 * assumption is that the size is correct. Doesn't
1011 * require the full buffer to be initialized when
1012 * writing. Without this, using some device
1013 * drivers with a large number of strange ioctl
1014 * commands becomes very tiresome.
1016 } else if (dir
== _VKI_IOC_NONE
&& size
> 0) {
1017 static UWord unknown_ioctl
[10];
1018 static Int moans
= sizeof(unknown_ioctl
) / sizeof(unknown_ioctl
[0]);
1019 if (moans
> 0 && !VG_(clo_xml
)) {
1020 /* Check if have not already moaned for this request. */
1022 for (i
= 0; i
< sizeof(unknown_ioctl
)/sizeof(unknown_ioctl
[0]); i
++) {
1023 if (unknown_ioctl
[i
] == ARG2
)
1025 if (unknown_ioctl
[i
] == 0) {
1026 unknown_ioctl
[i
] = ARG2
;
1028 VG_(umsg
)("Warning: noted but unhandled ioctl 0x%lx"
1029 " with no direction hints.\n", ARG2
);
1030 VG_(umsg
)(" This could cause spurious value errors to appear.\n");
1031 VG_(umsg
)(" See README_MISSING_SYSCALL_OR_IOCTL for "
1032 "guidance on writing a proper wrapper.\n" );
1038 if ((dir
& _VKI_IOC_WRITE
) && size
> 0)
1039 PRE_MEM_READ( "ioctl(generic)", ARG3
, size
);
1040 if ((dir
& _VKI_IOC_READ
) && size
> 0)
1041 PRE_MEM_WRITE( "ioctl(generic)", ARG3
, size
);
1044 // The block below is from Ryan Stone
1045 // https://bitbucket.org/rysto32/valgrind-freebsd/commits/5323c22be9f6c71a00e842c3ddfa1fa8a7feb279
1046 // however it drags in hundreds of lines of headers into vki-freebsd.h.
1047 // How stable are these structures? -> maintainability is a concern
1048 // Also there are no testcases for this.
1051 /* Handle specific ioctls which pass structures which may have pointers to other
1053 switch (ARG2
/* request */) {
1054 case VKI_SIOCGIFMEDIA
:
1056 struct vki_ifmediareq
* imr
= (struct vki_ifmediareq
*)ARG3
;
1057 if (imr
->ifm_ulist
) {
1058 PRE_MEM_WRITE("ioctl(SIOCGIFMEDIA).ifm_ulist",
1059 (Addr
)(imr
->ifm_ulist
), imr
->ifm_count
* sizeof(int));
1064 case VKI_PCIOCGETCONF
:
1066 struct vki_pci_conf_io
* pci
= (struct vki_pci_conf_io
*)ARG3
;
1067 PRE_MEM_READ("ioctl(PCIOCGETCONF).patterns",
1068 (Addr
)(pci
->patterns
), pci
->pat_buf_len
);
1069 PRE_MEM_WRITE("ioctl(PCIOCGETCONF).matches",
1070 (Addr
)(pci
->matches
), pci
->match_buf_len
);
1074 case VKI_CAMIOCOMMAND
:
1076 union vki_ccb
* ccb
= (union vki_ccb
*)ARG3
;
1077 if (ccb
->ccb_h
.func_code
== VKI_XPT_DEV_MATCH
) {
1078 PRE_MEM_WRITE("ioctl(CAMIOCOMMAND:XPT_DEV_MATCH).matches",
1079 (Addr
)(ccb
->cdm
.matches
), ccb
->cdm
.match_buf_len
);
1080 } else if (ccb
->ccb_h
.func_code
== VKI_XPT_SCSI_IO
) {
1081 struct vki_ccb_scsiio
* scsiio
= (struct vki_ccb_scsiio
*)ccb
;
1082 if (scsiio
->dxfer_len
) {
1083 if ((scsiio
->ccb_h
.flags
& VKI_CAM_DIR_MASK
) == VKI_CAM_DIR_IN
) {
1084 PRE_MEM_WRITE("ioctl(CAMIOCOMMAND:XPT_SCSI_IO).data_ptr",
1085 (Addr
)(scsiio
->data_ptr
), scsiio
->dxfer_len
);
1086 } else if ((scsiio
->ccb_h
.flags
& VKI_CAM_DIR_MASK
) == VKI_CAM_DIR_OUT
) {
1087 PRE_MEM_READ("ioctl(CAMIOCOMMAND:XPT_SCSI_IO).data_ptr",
1088 (Addr
)(scsiio
->data_ptr
), scsiio
->dxfer_len
);
1091 } else if (ccb
->ccb_h
.func_code
== VKI_XPT_GDEV_TYPE
||
1092 ccb
->ccb_h
.func_code
== VKI_XPT_PATH_INQ
||
1093 ccb
->ccb_h
.func_code
== VKI_XPT_GET_TRAN_SETTINGS
) {
1096 VG_(message
)(Vg_UserMsg
,
1097 "Warning: unhandled ioctl CAMIOCOMMAND function 0x%lx\n",
1098 ccb
->ccb_h
.func_code
);
1108 UInt dir
= _VKI_IOC_DIR(ARG2
);
1109 UInt size
= _VKI_IOC_SIZE(ARG2
);
1111 if (size
> 0 && (dir
& _VKI_IOC_READ
)
1112 && RES
== 0 && ARG3
!= (Addr
)NULL
)
1113 POST_MEM_WRITE(ARG3
, size
);
1116 /* Handle specific ioctls which pass structures which may have pointers to other
1118 switch (ARG2
/* request */) {
1119 case VKI_SIOCGIFMEDIA
:
1121 struct vki_ifmediareq
* imr
= (struct vki_ifmediareq
*)ARG3
;
1122 if (imr
->ifm_ulist
) {
1123 POST_MEM_WRITE((Addr
)(imr
->ifm_ulist
), imr
->ifm_count
* sizeof(int));
1128 case VKI_PCIOCGETCONF
:
1130 struct vki_pci_conf_io
* pci
= (struct vki_pci_conf_io
*)ARG3
;
1131 POST_MEM_WRITE((Addr
)(pci
->matches
), pci
->num_matches
* sizeof(struct vki_pci_conf
));
1135 case VKI_CAMIOCOMMAND
:
1137 union vki_ccb
* ccb
= (union vki_ccb
*)ARG3
;
1138 if (ccb
->ccb_h
.func_code
== VKI_XPT_DEV_MATCH
) {
1139 POST_MEM_WRITE((Addr
)(ccb
->cdm
.matches
), ccb
->cdm
.num_matches
*sizeof(struct vki_dev_match_result
));
1140 } else if (ccb
->ccb_h
.func_code
== VKI_XPT_SCSI_IO
) {
1141 struct vki_ccb_scsiio
* scsiio
= (struct vki_ccb_scsiio
*)ccb
;
1142 if (scsiio
->dxfer_len
) {
1143 if ((scsiio
->ccb_h
.flags
& VKI_CAM_DIR_MASK
) == VKI_CAM_DIR_IN
) {
1144 POST_MEM_WRITE((Addr
)(scsiio
->data_ptr
), scsiio
->dxfer_len
);
1155 // int reboot(int howto);
1158 PRINT("sys_reboot ( %" FMT_REGWORD
"d )", SARG1
);
1159 PRE_REG_READ1(int, "reboot", int, howto
);
1163 // int revoke(const char *path);
1166 PRINT("sys_revoke ( %#" FMT_REGWORD
"x(%s) )", ARG1
, (char*)ARG1
);
1167 PRE_REG_READ1(long, "revoke", const char *, path
);
1168 PRE_MEM_RASCIIZ( "revoke(path)", ARG1
);
1190 // pid_t vfork(void);
1193 PRINT("%s", "sys_vfork ()");
1194 PRE_REG_READ0(pid_t
, "vfork");
1196 /* Pretend vfork == fork. Not true, but will have to do. */
1197 SET_STATUS_from_SysRes( ML_(do_fork
)(tid
) );
1199 /* Thread creation was successful; let the child have the chance
1201 *flags
|= SfYieldAfter
;
1206 // void * sbrk(intptr_t incr);
1209 PRINT("sys_sbrk ( %#" FMT_REGWORD
"x )",ARG1
);
1210 PRE_REG_READ1(void*, "sbrk", vki_intptr_t
, incr
);
1213 // SYS_freebsd11_vadvise 72
1244 // int swapon(const char *special);
1247 PRINT("sys_swapon ( %#" FMT_REGWORD
"x(%s) )", ARG1
,(char*)ARG1
);
1248 PRE_REG_READ1(int, "swapon", const char*, special
);
1249 PRE_MEM_RASCIIZ( "swapon(special)", ARG1
);
1255 // SYS_getdtablesize 89
1256 // int getdtablesize(void);
1257 PRE(sys_getdtablesize
)
1259 PRINT("%s", "sys_getdtablesize ( )");
1260 PRE_REG_READ0(long, "getdtablesize");
1267 // int fcntl(int fd, int cmd, ...);
1271 // These ones ignore ARG3.
1275 case VKI_F_GET_SEALS
:
1276 case VKI_F_ISUNIONSTACK
:
1277 PRINT("sys_fcntl ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d )", SARG1
,SARG2
);
1278 PRE_REG_READ2(int, "fcntl", int, fd
, int, cmd
);
1281 // These ones use ARG3 as "arg".
1283 case VKI_F_DUPFD_CLOEXEC
:
1287 case VKI_F_READAHEAD
:
1289 case VKI_F_ADD_SEALS
:
1290 PRINT("sys_fcntl[ARG3=='arg'] ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %" FMT_REGWORD
"d )", SARG1
,SARG2
,SARG3
);
1291 PRE_REG_READ3(int, "fcntl",
1292 int, fd
, int, cmd
, int, arg
);
1295 // These ones use ARG3 as "lock" - obsolete.
1297 *flags
|= SfMayBlock
;
1301 PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
,ARG3
);
1302 PRE_REG_READ3(int, "fcntl",
1304 struct oflock
*, lock
);
1307 // This one uses ARG3 as "oldd" and ARG4 as "newd".
1309 case VKI_F_DUP2FD_CLOEXEC
:
1310 PRINT("sys_fcntl[ARG3=='oldd', ARG4=='newd'] ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )",
1311 ARG1
,ARG2
,ARG3
,ARG4
);
1312 PRE_REG_READ4(int, "fcntl",
1314 unsigned long, oldd
, unsigned long, newd
);
1317 // These ones use ARG3 as "lock".
1319 *flags
|= SfMayBlock
;
1323 case VKI_F_SETLK_REMOTE
:
1324 PRINT("sys_fcntl[ARG3=='lock'] ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
,ARG3
);
1325 PRE_REG_READ3(int, "fcntl",
1327 struct flock
*, lock
);
1330 PRINT("sys_fcntl[ARG3=='kinfo_file'] ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
,ARG3
);
1331 PRE_REG_READ3(int, "fcntl",
1333 struct vki_kinfo_file
*, kinfo
);
1335 struct vki_kinfo_file
* p_kinfo_file
= (struct vki_kinfo_file
*)ARG3
;
1336 PRE_MEM_WRITE("fcntl(ARG3=='kinfo_file)", ARG3
, p_kinfo_file
->vki_kf_structsize
);
1341 PRINT("sys_fcntl[UNKNOWN] ( %lu, %lu, %lu )", ARG1
,ARG2
,ARG3
);
1349 if (ARG2
== VKI_F_DUPFD
) {
1350 if (!ML_(fd_allowed
)(RES
, "fcntl(DUPFD)", tid
, True
)) {
1352 SET_STATUS_Failure( VKI_EMFILE
);
1354 if (VG_(clo_track_fds
))
1355 ML_(record_fd_open_named
)(tid
, RES
);
1357 } else if (ARG2
== VKI_F_DUPFD_CLOEXEC
) {
1358 if (!ML_(fd_allowed
)(RES
, "fcntl(DUPFD_CLOEXEC)", tid
, True
)) {
1360 SET_STATUS_Failure( VKI_EMFILE
);
1362 if (VG_(clo_track_fds
))
1363 ML_(record_fd_open_named
)(tid
, RES
);
1374 // SYS_setpriority 9
1378 // int socket(int domain, int type, int protocol);
1381 PRINT("sys_socket ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %" FMT_REGWORD
"d )",SARG1
,SARG2
,SARG3
);
1382 PRE_REG_READ3(int, "socket", int, domain
, int, type
, int, protocol
);
1389 r
= ML_(generic_POST_sys_socket
)(tid
, VG_(mk_SysRes_Success
)(RES
));
1390 SET_STATUS_from_SysRes(r
);
1394 // int connect(int s, const struct sockaddr *name, socklen_t namelen);
1397 *flags
|= SfMayBlock
;
1398 PRINT("sys_connect ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
1399 PRE_REG_READ3(int, "connect",
1400 int, s
, const struct sockaddr
*, name
, int, namelen
);
1401 ML_(generic_PRE_sys_connect
)(tid
, ARG1
,ARG2
,ARG3
);
1404 // SYS_getpriority 100
1408 // int bind(int s, const struct sockaddr *addr, socklen_t addrlen);
1411 PRINT("sys_bind ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
1412 PRE_REG_READ3(int, "bind",
1413 int, s
, struct sockaddr
*, addr
, int, addrlen
);
1414 ML_(generic_PRE_sys_bind
)(tid
, ARG1
,ARG2
,ARG3
);
1417 // SYS_setsockopt 105
1418 // int setsockopt(int s, int level, int optname, const void *optval,
1419 // socklen_t optlen);
1422 PRINT("sys_setsockopt ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",SARG1
,SARG2
,SARG3
,ARG4
,ARG5
);
1423 PRE_REG_READ5(int, "setsockopt",
1424 int, s
, int, level
, int, optname
,
1425 const void *, optval
, vki_socklen_t
, optlen
);
1426 ML_(generic_PRE_sys_setsockopt
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
1430 // int listen(int s, int backlog);
1433 PRINT("sys_listen ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d )",SARG1
,SARG2
);
1434 PRE_REG_READ2(int, "listen", int, s
, int, backlog
);
1437 //SYS_gettimeofday 116
1440 // SYS_getrusage 117
1443 // SYS_getsockopt 118
1444 // int getsockopt(int s, int level, int optname, void * restrict optval,
1445 // socklen_t * restrict optlen);
1448 Addr optval_p
= ARG4
;
1449 Addr optlen_p
= ARG5
;
1450 PRINT("sys_getsockopt ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
1451 PRE_REG_READ5(int, "getsockopt",
1452 int, s
, int, level
, int, optname
,
1453 void *, optval
, int, *optlen
);
1454 if (optval_p
!= (Addr
)NULL
) {
1455 ML_(buf_and_len_pre_check
) ( tid
, optval_p
, optlen_p
,
1456 "getsockopt(optval)",
1457 "getsockopt(optlen)" );
1461 POST(sys_getsockopt
)
1463 Addr optval_p
= ARG4
;
1464 Addr optlen_p
= ARG5
;
1466 if (optval_p
!= (Addr
)NULL
) {
1467 ML_(buf_and_len_post_check
) ( tid
, VG_(mk_SysRes_Success
)(RES
),
1469 "getsockopt(optlen_out)" );
1479 // SYS_settimeofday 122
1501 // int mkfifo(const char *path, mode_t mode);
1504 PRINT("sys_mkfifo ( %#" FMT_REGWORD
"x(%s), 0x%" FMT_REGWORD
"x, 0x%" FMT_REGWORD
"x )", ARG1
, (char *)ARG1
, ARG2
, ARG3
);
1505 PRE_REG_READ2(int, "mkfifo", const char *, path
, int, mode
);
1506 PRE_MEM_RASCIIZ( "mkfifo(path)", ARG1
);
1510 // ssize_t sendto(int s, const void *msg, size_t len, int flags,
1511 // const struct sockaddr *to, socklen_t tolen);
1514 *flags
|= SfMayBlock
;
1515 PRINT("sys_sendto ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
1516 PRE_REG_READ6(ssize_t
, "sendto",
1517 int, s
, const void *, msg
, int, len
,
1519 const struct sockaddr
*, to
, socklen_t
, tolen
);
1520 ML_(generic_PRE_sys_sendto
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
1524 // int shutdown(int s, int how);
1527 *flags
|= SfMayBlock
;
1528 PRINT("sys_shutdown ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )",ARG1
,ARG2
);
1529 PRE_REG_READ2(int, "shutdown", int, s
, int, how
);
1532 // SYS_socketpair 135
1533 // int socketpair(int domain, int type, int protocol, int *sv);
1536 PRINT("sys_socketpair ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )",ARG1
,ARG2
,ARG3
,ARG4
);
1537 PRE_REG_READ4(int, "socketpair",
1538 int, domain
, int, type
, int, protocol
, int *, sv
);
1539 ML_(generic_PRE_sys_socketpair
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
1542 POST(sys_socketpair
)
1545 ML_(generic_POST_sys_socketpair
)(tid
, VG_(mk_SysRes_Success
)(RES
),
1546 ARG1
,ARG2
,ARG3
,ARG4
);
1559 // int adjtime(const struct timeval *delta, struct timeval *olddelta);
1562 PRINT("sys_adjtime ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",ARG1
,ARG2
);
1563 PRE_REG_READ2(int, "adjtime",
1564 const struct vki_timeval
*, delta
, struct vki_timeval
*, olddelta
);
1565 PRE_MEM_READ("adjtime(delta)", ARG1
, sizeof(struct vki_timeval
));
1567 PRE_MEM_WRITE("adjtime(olddelta)", ARG1
, sizeof(struct vki_timeval
));
1574 POST_MEM_WRITE(ARG1
, sizeof(struct vki_timeval
));
1582 /* int quotactl(const char *path, int cmd, int id, void *addr); */
1585 PRINT("sys_quotactl ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
,ARG3
, ARG4
);
1588 case VKI_Q_SETQUOTA
:
1591 case VKI_Q_GETQUOTASIZE
:
1592 PRE_REG_READ4(int, "quotactl",
1593 const char *, path
, int, cmd
, int, id
,
1595 PRE_MEM_RASCIIZ( "quotactl(path)", ARG1
);
1597 case VKI_Q_GETQUOTA
:
1598 if (VG_(tdict
).track_pre_reg_read
) {
1601 PRA1("quotactl",const char*,path
);
1602 PRA2("quotactl",int,cmd
);
1603 PRA4("quotactl",void*,addr
);
1606 case VKI_Q_QUOTAOFF
:
1608 PRE_REG_READ2(int, "quotactl",
1609 const char *, path
, int, cmd
);
1616 // SYS_nlm_syscall 154
1617 // syscall.master says ; 154 is initialised by the NLM code, if present.
1621 // int nfssvc(int flags, void *argstructp);
1622 // lengthy manpage, at least 3 types of struct that argstructp can point to
1626 // int lgetfh(const char *path, fhandle_t *fhp);
1629 PRINT("sys_lgetfh ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"x ", ARG1
, ARG2
);
1630 PRE_REG_READ2(int, "lgetfh", const char*, path
, vki_fhandle_t
*, fhp
);
1631 PRE_MEM_RASCIIZ( "lgetfh(path)", ARG1
);
1632 PRE_MEM_WRITE("lgetfh(fhp)", ARG2
, sizeof(vki_fhandle_t
));
1637 POST_MEM_WRITE(ARG2
, sizeof(vki_fhandle_t
));
1641 // int getfh(const char *path, fhandle_t *fhp);
1644 PRINT("sys_getfh ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"x ", ARG1
, ARG2
);
1645 PRE_REG_READ2(int, "getfh", const char*, path
, vki_fhandle_t
*, fhp
);
1646 PRE_MEM_RASCIIZ( "getfh(path)", ARG1
);
1647 PRE_MEM_WRITE("getfh(fhp)", ARG2
, sizeof(vki_fhandle_t
));
1652 POST_MEM_WRITE(ARG2
, sizeof(vki_fhandle_t
));
1655 #if (FREEBSD_VERS <= FREEBSD_10)
1657 // int getdomainname(char *domainname, int len);
1658 PRE(sys_freebsd4_getdomainname
)
1660 PRINT("sys_freebsd4_getdomainname ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",ARG1
,ARG2
);
1661 PRE_REG_READ2(int, "getdomainname",
1662 char *, domainname
, int, len
);
1663 PRE_MEM_WRITE( "getdomainname(domainname)", ARG1
, ARG2
);
1666 POST(sys_freebsd4_getdomainname
)
1669 POST_MEM_WRITE( ARG1
, ARG2
);
1674 // int setdomainname(char *domainname, int len);
1675 PRE(sys_freebsd4_setdomainname
)
1677 PRINT("sys_freebsd4_setdomainname ( %#" FMT_REGWORD
"x )",ARG1
);
1678 PRE_REG_READ2(int, "setdomainname", char *, domainname
, int, len
);
1679 PRE_MEM_RASCIIZ( "setdomainname(domainname)", ARG1
);
1683 // int uname(struct utsname *name);
1684 PRE(sys_freebsd4_uname
)
1686 PRINT("sys_freebsd4_uname ( %#" FMT_REGWORD
"x )", ARG1
);
1687 PRE_REG_READ1(int, "uname", struct utsname
*, name
);
1688 PRE_MEM_WRITE( "uname(name)", ARG1
, sizeof(struct vki_utsname
) );
1691 POST(sys_freebsd4_uname
)
1694 POST_MEM_WRITE( ARG1
, sizeof(struct vki_utsname
) );
1705 PRINT( "sys_rtprio ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
, ARG2
, ARG3
);
1706 PRE_REG_READ3(int, "rtprio",
1707 int, function
, pid_t
, pid
, struct rtprio
*, rtp
);
1708 if (ARG1
== VKI_RTP_SET
) {
1709 PRE_MEM_READ( "rtprio(rtp#set)", ARG3
, sizeof(struct vki_rtprio
));
1710 } else if (ARG1
== VKI_RTP_LOOKUP
) {
1711 PRE_MEM_WRITE( "rtprio(rtp#lookup)", ARG3
, sizeof(struct vki_rtprio
));
1719 if (ARG1
== VKI_RTP_LOOKUP
&& RES
== 0)
1720 POST_MEM_WRITE( ARG3
, sizeof(struct vki_rtprio
));
1723 // freebsd6_pread 173 FREEBSD_VERS <= 10
1726 // freebsd6_pwrite 174 FREEBSD_VERS <= 10
1730 // int setfib(int fib);
1733 PRINT("sys_setfib ( %" FMT_REGWORD
"d )", SARG1
);
1734 PRE_REG_READ1(int, "setfib", int, fib
);
1737 // SYS_ntp_adjtime 176
1738 // int ntp_adjtime(struct timex *);
1745 // int setegid(gid_t egid);
1748 PRINT("sys_setegid ( %" FMT_REGWORD
"u )", ARG1
);
1749 PRE_REG_READ1(int, "setegid", vki_gid_t
, gid
);
1753 // int seteuid(uid_t euid);
1756 PRINT("sys_seteuid ( %" FMT_REGWORD
"u )", ARG1
);
1757 PRE_REG_READ1(long, "seteuid", vki_uid_t
, uid
);
1761 #if (FREEBSD_VERS >= FREEBSD_12)
1763 // SYS_freebsd11_stat 188
1764 // int stat(char *path, struct freebsd11_stat *sb);
1765 PRE(sys_freebsd11_stat
)
1767 PRINT("sys_freebsd11_stat ( %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x )",ARG1
,(char *)ARG1
,ARG2
);
1768 PRE_REG_READ2(int, "stat", char *, path
, struct freebsd11_stat
*, sb
);
1769 PRE_MEM_RASCIIZ( "stat(path)", ARG1
);
1770 PRE_MEM_WRITE( "stat(sb)", ARG2
, sizeof(struct vki_freebsd11_stat
) );
1773 POST(sys_freebsd11_stat
)
1775 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_stat
) );
1778 // SYS_freebsd11_fstat 189
1779 // int fstat(int fd, struct stat *sb);
1780 PRE(sys_freebsd11_fstat
)
1782 PRINT("sys_freebsd11_fstat ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )",SARG1
,ARG2
);
1783 PRE_REG_READ2(int, "fstat", int, fd
, struct stat
*, sb
);
1784 PRE_MEM_WRITE( "fstat(sb)", ARG2
, sizeof(struct vki_freebsd11_stat
) );
1787 POST(sys_freebsd11_fstat
)
1789 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_stat
) );
1792 // SYS_freebsd11_lstat 190
1793 // int lstat(const char * restrict path, struct stat * restrict sb);
1794 PRE(sys_freebsd11_lstat
)
1796 PRINT("sys_freebsd11_lstat ( %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x )",ARG1
,(char *)ARG1
,ARG2
);
1797 PRE_REG_READ2(sb
, "lstat", const char *, path
, struct freebsd11_stat
*, sb
);
1798 PRE_MEM_RASCIIZ( "lstat(path)", ARG1
);
1799 PRE_MEM_WRITE( "lstat(sb)", ARG2
, sizeof(struct vki_freebsd11_stat
) );
1802 POST(sys_freebsd11_lstat
)
1806 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_stat
) );
1814 PRINT("sys_stat ( %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x )",ARG1
,(char *)ARG1
,ARG2
);
1815 PRE_REG_READ2(int, "stat", char *, path
, struct stat
*, sb
);
1816 PRE_MEM_RASCIIZ( "stat(path)", ARG1
);
1817 PRE_MEM_WRITE( "stat(sb)", ARG2
, sizeof(struct vki_freebsd11_stat
) );
1822 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_stat
) );
1828 PRINT("sys_fstat ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )",SARG1
,ARG2
);
1829 PRE_REG_READ2(int, "fstat", int, fd
, struct stat
*, sb
);
1830 PRE_MEM_WRITE( "fstat(sb)", ARG2
, sizeof(struct vki_freebsd11_stat
) );
1835 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_stat
) );
1840 PRINT("sys_lstat ( %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x )",ARG1
,(char *)ARG1
,ARG2
);
1841 PRE_REG_READ2(int, "lstat", const char *, path
, struct stat
*, sb
);
1842 PRE_MEM_RASCIIZ( "lstat(path)", ARG1
);
1843 PRE_MEM_WRITE( "lstat(sb)", ARG2
, sizeof(struct vki_freebsd11_stat
) );
1850 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_stat
) );
1857 // long pathconf(const char *path, int name);
1860 PRINT("sys_pathconf ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u )",ARG1
,(char *)ARG1
,ARG2
);
1861 PRE_REG_READ2(long, "pathconf", char *, path
, int, name
);
1862 PRE_MEM_RASCIIZ( "pathconf(path)", ARG1
);
1865 // SYS_fpathconf 192
1866 // long fpathconf(int fd, int name);
1869 PRINT("sys_fpathconf ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )",ARG1
,ARG2
);
1870 PRE_REG_READ2(long, "fpathconf", int, fd
, int, name
);
1873 // SYS_getrlimit 194
1876 // SYS_setrlimit 195
1880 // SYS_freebsd11_getdirentries 196
1881 // int getdirentries(int fd, char *buf, int nbytes, long *basep);
1882 #if (FREEBSD_VERS >= FREEBSD_12)
1883 PRE(sys_freebsd11_getdirentries
)
1885 *flags
|= SfMayBlock
;
1886 PRINT("sys_freebsd11_getdirentries ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
,ARG2
,ARG3
);
1887 PRE_REG_READ4(int, "getdirentries",
1888 int, fd
, char *, buf
,
1891 PRE_MEM_WRITE( "getdirentries(buf)", ARG2
, ARG3
);
1893 PRE_MEM_WRITE( "getdirentries(basep)", ARG4
, sizeof(long) );
1896 POST(sys_freebsd11_getdirentries
)
1900 POST_MEM_WRITE( ARG2
, RES
);
1902 POST_MEM_WRITE( ARG4
, sizeof (long));
1906 PRE(sys_getdirentries
)
1908 *flags
|= SfMayBlock
;
1909 PRINT("sys_getdirentries ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
,ARG2
,ARG3
);
1910 PRE_REG_READ4(int, "getdirentries",
1911 int, fd
, char *, buf
,
1914 PRE_MEM_WRITE( "getdirentries(buf)", ARG2
, ARG3
);
1916 PRE_MEM_WRITE( "getdirentries(basep)", ARG4
, sizeof(long) );
1919 POST(sys_getdirentries
)
1923 POST_MEM_WRITE( ARG2
, RES
);
1925 POST_MEM_WRITE( ARG4
, sizeof (long));
1930 // SYS_freebsd6_mmap 197
1934 // SYS___syscall 198
1937 // freebsd6_lseek 199 FREEBSD_VERS <= 10
1940 // freebsd6_truncate 200 FREEBSD_VERS <= 10
1943 // freebsd6_ftruncate 201 FREEBSD_VERS <= 10
1946 static Bool
sysctl_kern_ps_strings(SizeT
* out
, SizeT
* outlen
)
1949 const struct auxv
*cauxv
;
1951 for (cauxv
= (struct auxv
*)VG_(client_auxv
); cauxv
->a_type
!= VKI_AT_NULL
; cauxv
++) {
1952 if (cauxv
->a_type
== VKI_AT_PS_STRINGS
) {
1953 tmp
= (Word
)cauxv
->u
.a_ptr
;
1956 *outlen
= sizeof(size_t);
1963 static void sysctl_kern_usrstack(SizeT
* out
, SizeT
* outlen
)
1965 *out
= VG_(get_usrstack
)();
1966 *outlen
= sizeof(ULong
);
1970 /* int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen); */
1971 /* ARG1 ARG2 ARG3 ARG4 ARG5 ARG6 */
1974 PRINT("sys_sysctl ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
,SARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
1976 int* name
= (int*)ARG1
;
1977 if (ML_(safe_to_deref
)(name
, sizeof(int))) {
1978 PRINT("\nmib[0]: ");
1981 case 0: // CTL_UNSPEC
1996 case 5: // CTL_DEBUG
2002 case 7: // CTL_MACHDEP
2005 case 8: // CTL _USER
2008 case 9: //CTL_P1003_1B
2012 PRINT("unrecognized (%d)", ((int*)ARG1
)[0]);
2016 if (SARG2
>= 2 && ML_(safe_to_deref
)(name
, 2*sizeof(int))) {
2017 PRINT(" mib[1]: %d\n", name
[1]);
2022 * Special handling cases
2025 * This sysctl returns the address of the bottom of the user stack
2026 * (that is the highest user stack address, since the stack grows
2027 * downwards). Without any special handling this would return the
2028 * address of the host userstack. We have created a stack for the
2029 * guest (in aspacemgr) and that is the one that we want the guest
2030 * to see. Aspacemgr is setup in m_main.c with the adresses and sizes
2031 * saved to file static variables in that file, so we call
2032 * VG_(get_usrstack)() to retrieve them from there.
2034 if (SARG2
>= 2 && ML_(safe_to_deref
)(name
, 2*sizeof(int))) {
2035 if (name
[0] == 1 && name
[1] == 33) {
2037 sysctl_kern_usrstack((SizeT
*)ARG3
, (SizeT
*)ARG4
);
2038 SET_STATUS_Success(0);
2043 * 2. kern.ps_strings
2045 if (SARG2
>= 2 && ML_(safe_to_deref
)(name
, 2*sizeof(int))) {
2046 if (name
[0] == 1 && name
[1] == 32) {
2047 if (sysctl_kern_ps_strings((SizeT
*)ARG3
, (SizeT
*)ARG4
)) {
2048 SET_STATUS_Success(0);
2053 PRE_REG_READ6(int, "__sysctl", int *, name
, vki_u_int32_t
, namelen
, void *, oldp
,
2054 vki_size_t
*, oldlenp
, void *, newp
, vki_size_t
, newlen
);
2056 // read number of ints specified in ARG2 from mem pointed to by ARG1
2057 PRE_MEM_READ("sysctl(name)", (Addr
)ARG1
, ARG2
* sizeof(int));
2059 // if 'newp' is not NULL can read namelen bytes from that address
2060 if (ARG5
!= (UWord
)NULL
)
2061 PRE_MEM_READ("sysctl(newp)", (Addr
)ARG5
, ARG6
);
2063 // there are two scenarios for oldlenp/oldp
2064 // 1. oldval is NULL and oldlenp is non-NULL
2065 // this is a query of oldlenp so oldlenp will be written
2066 // 2. Both are non-NULL
2067 // this is a query of oldp, oldlenp will be read and oldp will
2070 // is oldlenp is not NULL, can write
2071 if (ARG4
!= (UWord
)NULL
) {
2072 if (ARG3
!= (UWord
)NULL
) {
2074 PRE_MEM_READ("sysctl(oldlenp)", (Addr
)ARG4
, sizeof(vki_size_t
));
2075 if (ML_(safe_to_deref
)((void*)(Addr
)ARG4
, sizeof(vki_size_t
))) {
2076 PRE_MEM_WRITE("sysctl(oldp)", (Addr
)ARG3
, *(vki_size_t
*)ARG4
);
2078 VG_(dmsg
)("Warning: Bad oldlenp address %p in sysctl\n",
2079 (void *)(Addr
)ARG4
);
2080 SET_STATUS_Failure ( VKI_EFAULT
);
2084 PRE_MEM_WRITE("sysctl(oldlenp)", (Addr
)ARG4
, sizeof(vki_size_t
));
2091 if (ARG4
!= (UWord
)NULL
) {
2092 if (ARG3
!= (UWord
)NULL
) {
2093 //POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t));
2094 POST_MEM_WRITE((Addr
)ARG3
, *(vki_size_t
*)ARG4
);
2096 POST_MEM_WRITE((Addr
)ARG4
, sizeof(vki_size_t
));
2107 // int undelete(const char *path);
2110 *flags
|= SfMayBlock
;
2111 PRINT("sys_undelete ( %#" FMT_REGWORD
"x(%s) )", ARG1
,(char *)ARG1
);
2112 PRE_REG_READ1(int, "undelete", const char *, path
);
2113 PRE_MEM_RASCIIZ( "undelete(path)", ARG1
);
2117 // int futimes(int fd, const struct timeval *times);
2120 PRINT("sys_lutimes ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
);
2121 PRE_REG_READ2(long, "futimes", int, fd
, struct timeval
*, times
);
2123 PRE_MEM_READ( "futimes(times)", ARG2
, sizeof(struct vki_timeval
) );
2132 // SYS_freebsd7___semctl 220
2133 // int semctl(int semid, int semnum, int cmd, ...);
2134 PRE(sys_freebsd7___semctl
)
2139 PRINT("sys_semctl ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )",ARG1
,ARG2
,ARG3
,ARG4
);
2140 PRE_REG_READ4(int, "semctl",
2141 int, semid
, int, semnum
, int, cmd
, struct seminfo
*, arg
);
2146 PRINT("sys_semctl ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )",ARG1
,ARG2
,ARG3
,ARG4
);
2147 PRE_REG_READ4(int, "semctl",
2148 int, semid
, int, semnum
, int, cmd
, struct vki_semid_ds_old
*, arg
);
2152 PRINT("sys_semctl ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )",ARG1
,ARG2
,ARG3
,ARG4
);
2153 PRE_REG_READ4(int, "semctl",
2154 int, semid
, int, semnum
, int, cmd
, unsigned short *, arg
);
2157 PRINT("sys_semctl ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
2158 PRE_REG_READ3(long, "semctl",
2159 int, semid
, int, semnum
, int, cmd
);
2162 ML_(generic_PRE_sys_semctl
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
2165 POST(sys_freebsd7___semctl
)
2167 ML_(generic_POST_sys_semctl
)(tid
, RES
,ARG1
,ARG2
,ARG3
,ARG4
);
2171 // int semget(key_t key, int nsems, int flag);
2174 PRINT("sys_semget ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
2175 PRE_REG_READ3(int, "semget", vki_key_t
, key
, int, nsems
, int, flag
);
2179 // int semop(int semid, struct sembuf *array, size_t nops);
2182 *flags
|= SfMayBlock
;
2183 PRINT("sys_semop ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
2184 PRE_REG_READ3(int, "semop",
2185 int, semid
, struct sembuf
*, array
, unsigned, nops
);
2186 ML_(generic_PRE_sys_semop
)(tid
, ARG1
,ARG2
,ARG3
);
2189 // SYS_freebsd7_msgctl 224
2190 // int msgctl(int msqid, int cmd, struct msqid_ds_old *buf);
2191 PRE(sys_freebsd7_msgctl
)
2193 PRINT("sys_freebsd7_msgctl ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
,SARG2
,ARG3
);
2195 PRE_REG_READ3(int, "msgctl", int, msqid
, int, cmd
, struct msqid_ds_old
*, buf
);
2197 switch (ARG2
/* cmd */) {
2199 PRE_MEM_WRITE( "msgctl(IPC_STAT, buf)",
2200 ARG3
, sizeof(struct vki_msqid_ds_old
) );
2203 PRE_MEM_READ( "msgctl(IPC_SET, buf)",
2204 ARG3
, sizeof(struct vki_msqid_ds_old
) );
2209 POST(sys_freebsd7_msgctl
)
2211 switch (ARG2
/* cmd */) {
2213 POST_MEM_WRITE( ARG3
, sizeof(struct vki_msqid_ds_old
) );
2219 // int msgget(key_t key, int msgflg);
2222 PRINT("sys_msgget ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d )",SARG1
,SARG2
);
2223 PRE_REG_READ2(int, "msgget", key_t
, key
, int, msgflg
);
2227 // int msgsnd(int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg);
2230 PRINT("sys_msgsnd ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %" FMT_REGWORD
"d )", SARG1
,ARG2
,SARG3
,SARG4
);
2231 PRE_REG_READ4(int, "msgsnd", int, msqid
, struct msgbuf
*, msgp
, size_t, msgsz
, int, msgflg
);
2232 struct vki_msgbuf
*msgp
= (struct vki_msgbuf
*)ARG2
;
2233 PRE_MEM_READ( "msgsnd(msgp->mtype)", (Addr
)&msgp
->mtype
, sizeof(msgp
->mtype
) );
2234 PRE_MEM_READ( "msgsnd(msgp->mtext)", (Addr
)&msgp
->mtext
, ARG3
);
2237 // ssize_t msgrcv(int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp, int msgflg);
2240 *flags
|= SfMayBlock
;
2242 PRINT("sys_msgrcv ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"d, %" FMT_REGWORD
"d )", SARG1
,ARG2
,ARG3
,SARG4
,SARG5
);
2243 PRE_REG_READ5(ssize_t
, "msgrcv", int, msqid
, struct msgbuf
*, msgp
, size_t, msgsz
,
2244 long, msgtyp
, int, msgflg
);
2245 struct vki_msgbuf
*msgp
= (struct vki_msgbuf
*)ARG2
;
2246 PRE_MEM_WRITE( "msgrcv(msgp->mtype)", (Addr
)&msgp
->mtype
, sizeof(msgp
->mtype
) );
2247 PRE_MEM_WRITE( "msgrcv(msgp->mtext)", (Addr
)&msgp
->mtext
, ARG3
);
2252 struct vki_msgbuf
*msgp
= (struct vki_msgbuf
*)ARG2
;
2253 POST_MEM_WRITE( (Addr
)&msgp
->mtype
, sizeof(msgp
->mtype
) );
2254 POST_MEM_WRITE( (Addr
)&msgp
->mtext
, RES
);
2258 // void * shmat(int shmid, const void *addr, int flag);
2262 PRINT("sys_shmat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
2263 PRE_REG_READ3(void *, "shmat",
2264 int, shmid
, const void *, addr
, int, flag
);
2265 arg2tmp
= ML_(generic_PRE_sys_shmat
)(tid
, ARG1
,ARG2
,ARG3
);
2267 SET_STATUS_Failure( VKI_EINVAL
);
2274 ML_(generic_POST_sys_shmat
)(tid
, RES
,ARG1
,ARG2
,ARG3
);
2277 // SYS_freebsd7_shmctl 229
2278 // int shmctl(int shmid, int cmd, struct shmid_ds *buf);
2279 PRE(sys_freebsd7_shmctl
)
2281 PRINT("sys_freebsd7_shmctl ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )",SARG1
,SARG2
,ARG3
);
2282 PRE_REG_READ3(int, "shmctl",
2283 int, shmid
, int, cmd
, struct vki_shmid_ds_old
*, buf
);
2284 switch (ARG2
/* cmd */) {
2286 PRE_MEM_WRITE( "shmctl7(IPC_STAT, buf)",
2287 ARG3
, sizeof(struct vki_shmid_ds_old
) );
2290 PRE_MEM_READ( "shmctl7(IPC_SET, buf)",
2291 ARG3
, sizeof(struct vki_shmid_ds_old
) );
2296 POST(sys_freebsd7_shmctl
)
2298 if (ARG2
== VKI_IPC_STAT
) {
2299 POST_MEM_WRITE( ARG3
, sizeof(struct vki_shmid_ds_old
) );
2304 // int shmdt(const void *addr);
2307 PRINT("sys_shmdt ( %#" FMT_REGWORD
"x )",ARG1
);
2308 PRE_REG_READ1(int, "shmdt", const void *, addr
);
2309 if (!ML_(generic_PRE_sys_shmdt
)(tid
, ARG1
))
2310 SET_STATUS_Failure( VKI_EINVAL
);
2315 ML_(generic_POST_sys_shmdt
)(tid
, RES
,ARG1
);
2319 // int shmget(key_t key, size_t size, int flag);
2322 PRINT("sys_shmget ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
2323 PRE_REG_READ3(int, "shmget", vki_key_t
, key
, vki_size_t
, size
, int, flag
);
2327 // SYS_clock_gettime 232
2328 // int clock_gettime(clockid_t clock_id, struct timespec *tp);
2329 PRE(sys_clock_gettime
)
2331 PRINT("sys_clock_gettime( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
);
2332 PRE_REG_READ2(int, "clock_gettime",
2333 vki_clockid_t
, clk_id
, struct timespec
*, tp
);
2334 PRE_MEM_WRITE( "clock_gettime(tp)", ARG2
, sizeof(struct vki_timespec
) );
2337 POST(sys_clock_gettime
)
2339 POST_MEM_WRITE( ARG2
, sizeof(struct vki_timespec
) );
2342 // SYS_clock_settime 233
2343 // int clock_settime(clockid_t clock_id, const struct timespec *tp);
2344 PRE(sys_clock_settime
)
2346 PRINT("sys_clock_settime( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
);
2347 PRE_REG_READ2(int, "clock_settime",
2348 vki_clockid_t
, clk_id
, const struct timespec
*, tp
);
2349 PRE_MEM_READ( "clock_settime(tp)", ARG2
, sizeof(struct vki_timespec
) );
2352 // SYS_clock_getres 234
2353 // int clock_getres(clockid_t clock_id, struct timespec *tp);
2354 PRE(sys_clock_getres
)
2356 PRINT("sys_clock_getres( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
);
2357 // Nb: we can't use "RES" as the param name because that's a macro
2359 PRE_REG_READ2(int, "clock_getres",
2360 vki_clockid_t
, clock_id
, struct timespec
*, tp
);
2362 PRE_MEM_WRITE( "clock_getres(tp)", ARG2
, sizeof(struct vki_timespec
) );
2365 POST(sys_clock_getres
)
2368 POST_MEM_WRITE( ARG2
, sizeof(struct vki_timespec
) );
2371 // SYS_ktimer_create 235
2372 // int timer_create(clockid_t clockid, struct sigevent *restrict evp,
2373 // timer_t *restrict timerid);
2374 PRE(sys_timer_create
)
2376 PRINT("sys_timer_create( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )", SARG1
,ARG2
,ARG3
);
2377 PRE_REG_READ3(int, "timer_create",
2378 vki_clockid_t
, clockid
, struct sigevent
*, evp
,
2379 vki_timer_t
*, timerid
);
2381 PRE_MEM_READ( "timer_create(evp)", ARG2
, sizeof(struct vki_sigevent
) );
2382 PRE_MEM_WRITE( "timer_create(timerid)", ARG3
, sizeof(vki_timer_t
) );
2385 POST(sys_timer_create
)
2387 POST_MEM_WRITE( ARG3
, sizeof(vki_timer_t
) );
2390 // SYS_ktimer_delete 236
2391 // int timer_delete(timer_t timerid);
2392 PRE(sys_timer_delete
)
2394 PRINT("sys_timer_delete( %#" FMT_REGWORD
"x )", ARG1
);
2395 PRE_REG_READ1(long, "timer_delete", vki_timer_t
, timerid
);
2398 // SYS_ktimer_settime 237
2399 // int timer_settime(timer_t timerid, int flags,
2400 // const struct itimerspec *restrict value,
2401 // struct itimerspec *restrict ovalue);
2402 PRE(sys_timer_settime
)
2404 PRINT("sys_timer_settime( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )", ARG1
,SARG2
,ARG3
,ARG4
);
2405 PRE_REG_READ4(int, "timer_settime",
2406 vki_timer_t
, timerid
, int, flags
,
2407 const struct itimerspec
*, value
,
2408 struct itimerspec
*, ovalue
);
2409 PRE_MEM_READ( "timer_settime(value)", ARG3
,
2410 sizeof(struct vki_itimerspec
) );
2412 PRE_MEM_WRITE( "timer_settime(ovalue)", ARG4
,
2413 sizeof(struct vki_itimerspec
) );
2416 POST(sys_timer_settime
)
2419 POST_MEM_WRITE( ARG4
, sizeof(struct vki_itimerspec
) );
2422 // SYS_ktimer_gettime 238
2423 // int timer_gettime(timer_t timerid, struct itimerspec *value);
2424 PRE(sys_timer_gettime
)
2426 PRINT("sys_timer_gettime( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )", ARG1
,ARG2
);
2427 PRE_REG_READ2(long, "timer_gettime",
2428 vki_timer_t
, timerid
, struct itimerspec
*, value
);
2429 PRE_MEM_WRITE( "timer_gettime(value)", ARG2
,
2430 sizeof(struct vki_itimerspec
));
2433 POST(sys_timer_gettime
)
2435 POST_MEM_WRITE( ARG2
, sizeof(struct vki_itimerspec
) );
2438 // SYS_ktimer_getoverrun 239
2439 // int timer_getoverrun(timer_t timerid);
2440 PRE(sys_timer_getoverrun
)
2442 PRINT("sys_timer_getoverrun( %#" FMT_REGWORD
"x )", ARG1
);
2443 PRE_REG_READ1(int, "timer_getoverrun", vki_timer_t
, timerid
);
2446 // SYS_nanosleep 240
2449 // SYS_ffclock_getcounter 241
2450 // int ffclock_getcounter(ffcounter *ffcount);
2453 // SYS_ffclock_setestimate 242
2454 // int ffclock_setestimate(struct ffclock_estimate *cest);
2457 // SYS_ffclock_getestimate 243
2458 // int ffclock_getestimate(struct ffclock_estimate *cest);
2461 // SYS_clock_nanosleep 244
2462 // int clock_nanosleep(clockid_t clock_id, int flags,
2463 // const struct timespec *rqtp, struct timespec *rmtp);
2464 PRE(sys_clock_nanosleep
)
2466 *flags
|= SfMayBlock
|SfPostOnFail
;
2467 PRINT("sys_clock_nanosleep ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",
2468 SARG1
, SARG2
, ARG3
, ARG4
);
2469 PRE_REG_READ4(int, "clock_nanosleep", clockid_t
, clock_id
, int, flags
,
2470 const struct timespec
*, rqtp
, struct timespec
*, rmtp
);
2471 PRE_MEM_READ("clock_nanosleep(rqtp)", ARG1
, sizeof(struct vki_timespec
));
2473 PRE_MEM_WRITE( "clock_nanosleep(rmtp)", ARG2
, sizeof(struct vki_timespec
) );
2477 POST(sys_clock_nanosleep
)
2480 POST_MEM_WRITE( ARG2
, sizeof(struct vki_timespec
) );
2483 // SYS_clock_getcpuclockid2 247
2486 POST(sys_clock_getcpuclockid2
)
2488 POST_MEM_WRITE(ARG3
, sizeof(vki_clockid_t
));
2492 // SYS_ntp_gettime 248
2493 // int ntp_gettime(struct ntptimeval *);
2497 // int minherit(void *addr, size_t len, int inherit);
2500 PRINT("sys_minherit( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )", ARG1
,ARG2
,ARG3
);
2501 PRE_REG_READ3(int, "minherit",
2502 void *, addr
, vki_size_t
, len
, int, inherit
);
2504 PRE_MEM_WRITE( "minherit(addr)", ARG1
,ARG2
);
2510 POST_MEM_WRITE( ARG1
, ARG2
);
2514 // x86/amd64 not functional
2516 // SYS_issetugid 253
2517 // int issetugid(void);
2520 PRINT("%s", "sys_issetugid ()");
2521 PRE_REG_READ0(long, "issetugid");
2528 // int aio_read(struct aiocb *iocb);
2531 PRINT("sys_aio_read ( %#" FMT_REGWORD
"x )", ARG1
);
2532 PRE_REG_READ1(int, "aio_read", struct vki_aiocb
*, iocb
);
2533 PRE_MEM_READ("aio_read(iocb)", ARG1
, sizeof(struct vki_aiocb
));
2534 if (ML_(safe_to_deref
)((struct vki_aiocb
*)ARG1
, sizeof(struct vki_aiocb
))) {
2535 struct vki_aiocb
*iocb
= (struct vki_aiocb
*)ARG1
;
2536 PRE_MEM_WRITE( "aio_read(iocb->aio_offset)", (Addr
)iocb
, sizeof(struct vki_aiocb
));
2542 if (ML_(safe_to_deref
)((struct vki_aiocb
*)ARG1
, sizeof(struct vki_aiocb
))) {
2543 struct vki_aiocb
*iocb
= (struct vki_aiocb
*)ARG1
;
2544 POST_MEM_WRITE((Addr
)iocb
, sizeof(struct vki_aiocb
));
2548 // SYS_aio_write 256
2549 // int aio_write(struct aiocb *iocb);
2552 PRINT("sys_aio_write ( %#" FMT_REGWORD
"x )", ARG1
);
2553 PRE_REG_READ1(int, "aio_write", struct vki_aiocb
*, iocb
);
2554 PRE_MEM_READ("aio_read(iocb)", ARG1
, sizeof(struct vki_aiocb
));
2555 if (ML_(safe_to_deref
)((struct vki_aiocb
*)ARG1
, sizeof(struct vki_aiocb
))) {
2556 struct vki_aiocb
*iocb
= (struct vki_aiocb
*)ARG1
;
2557 PRE_MEM_WRITE( "aio_write(iocb->aio_offset)", (Addr
)iocb
, sizeof(struct vki_aiocb
));
2563 if (ML_(safe_to_deref
)((struct vki_aiocb
*)ARG1
, sizeof(struct vki_aiocb
))) {
2564 struct vki_aiocb
*iocb
= (struct vki_aiocb
*)ARG1
;
2565 PRE_MEM_WRITE( "aio_write(iocb->aio_offset)", (Addr
)iocb
, sizeof(struct vki_aiocb
));
2569 // SYS_lio_listio 257
2570 // int lio_listio(int mode, struct aiocb * const list[], int nent,
2571 // struct sigevent *sig);
2574 PRINT("sys_lio_listio ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )",
2575 SARG1
, ARG2
, SARG3
, ARG4
);
2576 PRE_REG_READ4(int, "lio_listio", int, mode
, struct aiocb
* const *, list
, int, nent
,
2577 struct sigevent
*,sig
);
2578 PRE_MEM_READ("lio_listio(list)", ARG2
, ARG3
*sizeof(struct vki_aiocb
*));
2579 // loop check elements
2580 if (ML_(safe_to_deref
)((struct vki_aiocb
**)ARG2
, ARG3
*sizeof(struct vki_aiocb
*))) {
2581 struct vki_aiocb
** list
= (struct vki_aiocb
**)ARG2
;
2582 for (int i
= 0; i
< (int)ARG3
; ++i
) {
2584 PRE_MEM_READ("lio_listio(list[?])", (Addr
)list
[i
], ARG3
*sizeof(struct vki_aiocb
));
2587 // figure out what gets read/written
2588 // when list[i]->aio_lio_opcode == VKI_LIO_READ and
2589 // when list[i]->aio_lio_opcode == VKI_LIO_WRITE
2590 //if (ML_(safe_to_deref)(list[i], ARG3*sizeof(struct vki_aiocb))) {
2595 if (ARG1
& VKI_LIO_WAIT
) {
2596 *flags
|= SfMayBlock
;
2599 if (ARG4
&& (ARG1
== VKI_LIO_NOWAIT
)) {
2600 PRE_MEM_READ("lio_listio(sig)", ARG4
, sizeof(struct vki_sigevent
));
2604 // SYS_freebsd11_getdents 272
2608 // int lchmod(const char *path, mode_t mode);
2611 PRINT("sys_lchmod ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u )", ARG1
,(char *)ARG1
,ARG2
);
2612 PRE_REG_READ2(int, "lchmod", const char *, path
, vki_mode_t
, mode
);
2613 PRE_MEM_RASCIIZ( "lchmod(path)", ARG1
);
2617 // int lutimes(const char *path, const struct timeval *times);
2620 PRINT("sys_lutimes ( %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x )", ARG1
,(char *)ARG1
,ARG2
);
2621 PRE_REG_READ2(int, "lutimes", char *, path
, struct timeval
*, times
);
2622 PRE_MEM_RASCIIZ( "lutimes(path)", ARG1
);
2624 PRE_MEM_READ( "lutimes(times)", ARG2
, sizeof(struct vki_timeval
) );
2627 // SYS_freebsd11_nstat 278
2630 // SYS_freebsd11_nfstat 279
2633 // SYS_freebsd11_nlstat 280
2643 // int fhopen(const fhandle_t *fhp, int flags);
2646 PRINT("sys_open ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",ARG1
,ARG2
);
2647 PRE_REG_READ2(int, "fhopen",
2648 struct fhandle_t
*, fhp
, int, flags
);
2649 PRE_MEM_READ( "fhopen(fhp)", ARG1
, sizeof(struct vki_fhandle
) );
2651 /* Otherwise handle normally */
2652 *flags
|= SfMayBlock
;
2658 if (!ML_(fd_allowed
)(RES
, "fhopen", tid
, True
)) {
2660 SET_STATUS_Failure( VKI_EMFILE
);
2662 if (VG_(clo_track_fds
))
2663 ML_(record_fd_open_nameless
)(tid
, RES
);
2667 // SYS_freebsd11_fhstat 299
2668 // int fhstat(const fhandle_t *fhp, struct stat *sb);
2669 #if (FREEBSD_VERS >= FREEBSD_12)
2670 PRE(sys_freebsd11_fhstat
)
2672 PRINT("sys_freebsd11_fhstat ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",ARG1
,ARG2
);
2673 PRE_REG_READ2(int, "fhstat", struct fhandle
*, fhp
, struct freebd11_stat
*, sb
);
2674 PRE_MEM_READ( "fhstat(fhp)", ARG1
, sizeof(struct vki_fhandle
) );
2675 PRE_MEM_WRITE( "fhstat(sb)", ARG2
, sizeof(struct vki_freebsd11_stat
) );
2678 POST(sys_freebsd11_fhstat
)
2680 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_stat
) );
2685 PRINT("sys_fhstat ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",ARG1
,ARG2
);
2686 PRE_REG_READ2(int, "fhstat", struct fhandle
*, fhp
, struct stat
*, sb
);
2687 PRE_MEM_READ( "fhstat(fhp)", ARG1
, sizeof(struct vki_fhandle
) );
2688 PRE_MEM_WRITE( "fhstat(sb)", ARG2
, sizeof(struct vki_freebsd11_stat
) );
2693 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_stat
) );
2699 // int modnext(int modid);
2702 PRINT("sys_modnext ( %" FMT_REGWORD
"d )",SARG1
);
2703 PRE_REG_READ1(int, "modnext", int, modid
);
2707 // int modstat(int modid, struct module_stat *stat);
2710 PRINT("sys_modstat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )",ARG1
,ARG2
);
2711 PRE_REG_READ2(int, "modstat", int, modid
, struct module_stat
*, buf
);
2712 PRE_MEM_WRITE( "modstat(stat)", ARG2
, sizeof(struct vki_module_stat
) );
2717 POST_MEM_WRITE( ARG2
, sizeof(struct vki_module_stat
) );
2721 // int modfnext(int modid);
2724 PRINT("sys_modfnext ( %" FMT_REGWORD
"d )",SARG1
);
2725 PRE_REG_READ1(int, "modfnext", int, modid
);
2729 // int modfind(const char *modname);
2732 PRINT("sys_modfind ( %#" FMT_REGWORD
"x )",ARG1
);
2733 PRE_REG_READ1(long, "modfind", char *, modname
);
2734 PRE_MEM_RASCIIZ( "modfind(modname)", ARG1
);
2738 // int kldload(const char *file);
2741 PRINT("sys_kldload ( %#" FMT_REGWORD
"x(%s) )", ARG1
, (char *)ARG1
);
2742 PRE_REG_READ1(int, "kldload", const char *, "file");
2743 PRE_MEM_RASCIIZ( "kldload(file)", ARG1
);
2746 // SYS_kldunload 305
2747 // int kldunload(int fileid);
2750 PRINT("sys_kldunload ( %" FMT_REGWORD
"u )", ARG1
);
2751 PRE_REG_READ1(int, "kldunload", int, "fileid");
2755 // int kldfind(const char *file);
2758 PRINT("sys_kldfind ( %#" FMT_REGWORD
"x(%s) )", ARG1
, (char *)ARG1
);
2759 PRE_REG_READ1(int, "kldfind", const char *, file
);
2760 PRE_MEM_RASCIIZ( "kldfind(file)", ARG1
);
2764 // int kldnext(int fileid);
2767 PRINT("sys_kldnext ( %" FMT_REGWORD
"u )", ARG1
);
2768 PRE_REG_READ1(int, "kldnext", int, fileid
);
2772 // int kldstat(int fileid, struct kld_file_stat *stat);
2775 PRINT("sys_kldstat ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
, ARG2
);
2776 PRE_REG_READ2(int, "kldstat", int, fileid
, struct kld_file_stat
*, stat
);
2777 PRE_MEM_WRITE("kldstat(stat)", ARG2
, sizeof(struct vki_kld_file_stat
));
2782 POST_MEM_WRITE(ARG2
, sizeof(struct vki_kld_file_stat
));
2785 // SYS_kldfirstmod 309
2786 // int kldfirstmod(int fileid);
2787 PRE(sys_kldfirstmod
)
2789 PRINT("sys_kldfirstmod ( %" FMT_REGWORD
"u )", ARG1
);
2790 PRE_REG_READ1(int, "kldfirstmod", int, fileid
);
2793 // SYS_setresuid 311
2794 // int setresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
2797 PRINT("sys_setresuid ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )", ARG1
, ARG2
, ARG3
);
2798 PRE_REG_READ3(int, "setresuid",
2799 vki_uid_t
, ruid
, vki_uid_t
, euid
, vki_uid_t
, suid
);
2802 // SYS_setresgid 312
2803 // int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
2806 PRINT("sys_setresgid ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )", ARG1
, ARG2
, ARG3
);
2807 PRE_REG_READ3(int, "setresgid",
2808 vki_gid_t
, rgid
, vki_gid_t
, egid
, vki_gid_t
, sgid
);
2811 // SYS_aio_return 314
2812 // ssize_t aio_return(struct aiocb *iocb);
2815 PRINT("sys_aio_return ( %#" FMT_REGWORD
"x )", ARG1
);
2816 PRE_REG_READ1(ssize_t
, "aio_return", struct aiocb
*, iocb
);
2817 // not too clear if this is read-only, sounds like it from the man page
2818 // but it isn't const
2819 PRE_MEM_READ("aio_return(iocb)", ARG1
, sizeof(struct vki_aiocb
));
2822 // SYS_aio_suspend 315
2823 // int aio_suspend(const struct aiocb *const iocbs[], int niocb,
2824 // const struct timespec *timeout);
2825 PRE(sys_aio_suspend
)
2827 PRINT("sys_aio_suspend ( %#" FMT_REGWORD
"x )", ARG1
);
2828 PRE_REG_READ3(int, "aio_suspend", struct aiocb
**, iocbs
, int, nbiocb
, const struct timespec
*, timeout
);
2829 PRE_MEM_READ("aio_suspend(iocbs)", ARG1
, ARG2
*sizeof(struct vki_aiocb
));
2830 PRE_MEM_READ("aio_suspend(timeout)", ARG3
, sizeof(struct vki_timespec
));
2833 // SYS_aio_cancel 316
2834 // int aio_cancel(int fildes, struct aiocb *iocb);
2837 PRINT("sys_aio_cancel ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
, ARG2
);
2838 PRE_REG_READ2(int, "aio_cancel", int, fildex
, struct aiocb
*, iocb
);
2840 PRE_MEM_READ("aio_cancel(iocb)", ARG2
, sizeof(struct vki_aiocb
));
2844 // SYS_aio_error 317
2845 // int aio_error(const struct aiocb *iocb);
2848 PRINT("sys_aio_error ( %#" FMT_REGWORD
"x )", ARG1
);
2849 PRE_REG_READ1(ssize_t
, "aio_error", struct aiocb
*, iocb
);
2850 PRE_MEM_READ("aio_error(iocb)", ARG1
, sizeof(struct vki_aiocb
));
2857 *flags
|= SfMayBlock
;
2858 PRINT("%s", "yield()");
2859 PRE_REG_READ0(long, "yield");
2865 // SYS_munlockall 325
2866 // int munlockall(void);
2869 *flags
|= SfMayBlock
;
2870 PRINT("%s", "sys_munlockall ( )");
2871 PRE_REG_READ0(int, "munlockall");
2875 // int __getcwd(char *buf, size_t buflen);
2878 PRINT("sys___getcwd ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
,ARG2
);
2879 PRE_REG_READ2(long, "__getcwd", char *, buf
, unsigned int, buflen
);
2880 PRE_MEM_WRITE( "__getcwd(buf)", ARG1
, ARG2
);
2887 // QQQ it is unclear if this is legal or not, but the
2888 // QQQ kernel just wrote it there...
2889 // QQQ Why oh why didn't phk return the length from __getcwd()?
2890 UInt len
= VG_(strlen
) ( (char *)ARG1
) + 1;
2891 POST_MEM_WRITE( ARG1
, len
);
2895 //SYS_sched_setparam 327
2896 // int sched_setparam(pid_t pid, const struct sched_param *param);
2897 PRE(sys_sched_setparam
)
2899 PRINT("sched_setparam ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
, ARG2
);
2900 PRE_REG_READ2(int, "sched_setparam",
2901 vki_pid_t
, pid
, struct sched_param
*, param
);
2902 PRE_MEM_READ( "sched_setparam(param)", ARG2
, sizeof(struct vki_sched_param
) );
2905 POST(sys_sched_setparam
)
2907 POST_MEM_WRITE( ARG2
, sizeof(struct vki_sched_param
) );
2910 // SYS_sched_getparam 328
2911 // int sched_getparam(pid_t pid, struct sched_param *param);
2912 PRE(sys_sched_getparam
)
2914 PRINT("sched_getparam ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
, ARG2
);
2915 PRE_REG_READ2(int, "sched_getparam",
2916 vki_pid_t
, pid
, struct sched_param
*, param
);
2917 PRE_MEM_WRITE( "sched_getparam(param)", ARG2
, sizeof(struct vki_sched_param
) );
2920 POST(sys_sched_getparam
)
2922 POST_MEM_WRITE( ARG2
, sizeof(struct vki_sched_param
) );
2925 // SYS_sched_setscheduler 329
2926 // int sched_setscheduler(pid_t pid, int policy,
2927 // const struct sched_param *param);
2928 PRE(sys_sched_setscheduler
)
2930 PRINT("sys_sched_setscheduler ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
,SARG2
,ARG3
);
2931 PRE_REG_READ3(int, "sched_setscheduler",
2932 vki_pid_t
, pid
, int, policy
, struct sched_param
*, param
);
2934 PRE_MEM_READ("sched_setscheduler(param)",
2935 ARG3
, sizeof(struct vki_sched_param
));
2938 // SYS_sched_getscheduler 330
2939 // int sched_getscheduler(pid_t pid);
2940 PRE(sys_sched_getscheduler
)
2942 PRINT("sys_sched_getscheduler ( %" FMT_REGWORD
"d )", SARG1
);
2943 PRE_REG_READ1(int, "sched_getscheduler", vki_pid_t
, pid
);
2946 // SYS_sched_yield 331
2947 // int sched_yield(void);
2948 PRE(sys_sched_yield
)
2950 *flags
|= SfMayBlock
;
2951 PRINT("sched_yield()");
2952 PRE_REG_READ0(int, "sched_yield");
2955 // SYS_sched_get_priority_max 332
2956 // int sched_get_priority_max(int policy);
2957 PRE(sys_sched_get_priority_max
)
2959 PRINT("sched_get_priority_max ( %" FMT_REGWORD
"u )", ARG1
);
2960 PRE_REG_READ1(long, "sched_get_priority_max", int, policy
);
2963 // SYS_sched_get_priority_min 333
2964 // int sched_get_priority_min(int policy);
2965 PRE(sys_sched_get_priority_min
)
2967 PRINT("sched_get_priority_min ( %" FMT_REGWORD
"u )", ARG1
);
2968 PRE_REG_READ1(long, "sched_get_priority_min", int, policy
);
2971 // SYS_sched_rr_get_interval 334
2972 // int sched_rr_get_interval(pid_t pid, struct timespec *interval);
2973 PRE(sys_sched_rr_get_interval
)
2975 PRINT("sys_sched_rr_get_interval ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
, ARG2
);
2976 PRE_REG_READ2(int, "sched_rr_get_interval", vki_pid_t
, pid
, struct vki_timespec
*,interval
);
2977 PRE_MEM_WRITE("sys_sched_rr_get_interval(interval)", ARG2
, sizeof(struct vki_timespec
));
2980 POST(sys_sched_rr_get_interval
)
2982 POST_MEM_WRITE(ARG2
, sizeof(struct vki_timespec
));
2986 // int utrace(const void *addr, size_t len);
2989 PRINT("sys_utrace ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
, ARG2
);
2990 PRE_REG_READ2(int, "utrace", const void *, addr
, vki_size_t
, len
);
2991 PRE_MEM_READ( "utrace(addr)", ARG2
, ARG3
);
2995 // int kldsym(int fileid, int cmd, void *data);
2998 PRINT("sys_kldsym ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
,ARG3
);
2999 PRE_REG_READ3(int, "kldsym", int, fileid
, int, cmd
, void*, data
);
3000 PRE_MEM_READ( "kldsym(data)", ARG3
, sizeof(struct vki_kld_sym_lookup
) );
3001 struct vki_kld_sym_lookup
*kslp
= (struct vki_kld_sym_lookup
*)ARG3
;
3002 if (ML_(safe_to_deref
)(kslp
, sizeof(struct vki_kld_sym_lookup
))) {
3003 PRE_MEM_RASCIIZ( "kldsym(data.symname)", (Addr
)kslp
->symname
);
3009 struct vki_kld_sym_lookup
*kslp
= (struct vki_kld_sym_lookup
*)ARG3
;
3010 POST_MEM_WRITE( (Addr
)&kslp
->symvalue
, sizeof(kslp
->symvalue
) );
3011 POST_MEM_WRITE( (Addr
)&kslp
->symsize
, sizeof(kslp
->symsize
) );
3015 // int jail(struct jail *jail);
3018 PRINT("sys_jail ( %#" FMT_REGWORD
"x )", ARG1
);
3019 PRE_REG_READ1(int, "jail", struct jail
*, jail
);
3020 PRE_MEM_READ( "jail(jail)", ARG1
, sizeof(struct vki_jail
) );
3023 // SYS_nnpfs_syscall 338
3026 // SYS_sigprocmask 340
3027 // int sigprocmask(int how, const sigset_t * restrict set,
3028 // sigset_t * restrict oset);
3029 PRE(sys_sigprocmask
)
3031 PRINT("sys_sigprocmask ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",ARG1
,ARG2
,ARG3
);
3032 PRE_REG_READ3(int, "sigprocmask",
3033 int, how
, vki_sigset_t
*, set
, vki_sigset_t
*, oset
);
3035 PRE_MEM_READ( "sigprocmask(set)", ARG2
, sizeof(vki_sigset_t
));
3037 PRE_MEM_WRITE( "sigprocmask(oset)", ARG3
, sizeof(vki_sigset_t
));
3040 !ML_(safe_to_deref
)((void *)(Addr
)ARG2
, sizeof(vki_sigset_t
))) {
3041 VG_(dmsg
)("Warning: Bad set handler address %p in sigprocmask\n",
3042 (void *)(Addr
)ARG2
);
3043 SET_STATUS_Failure ( VKI_EFAULT
);
3044 } else if (ARG3
!= 0 &&
3045 !ML_(safe_to_deref
)((void *)(Addr
)ARG3
, sizeof(vki_sigset_t
))) {
3046 VG_(dmsg
)("Warning: Bad oldset address %p in sigprocmask\n",
3047 (void *)(Addr
)ARG3
);
3048 SET_STATUS_Failure ( VKI_EFAULT
);
3050 SET_STATUS_from_SysRes(VG_(do_sys_sigprocmask
)(tid
, ARG1
/*how*/,
3051 (vki_sigset_t
*)(Addr
)ARG2
,
3052 (vki_sigset_t
*)(Addr
)ARG3
));
3056 *flags
|= SfPollAfter
;
3059 POST(sys_sigprocmask
)
3062 if (RES
== 0 && ARG3
!= 0)
3063 POST_MEM_WRITE( ARG3
, sizeof(vki_sigset_t
));
3066 // SYS_sigsuspend 341
3067 // int sigsuspend(const sigset_t *sigmask);
3070 *flags
|= SfMayBlock
;
3071 PRINT("sys_sigsuspend ( %#" FMT_REGWORD
"x )", ARG1
);
3072 PRE_REG_READ1(int, "sigsuspend", const vki_sigset_t
*, sigmask
);
3073 PRE_MEM_READ( "sigsuspend(sigmask)", ARG1
, sizeof(vki_sigset_t
) );
3075 ARG1
= ML_(make_safe_mask
)("syswrap.sigsuspend.1", (Addr
)ARG1
);
3079 POST(sys_sigsuspend
)
3081 ML_(free_safe_mask
) ( (Addr
)ARG1
);
3084 // SYS_sigpending 343
3085 // int sigpending(sigset_t *set);
3088 PRINT( "sys_sigpending ( %#" FMT_REGWORD
"x )", ARG1
);
3089 PRE_REG_READ1(int, "sigpending", vki_sigset_t
*, set
);
3090 PRE_MEM_WRITE( "sigpending(set)", ARG1
, sizeof(vki_sigset_t
));
3093 POST(sys_sigpending
)
3095 POST_MEM_WRITE( ARG1
, sizeof(vki_sigset_t
) ) ;
3099 // SYS_sigtimedwait 345
3100 // int sigtimedwait(const sigset_t *restrict set, siginfo_t *restrict info,
3101 // const struct timespec *restrict timeout);
3102 PRE(sys_sigtimedwait
)
3104 *flags
|= SfMayBlock
;
3105 PRINT("sys_sigtimedwait ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",
3107 PRE_REG_READ3(int, "sigtimedwait",
3108 const vki_sigset_t
*, set
, vki_siginfo_t
*, info
,
3109 const struct timespec
*, timeout
);
3111 PRE_MEM_READ( "sigtimedwait(set)", ARG1
, sizeof(vki_sigset_t
));
3113 PRE_MEM_WRITE( "sigtimedwait(info)", ARG2
, sizeof(vki_siginfo_t
) );
3115 PRE_MEM_READ( "sigtimedwait(timeout)",
3116 ARG3
, sizeof(struct vki_timespec
) );
3119 POST(sys_sigtimedwait
)
3122 POST_MEM_WRITE( ARG2
, sizeof(vki_siginfo_t
) );
3125 // SYS_sigwaitinfo 346
3126 // int sigwaitinfo(const sigset_t * restrict set, siginfo_t * restrict info);
3127 PRE(sys_sigwaitinfo
)
3129 *flags
|= SfMayBlock
;
3130 PRINT("sys_sigwaitinfo ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",
3132 PRE_REG_READ2(int, "sigwaitinfo",
3133 const vki_sigset_t
*, set
, vki_siginfo_t
*, info
);
3135 PRE_MEM_READ( "sigwaitinfo(set)", ARG1
, sizeof(vki_sigset_t
));
3137 PRE_MEM_WRITE( "sigwaitinfo(info)", ARG2
, sizeof(vki_siginfo_t
) );
3140 POST(sys_sigwaitinfo
)
3143 POST_MEM_WRITE( ARG2
, sizeof(vki_siginfo_t
) );
3146 // SYS___acl_get_file 347
3147 // int __acl_get_file(const char *path, acl_type_t type, struct acl *aclp);
3148 PRE(sys___acl_get_file
)
3150 PRINT("sys___acl_get_file ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,(char *)ARG1
,ARG2
,ARG3
);
3151 PRE_REG_READ3(int, "acl_get_file",
3152 const char *, path
, int, type
, struct vki_acl
*, aclp
);
3153 PRE_MEM_RASCIIZ("acl_get_file(path", ARG1
);
3154 PRE_MEM_WRITE( "acl_get_file(aclp)", ARG3
, sizeof(struct vki_acl
) );
3157 POST(sys___acl_get_file
)
3161 POST_MEM_WRITE( ARG3
, sizeof(struct vki_acl
) );
3165 // SYS___acl_set_file 348
3166 // int __acl_set_file(const char *path, acl_type_t type, struct acl *aclp);
3167 PRE(sys___acl_set_file
)
3169 PRINT("sys___acl_set_file ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,(char *)ARG1
,ARG2
,ARG3
);
3170 PRE_REG_READ3(int, "acl_set_file",
3171 const char *, path
, int, type
, struct vki_acl
*, aclp
);
3172 PRE_MEM_RASCIIZ("acl_set_file(path", ARG1
);
3173 PRE_MEM_READ("acl_set_file(aclp)", ARG3
, sizeof(struct vki_acl
) );
3176 // SYS___acl_get_fd 349
3177 // int __acl_get_fd(int filedes, acl_type_t type, struct acl *aclp);
3178 PRE(sys___acl_get_fd
)
3180 PRINT("sys___acl_get_fd ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
,ARG3
);
3181 PRE_REG_READ3(int, "acl_get_fd",
3182 int, fd
, int, type
, struct vki_acl
*, aclp
);
3183 PRE_MEM_WRITE( "acl_get_file(aclp)", ARG3
, sizeof(struct vki_acl
) );
3186 POST(sys___acl_get_fd
)
3190 POST_MEM_WRITE( ARG3
, sizeof(struct vki_acl
) );
3194 // SYS___acl_set_fd 350
3195 // int __acl_set_fd(int filedes, acl_type_t type, struct acl *aclp);
3196 PRE(sys___acl_set_fd
)
3198 PRINT("sys___acl_set_fd ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
,ARG3
);
3199 PRE_REG_READ3(int, "acl_set_fd",
3200 int, filedes
, int, type
, struct vki_acl
*, aclp
);
3201 PRE_MEM_READ( "acl_get_file(aclp)", ARG3
, sizeof(struct vki_acl
) );
3204 // SYS___acl_delete_file 351
3205 // int __acl_delete_file(const char *path, acl_type_t type);
3206 PRE(sys___acl_delete_file
)
3208 PRINT("sys___acl_delete_file ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u )", ARG1
,(char *)ARG1
,ARG2
);
3209 PRE_MEM_RASCIIZ("acl_set_file(path", ARG1
);
3210 PRE_REG_READ2(int, "acl_delete_file",
3211 const char *, path
, int, type
);
3213 // SYS___acl_delete_fd 352
3214 // int __acl_delete_fd(int filedes, acl_type_t type);
3215 PRE(sys___acl_delete_fd
)
3217 PRINT("sys___acl_delete_fd ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )", ARG1
,ARG2
);
3218 PRE_REG_READ2(int, "acl_delete_fd",
3219 int, filedes
, int, acltype
);
3222 // SYS___acl_aclcheck_file 353
3223 // int __acl_aclcheck_file(const char *path, acl_type_t type, struct acl *aclp);
3224 PRE(sys___acl_aclcheck_file
)
3226 PRINT("sys___acl_aclcheck_file ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,(char *)ARG1
,ARG2
,ARG3
);
3227 PRE_REG_READ3(int, "acl_aclcheck_file",
3228 const char *, path
, int, type
, struct vki_acl
*, aclp
);
3229 PRE_MEM_RASCIIZ("acl_set_file(path", ARG1
);
3230 PRE_MEM_READ( "acl_aclcheck_file(aclp)", ARG3
, sizeof(struct vki_acl
) );
3233 // SYS___acl_aclcheck_fd 354
3234 // int __acl_aclcheck_fd(int filedes, acl_type_t type, struct acl *aclp);
3235 PRE(sys___acl_aclcheck_fd
)
3237 PRINT("sys___acl_aclcheck_fd ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
,ARG3
);
3238 PRE_REG_READ3(int, "acl_aclcheck_fd",
3239 int, fd
, int, type
, struct vki_acl
*, aclp
);
3240 PRE_MEM_READ( "acl_aclcheck_fd(aclp)", ARG3
, sizeof(struct vki_acl
) );
3243 // SYS_extattrctl 355
3245 // syscalls.master: int extattrctl(_In_z_ const char *path, int cmd, _In_z_opt_ const char *filename, int attrnamespace, _In_z_ const char *attrname);
3248 PRINT("sys_extattrctl ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", ARG1
,SARG2
,ARG3
,SARG4
,ARG5
);
3249 PRE_REG_READ5(ssize_t
, "extattrctl",
3250 const char *, path
, int, cmd
, const char *, filename
, int, attrnamespace
, const char *, attrname
);
3251 PRE_MEM_RASCIIZ("extattrctl(path)", ARG1
);
3252 PRE_MEM_RASCIIZ("extattrctl(filename)", ARG3
);
3253 PRE_MEM_RASCIIZ("extattrctl(attrname)", ARG5
);
3256 // SYS_extattr_set_file 356
3257 // ssize_t extattr_set_file(const char *path, int attrnamespace,
3258 // const char *attrname, const void *data, size_t nbytes);
3259 PRE(sys_extattr_set_file
)
3261 PRINT("sys_extattr_set_file ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
,SARG2
,ARG3
,ARG4
,ARG5
);
3262 PRE_REG_READ5(ssize_t
, "extattr_set_file",
3263 const char *, path
, int, attrnamespace
, const char *, attrname
, const void *, data
, size_t, nbytes
);
3264 PRE_MEM_RASCIIZ("extattr_set_file(path)", ARG1
);
3265 PRE_MEM_RASCIIZ("extattr_set_file(attrname)", ARG3
);
3266 PRE_MEM_READ("extattr_set_file(data)", ARG4
, ARG5
);
3269 // SYS_extattr_get_file 357
3270 // ssize_t extattr_get_file(const char *path, int attrnamespace,
3271 // const char *attrname, void *data, size_t nbytes);
3272 PRE(sys_extattr_get_file
)
3274 PRINT("sys_extattr_get_file ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
,SARG2
,ARG3
,ARG4
,ARG5
);
3275 PRE_REG_READ5(ssize_t
, "extattr_get_file",
3276 const char *, path
, int, attrnamespace
, const char *, attrname
, void *, data
, size_t, nbytes
);
3277 PRE_MEM_RASCIIZ("extattr_get_file(path)", ARG1
);
3278 PRE_MEM_RASCIIZ("extattr_get_file(attrname)", ARG3
);
3280 PRE_MEM_WRITE("extattr_get_file(data)", ARG4
, ARG5
);
3284 POST(sys_extattr_get_file
)
3287 POST_MEM_WRITE(ARG4
, ARG5
);
3291 // SYS_extattr_delete_file 358
3292 // int extattr_delete_file(const char *path, int attrnamespace,
3293 // const char *attrname);
3294 PRE(sys_extattr_delete_file
)
3296 PRINT("sys_extattr_delete_file ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", ARG1
,SARG2
,ARG3
);
3297 PRE_REG_READ3(ssize_t
, "extattr_delete_file",
3298 const char *, path
, int, attrnamespace
, const char *, attrname
);
3299 PRE_MEM_RASCIIZ("extattr_delete_file(path)", ARG1
);
3300 PRE_MEM_RASCIIZ("extattr_delete_file(attrname)", ARG3
);
3303 // SYS_aio_waitcomplete 359
3304 // ssize_t aio_waitcomplete(struct aiocb **iocbp, struct timespec *timeout);
3305 PRE(sys_aio_waitcomplete
)
3307 *flags
|= SfMayBlock
;
3308 PRINT("sys_aio_waitcomplete ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )", ARG1
,ARG2
);
3309 PRE_REG_READ2(ssize_t
, "aio_waitcomplete", struct aiocb
**, iocbp
, struct timespec
*, timeout
);
3311 PRE_MEM_READ("aio_waitcomplete(timeout", ARG2
, sizeof(struct vki_timespec
));
3313 PRE_MEM_WRITE( "aio_waitcomplete(iocbp)", ARG1
, sizeof(struct aiocb
*));
3316 POST(sys_aio_waitcomplete
)
3318 POST_MEM_WRITE(ARG1
, sizeof(struct aiocb
*));
3321 // SYS_getresuid 360
3322 // int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
3325 PRINT("sys_getresuid ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )", ARG1
,ARG2
,ARG3
);
3326 PRE_REG_READ3(long, "getresuid",
3327 vki_uid_t
*, ruid
, vki_uid_t
*, euid
, vki_uid_t
*, suid
);
3328 PRE_MEM_WRITE( "getresuid(ruid)", ARG1
, sizeof(vki_uid_t
) );
3329 PRE_MEM_WRITE( "getresuid(euid)", ARG2
, sizeof(vki_uid_t
) );
3330 PRE_MEM_WRITE( "getresuid(suid)", ARG3
, sizeof(vki_uid_t
) );
3337 POST_MEM_WRITE( ARG1
, sizeof(vki_uid_t
) );
3338 POST_MEM_WRITE( ARG2
, sizeof(vki_uid_t
) );
3339 POST_MEM_WRITE( ARG3
, sizeof(vki_uid_t
) );
3343 // SYS_getresgid 361
3344 // int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
3347 PRINT("sys_getresgid ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )", ARG1
,ARG2
,ARG3
);
3348 PRE_REG_READ3(long, "getresgid",
3349 vki_gid_t
*, rgid
, vki_gid_t
*, egid
, vki_gid_t
*, sgid
);
3350 PRE_MEM_WRITE( "getresgid(rgid)", ARG1
, sizeof(vki_gid_t
) );
3351 PRE_MEM_WRITE( "getresgid(egid)", ARG2
, sizeof(vki_gid_t
) );
3352 PRE_MEM_WRITE( "getresgid(sgid)", ARG3
, sizeof(vki_gid_t
) );
3359 POST_MEM_WRITE( ARG1
, sizeof(vki_gid_t
) );
3360 POST_MEM_WRITE( ARG2
, sizeof(vki_gid_t
) );
3361 POST_MEM_WRITE( ARG3
, sizeof(vki_gid_t
) );
3366 // int kqueue(void);
3369 PRINT("%s", "sys_kqueue ()");
3370 PRE_REG_READ0(omt
, "kqueue");
3375 if (!ML_(fd_allowed
)(RES
, "kqueue", tid
, True
)) {
3377 SET_STATUS_Failure( VKI_EMFILE
);
3379 if (VG_(clo_track_fds
)) {
3380 ML_(record_fd_open_nameless
)(tid
, RES
);
3385 // SYS_freebsd11_kevent 363
3386 // int kevent(int kq, const struct kevent *changelist, int nchanges,
3387 // struct kevent *eventlist, int nevents,
3388 // const struct timespec *timeout);
3389 #if (FREEBSD_VERS >= FREEBSD_12)
3390 PRE(sys_freebsd11_kevent
)
3392 PRINT("sys_freebsd11_kevent ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )\n", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
3393 PRE_REG_READ6(int, "kevent",
3394 int, fd
, const struct vki_kevent_freebsd11
*, changelist
, int, nchanges
,
3395 struct vki_kevent_freebsd11
*, eventlist
, int, nevents
,
3396 struct timespec
*, timeout
);
3397 if (ARG2
!= 0 && ARG3
!= 0)
3398 PRE_MEM_READ( "kevent(changelist)", ARG2
, sizeof(struct vki_kevent_freebsd11
)*ARG3
);
3399 if (ARG4
!= 0 && ARG5
!= 0)
3400 PRE_MEM_WRITE( "kevent(eventlist)", ARG4
, sizeof(struct vki_kevent_freebsd11
)*ARG5
);
3402 *flags
|= SfMayBlock
;
3404 PRE_MEM_READ( "kevent(timeout)",
3405 ARG6
, sizeof(struct vki_timespec
));
3408 POST(sys_freebsd11_kevent
)
3411 if ((Word
)RES
!= -1) {
3413 POST_MEM_WRITE( ARG4
, sizeof(struct vki_kevent_freebsd11
)*RES
) ;
3419 *flags
|= SfMayBlock
;
3420 PRINT("sys_kevent ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )\n", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
3421 PRE_REG_READ6(int, "kevent",
3422 int, fd
, struct vki_kevent_freebsd11
*, changelist
, int, nchanges
,
3423 struct vki_kevent_freebsd11
*, eventlist
, int, nevents
,
3424 struct timespec
*, timeout
);
3425 if (ARG2
!= 0 && ARG3
!= 0)
3426 PRE_MEM_READ( "kevent(changelist)", ARG2
, sizeof(struct vki_kevent_freebsd11
)*ARG3
);
3427 if (ARG4
!= 0 && ARG5
!= 0)
3428 PRE_MEM_WRITE( "kevent(eventlist)", ARG4
, sizeof(struct vki_kevent_freebsd11
)*ARG5
);
3430 PRE_MEM_READ( "kevent(timeout)",
3431 ARG6
, sizeof(struct vki_timespec
));
3437 if ((Word
)RES
!= -1) {
3439 POST_MEM_WRITE( ARG4
, sizeof(struct vki_kevent_freebsd11
)*RES
) ;
3444 // SYS_extattr_set_fd 371
3445 // ssize_t extattr_set_fd(int fd, int attrnamespace, const char *attrname,
3446 // const void *data, size_t nbytes);
3447 PRE(sys_extattr_set_fd
)
3449 PRINT("sys_extattr_set_fd ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", SARG1
,SARG2
,ARG3
,ARG4
,ARG5
);
3450 PRE_REG_READ5(int, "extattr_set_fd", int, fd
, int, attrnamespace
, const char *,attrname
, const void *,data
, size_t, nbytes
);
3451 PRE_MEM_RASCIIZ( "extattr_set_fd(attrname)", ARG3
);
3452 PRE_MEM_READ("extattr_set_fd(data)", ARG4
, ARG5
);
3455 // SYS_extattr_get_fd 372
3456 // ssize_t extattr_get_fd(int fd, int attrnamespace, const char *attrname,
3457 // void *data, size_t nbytes);
3458 PRE(sys_extattr_get_fd
)
3460 PRINT("sys_extattr_get_fd ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", SARG1
,SARG2
,ARG3
,ARG4
,ARG5
);
3461 PRE_REG_READ5(int, "extattr_get_fd", int, fd
, int, attrnamespace
, const char *,attrname
, const void *,data
, size_t, nbytes
);
3462 PRE_MEM_RASCIIZ( "extattr_get_fd(attrname)", ARG3
);
3463 PRE_MEM_WRITE("extattr_get_fd(data)", ARG4
, ARG5
);
3466 POST(sys_extattr_get_fd
)
3468 POST_MEM_WRITE(ARG4
, ARG5
);
3471 // SYS_extattr_delete_fd 373
3472 // int extattr_delete_fd(int fd, int attrnamespace, const char *attrname);
3473 PRE(sys_extattr_delete_fd
)
3475 PRINT("sys_extattr_delete_fd ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
,SARG2
,ARG3
);
3476 PRE_REG_READ3(int, "extattr_delete_fd", int, fd
, int, attrnamespace
, const char *,attrname
);
3477 PRE_MEM_RASCIIZ( "extattr_delete_fd(attrname)", ARG3
);
3480 // SYS___setugid 374
3482 // syscalls.master: int __setugid(int flag);
3485 PRINT("sys___setugid ( %" FMT_REGWORD
"d )", SARG1
);
3486 PRE_REG_READ1(int, "__setugid", int, flag
);
3490 // int eaccess(const char *path, int mode);
3493 PRINT("sys_eaccess ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u )", ARG1
,(char*)ARG1
,ARG2
);
3494 PRE_REG_READ2(int, "eaccess", const char *, path
, int, mode
);
3495 PRE_MEM_RASCIIZ( "eaccess(path)", ARG1
);
3498 // SYS_afs3_syscall 377
3502 // int nmount(struct iovec *iov, u_int niov, int flags);
3505 PRINT("sys_nmount ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"d )", ARG1
, ARG2
, SARG3
);
3506 PRE_REG_READ3(int, "nmount", struct iovec
*, iov
, u_int
, niov
, int, flags
);
3507 PRE_MEM_READ( "nmount(pathname)", ARG1
, ARG2
*sizeof(struct vki_iovec
) );
3510 // SYS___mac_get_proc 384
3513 // SYS___mac_set_proc 385
3516 // SYS___mac_get_fd 386
3519 // SYS___mac_get_file 387
3522 // SYS___mac_set_fd 388
3525 // SYS___mac_set_file 389
3529 // int kenv(int action, const char *name, char *value, int len);
3532 PRINT("sys_kenv ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
,ARG2
,ARG3
,ARG4
);
3533 PRE_REG_READ4(int, "kenv",
3534 int, action
, const char *, name
, char *, value
, int, len
);
3538 case VKI_KENV_UNSET
:
3539 PRE_MEM_RASCIIZ("kenv(name)", ARG2
);
3544 VG_(dmsg
)("Warning: Bad action %" FMT_REGWORD
"u in kenv\n", ARG1
);
3553 POST_MEM_WRITE(ARG3
, ARG4
);
3556 if (ARG3
!= (Addr
)NULL
)
3557 POST_MEM_WRITE(ARG3
, ARG4
);
3564 // int lchflags(const char *path, unsigned long flags);
3567 PRINT("sys_lchflags ( %#" FMT_REGWORD
"x(%s), 0x%" FMT_REGWORD
"x )", ARG1
,(char *)ARG1
,ARG2
);
3568 PRE_REG_READ2(int, "lchflags",
3569 const char *, path
, unsigned long, flags
);
3570 PRE_MEM_RASCIIZ( "lchflags(path)", ARG1
);
3574 // int uuidgen(struct uuid *store, int count);
3577 PRINT("sys_uuidgen ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
,ARG2
);
3578 PRE_REG_READ2(int, "uuidgen",
3579 struct vki_uuid
*, store
, int, count
);
3580 PRE_MEM_WRITE( "uuidgen(store)", ARG1
, ARG2
* sizeof(struct vki_uuid
));
3586 POST_MEM_WRITE( ARG1
, ARG2
* sizeof(struct vki_uuid
) );
3592 // SYS_mac_syscall 394
3595 #if (FREEBSD_VERS >= FREEBSD_12)
3597 // SYS_freebsd11_getfsstat 395
3598 // int getfsstat(struct freebsd11_statfs *buf, long bufsize, int mode);
3600 PRE(sys_freebsd11_getfsstat
)
3602 PRINT("sys_freebsd11_getfsstat ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
3603 PRE_REG_READ3(int, "getfsstat", struct vki_freebsd11_statfs
*, buf
, long, bufsize
, int, mode
);
3604 PRE_MEM_WRITE( "getfsstat(buf)", ARG1
, ARG2
);
3607 POST(sys_freebsd11_getfsstat
)
3610 if ((Word
)RES
!= -1) {
3611 POST_MEM_WRITE( ARG1
, RES
* sizeof(struct vki_freebsd11_statfs
) );
3615 // SYS_freebsd11_statfs 396
3616 // int statfs(const char *path, struct statfs *buf);
3617 PRE(sys_freebsd11_statfs
)
3619 PRINT("sys_statfs ( %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x )",ARG1
,(char *)ARG1
,ARG2
);
3620 PRE_REG_READ2(int, "statfs", const char *, path
, struct statfs
*, buf
);
3621 PRE_MEM_RASCIIZ( "statfs(path)", ARG1
);
3622 PRE_MEM_WRITE( "statfs(buf)", ARG2
, sizeof(struct vki_freebsd11_statfs
) );
3625 POST(sys_freebsd11_statfs
)
3627 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_statfs
) );
3630 // SYS_freebsd11_fstatfs 397
3631 // int fstatfs(int fd, struct statfs *buf);
3632 PRE(sys_freebsd11_fstatfs
)
3634 PRINT("sys_fstatfs ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )",ARG1
,ARG2
);
3635 PRE_REG_READ2(int, "fstatfs",
3636 unsigned int, fd
, struct statfs
*, buf
);
3637 PRE_MEM_WRITE( "fstatfs(buf)", ARG2
, sizeof(struct vki_freebsd11_statfs
) );
3640 POST(sys_freebsd11_fstatfs
)
3642 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_statfs
) );
3645 // SYS_freebsd11_fhstatfs 398
3646 // int fhstatfs(const fhandle_t *fhp, struct statfs *buf);
3647 PRE(sys_freebsd11_fhstatfs
)
3649 PRINT("sys_fhstatfs ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",ARG1
,ARG2
);
3650 PRE_REG_READ2(int, "fhstatfs",
3651 struct fhandle
*, fhp
, struct statfs
*, buf
);
3652 PRE_MEM_READ( "fhstatfs(fhp)", ARG1
, sizeof(struct vki_fhandle
) );
3653 PRE_MEM_WRITE( "fhstatfs(buf)", ARG2
, sizeof(struct vki_freebsd11_statfs
) );
3656 POST(sys_freebsd11_fhstatfs
)
3658 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_statfs
) );
3666 PRINT("sys_getfsstat ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
3667 PRE_REG_READ3(int, "getfsstat", struct vki_freebsd11_statfs
*, buf
, long, bufsize
, int, mode
);
3668 PRE_MEM_WRITE( "getfsstat(buf)", ARG1
, ARG2
);
3674 if ((Word
)RES
!= -1) {
3675 POST_MEM_WRITE( ARG1
, RES
* sizeof(struct vki_freebsd11_statfs
) );
3681 PRINT("sys_statfs ( %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x )",ARG1
,(char *)ARG1
,ARG2
);
3682 PRE_REG_READ2(int, "statfs", const char *, path
, struct statfs
*, buf
);
3683 PRE_MEM_RASCIIZ( "statfs(path)", ARG1
);
3684 PRE_MEM_WRITE( "statfs(buf)", ARG2
, sizeof(struct vki_freebsd11_statfs
) );
3689 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_statfs
) );
3694 PRINT("sys_fstatfs ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )",ARG1
,ARG2
);
3695 PRE_REG_READ2(int, "fstatfs",
3696 unsigned int, fd
, struct statfs
*, buf
);
3697 PRE_MEM_WRITE( "fstatfs(buf)", ARG2
, sizeof(struct vki_freebsd11_statfs
) );
3702 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_statfs
) );
3707 PRINT("sys_fhstatfs ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",ARG1
,ARG2
);
3708 PRE_REG_READ2(int, "fhstatfs",
3709 struct fhandle
*, fhp
, struct statfs
*, buf
);
3710 PRE_MEM_READ( "fhstatfs(fhp)", ARG1
, sizeof(struct vki_fhandle
) );
3711 PRE_MEM_WRITE( "fhstatfs(buf)", ARG2
, sizeof(struct vki_freebsd11_statfs
) );
3716 POST_MEM_WRITE( ARG2
, sizeof(struct vki_freebsd11_statfs
) );
3722 // SYS_ksem_close 400
3725 // SYS_ksem_post 401
3728 // SYS_ksem_wait 402
3731 // SYS_ksem_trywait 403
3734 // SYS_ksem_init 404
3737 // SYS_ksem_open 405
3740 // SYS_ksem_unlink 406
3743 // SYS_ksem_getvalue 407
3746 // SYS_ksem_destroy 408
3749 // SYS___mac_get_pid 409
3752 // SYS___mac_get_link 410
3755 // SYS___mac_set_link 411
3758 // SYS_extattr_set_link 412
3759 // ssize_t extattr_set_link(const char *path, int attrnamespace,
3760 // const char *attrname, const void *data, size_t nbytes);
3761 PRE(sys_extattr_set_link
)
3763 PRINT("sys_extattr_set_link ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
,SARG2
,ARG3
,ARG4
,ARG5
);
3764 PRE_REG_READ5(ssize_t
, "extattr_set_link",
3765 const char *, path
, int, attrnamespace
, const char *, attrname
, const void *, data
, size_t, nbytes
);
3766 PRE_MEM_RASCIIZ("extattr_set_link(path)", ARG1
);
3767 PRE_MEM_RASCIIZ("extattr_set_link(attrname)", ARG3
);
3768 PRE_MEM_READ("extattr_set_link(data)", ARG4
, ARG5
);
3771 // SYS_extattr_get_link 413
3772 // ssize_t extattr_get_link(const char *path, int attrnamespace,
3773 // const char *attrname, void *data, size_t nbytes);
3774 PRE(sys_extattr_get_link
)
3776 PRINT("sys_extattr_get_link ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
,SARG2
,ARG3
,ARG4
,ARG5
);
3777 PRE_REG_READ5(ssize_t
, "extattr_get_link",
3778 const char *, path
, int, attrnamespace
, const char *, attrname
, void *, data
, size_t, nbytes
);
3779 PRE_MEM_RASCIIZ("extattr_get_link(path)", ARG1
);
3780 PRE_MEM_RASCIIZ("extattr_get_link(attrname)", ARG3
);
3782 PRE_MEM_WRITE("extattr_get_link(data)", ARG4
, ARG5
);
3786 POST(sys_extattr_get_link
)
3789 POST_MEM_WRITE(ARG4
, ARG5
);
3793 // SYS_extattr_delete_link 414
3794 // int extattr_delete_link(const char *path, int attrnamespace,
3795 // const char *attrname);
3796 PRE(sys_extattr_delete_link
)
3798 PRINT("sys_extattr_delete_link ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", ARG1
,SARG2
,ARG3
);
3799 PRE_REG_READ3(ssize_t
, "extattr_delete_link",
3800 const char *, path
, int, attrnamespace
, const char *, attrname
);
3801 PRE_MEM_RASCIIZ("extattr_delete_link(path)", ARG1
);
3802 PRE_MEM_RASCIIZ("extattr_delete_link(attrname)", ARG3
);
3805 // SYS___mac_execve 415
3808 // SYS_sigaction 416
3809 //int sigaction(int sig, const struct sigaction * restrict act,
3810 // struct sigaction * restrict oact);
3813 vki_sigaction_toK_t
new, *newp
;
3814 vki_sigaction_fromK_t old
, *oldp
;
3816 PRINT("sys_sigaction ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",
3818 PRE_REG_READ3(long, "sigaction",
3819 int, sign
, const struct sigaction
*, act
,
3820 struct sigaction
*, oact
);
3825 struct vki_sigaction
*sa
= (struct vki_sigaction
*)ARG2
;
3826 PRE_MEM_READ( "sigaction(act->sa_handler)", (Addr
)&sa
->ksa_handler
, sizeof(sa
->ksa_handler
));
3827 PRE_MEM_READ( "sigaction(act->sa_mask)", (Addr
)&sa
->sa_mask
, sizeof(sa
->sa_mask
));
3828 PRE_MEM_READ( "sigaction(act->sa_flags)", (Addr
)&sa
->sa_flags
, sizeof(sa
->sa_flags
));
3832 PRE_MEM_WRITE( "sigaction(oact)", ARG3
, sizeof(struct vki_sigaction
));
3837 && ! ML_(safe_to_deref
)((void *)(Addr
)ARG2
,
3838 sizeof(struct vki_sigaction
))) {
3839 VG_(umsg
)("Warning: bad act handler address %p in sigaction()\n",
3840 (void *)(Addr
)ARG2
);
3841 SET_STATUS_Failure ( VKI_EFAULT
);
3842 } else if ((ARG3
!= 0
3843 && ! ML_(safe_to_deref
)((void *)(Addr
)ARG3
,
3844 sizeof(struct vki_sigaction
)))) {
3845 VG_(umsg
)("Warning: bad oact handler address %p in sigaction()\n",
3846 (void *)(Addr
)ARG3
);
3847 SET_STATUS_Failure ( VKI_EFAULT
);
3850 struct vki_sigaction
*oldnew
=
3851 (struct vki_sigaction
*)(Addr
)ARG2
;
3853 new.ksa_handler
= oldnew
->ksa_handler
;
3854 new.sa_flags
= oldnew
->sa_flags
;
3855 new.sa_mask
= oldnew
->sa_mask
;
3859 SET_STATUS_from_SysRes( VG_(do_sys_sigaction
)(ARG1
, newp
, oldp
) );
3861 if (ARG3
!= 0 && SUCCESS
&& RES
== 0) {
3862 struct vki_sigaction
*oldold
=
3863 (struct vki_sigaction
*)(Addr
)ARG3
;
3865 oldold
->ksa_handler
= oldp
->ksa_handler
;
3866 oldold
->sa_flags
= oldp
->sa_flags
;
3867 oldold
->sa_mask
= oldp
->sa_mask
;
3875 if (RES
== 0 && ARG3
!= 0)
3876 POST_MEM_WRITE( ARG3
, sizeof(struct vki_sigaction
));
3879 // SYS_sigreturn 417
3882 // SYS_getcontext 421
3883 // SYS_setcontext 422
3884 // SYS_swapcontext 423
3887 POST(sys_getcontext
)
3889 POST_MEM_WRITE( ARG1
, sizeof(struct vki_ucontext
) );
3892 POST(sys_swapcontext
)
3895 POST_MEM_WRITE( ARG1
, sizeof(struct vki_ucontext
) );
3898 #if (FREEBSD_VERS >= FREEBSD_13_1)
3899 // SYS_freebsd13_swapoff 424
3900 // int swapoff(const char *special);
3901 PRE(sys_freebsd13_swapoff
)
3903 PRINT("sys_freebsd13_swapoff ( %#" FMT_REGWORD
"x(%s) )", ARG1
,(char *)ARG1
);
3904 PRE_REG_READ1(int, "swapoff", const char *, special
);
3905 PRE_MEM_RASCIIZ( "swapoff(special)", ARG1
);
3909 // int swapoff(const char *special);
3912 PRINT("sys_swapoff ( %#" FMT_REGWORD
"x(%s) )", ARG1
,(char *)ARG1
);
3913 PRE_REG_READ1(int, "swapoff", const char *, special
);
3914 PRE_MEM_RASCIIZ( "swapoff(special)", ARG1
);
3918 // SYS___acl_get_link 425
3919 // int __acl_get_link(const char *path, acl_type_t type, struct acl *aclp);
3920 PRE(sys___acl_get_link
)
3922 PRINT("sys___acl_get_link ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,(char *)ARG1
,ARG2
,ARG3
);
3923 PRE_REG_READ3(int, "__acl_get_link",
3924 const char *, path
, int, acltype
, struct vki_acl
*, aclp
);
3925 PRE_MEM_RASCIIZ( "__acl_get_link(path)", ARG1
);
3926 PRE_MEM_WRITE( "__acl_get_link(aclp)", ARG3
, sizeof(struct vki_acl
) );
3929 POST(sys___acl_get_link
)
3933 POST_MEM_WRITE( ARG3
, sizeof(struct vki_acl
) );
3937 // SYS___acl_set_link 426
3938 // int __acl_set_link(const char *path, acl_type_t type, struct acl *aclp);
3939 PRE(sys___acl_set_link
)
3941 PRINT("sys___acl_set_link ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,(char *)ARG1
,ARG2
,ARG3
);
3942 PRE_REG_READ3(int, "__acl_set_link",
3943 const char *, path
, int, acltype
, struct vki_acl
*, aclp
);
3944 PRE_MEM_RASCIIZ( "__acl_set_link(path)", ARG1
);
3945 PRE_MEM_READ( "__acl_set_link(aclp)", ARG3
, sizeof(struct vki_acl
) );
3947 // SYS___acl_delete_link 427
3948 // int __acl_delete_link(const char *path, acl_type_t type);
3949 PRE(sys___acl_delete_link
)
3951 PRINT("sys___acl_delete_link ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u )", ARG1
,(char *)ARG1
,ARG2
);
3952 PRE_MEM_RASCIIZ( "__acl_delete_link(path)", ARG1
);
3953 PRE_REG_READ2(int, "__acl_delete_link",
3954 const char *, path
, int, acltype
);
3957 // SYS___acl_aclcheck_link 428
3958 // int __acl_aclcheck_link(const char *path, acl_type_t type, struct acl *aclp);
3959 PRE(sys___acl_aclcheck_link
)
3961 PRINT("sys___acl_aclcheck_link ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,(char *)ARG1
,ARG2
,ARG3
);
3962 PRE_REG_READ3(long, "__acl_aclcheck_link",
3963 const char *, path
, int, acltype
, struct vki_acl
*, aclp
);
3964 PRE_MEM_RASCIIZ( "__acl_check_link(path)", ARG1
);
3965 PRE_MEM_READ( "__acl_aclcheck_link(aclp)", ARG3
, sizeof(struct vki_acl
) );
3969 // int sigwait(const sigset_t * restrict set, int * restrict sig);
3972 *flags
|= SfMayBlock
;
3973 PRINT("sys_sigwait ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",
3975 PRE_REG_READ2(int, "sigwait",
3976 const vki_sigset_t
*, set
, int *, sig
);
3978 PRE_MEM_READ( "sigwait(set)", ARG1
, sizeof(vki_sigset_t
));
3980 PRE_MEM_WRITE( "sigwait(sig)", ARG2
, sizeof(int));
3986 POST_MEM_WRITE( ARG2
, sizeof(int));
3989 // SYS_thr_create 430
3991 // syscalls.master: int thr_create(_In_ ucontext_t *ctx, _Out_ long *id, int flags );
3994 PRINT( "sys_thr_create ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d )", ARG1
, ARG2
, SARG3
);
3995 PRE_REG_READ3(int, "thr_create", /*ucontext_t*/void *, ctx
, long *, id
, int, flags
);
3997 VG_(message
)(Vg_UserMsg
, "thr_create() not implemented");
3998 VG_(unimplemented
)("Valgrind does not support thr_create().");
4000 SET_STATUS_Failure(VKI_ENOSYS
);
4004 // void thr_exit(long *state);
4009 PRINT( "sys_thr_exit ( %#" FMT_REGWORD
"x )", ARG1
);
4010 PRE_REG_READ1(void, "thr_exit", long *, state
);
4013 PRE_MEM_WRITE( "thr_exit(state)", ARG1
, sizeof(long) );
4016 tst
= VG_(get_ThreadState
)(tid
);
4017 tst
->exitreason
= VgSrc_ExitThread
;
4018 tst
->os_state
.exitcode
= ARG1
;
4019 SET_STATUS_Success(0);
4023 // int thr_self(long *id);
4026 PRINT( "sys_thr_self ( %#" FMT_REGWORD
"x )", ARG1
);
4027 PRE_REG_READ1(int, "thr_self", long *, id
);
4028 PRE_MEM_WRITE( "thr_self()", ARG1
, sizeof(long));
4033 POST_MEM_WRITE( ARG1
, sizeof(long));
4037 // int thr_kill(long id, int sig);
4040 PRINT("sys_thr_kill ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )", ARG1
,ARG2
);
4041 PRE_REG_READ2(long, "thr_kill", long, id
, int, sig
);
4042 if (!ML_(client_signal_OK
)(ARG2
)) {
4043 SET_STATUS_Failure( VKI_EINVAL
);
4047 /* Check to see if this kill gave us a pending signal */
4048 *flags
|= SfPollAfter
;
4050 if (VG_(clo_trace_signals
))
4051 VG_(message
)(Vg_DebugMsg
, "thr_kill: sending signal %lu to tid %lu\n",
4054 /* If we're sending SIGKILL, check to see if the target is one of
4055 our threads and handle it specially. */
4056 if (ARG2
== VKI_SIGKILL
&& ML_(do_sigkill
)(ARG1
, -1)) {
4057 SET_STATUS_Success(0);
4061 /* Ask to handle this syscall via the slow route, since that's the
4062 only one that sets tst->status to VgTs_WaitSys. If the result
4063 of doing the syscall is an immediate run of
4064 async_signalhandler() in m_signals, then we need the thread to
4065 be properly tidied away. I have the impression the previous
4066 version of this wrapper worked on x86/amd64 only because the
4067 kernel did not immediately deliver the async signal to this
4068 thread (on ppc it did, which broke the assertion re tst->status
4069 at the top of async_signalhandler()). */
4070 *flags
|= SfMayBlock
;
4075 if (VG_(clo_trace_signals
))
4076 VG_(message
)(Vg_DebugMsg
, "thr_kill: sent signal %lu to tid %lu\n",
4080 #if (FREEBSD_VERS <= FREEBSD_10)
4081 // SYS__umtx_lock 434
4084 PRINT( "sys__umtx_lock ( %#" FMT_REGWORD
"x )", ARG1
);
4085 PRE_REG_READ1(long, "_umtx_lock", struct vki_umtx
*, umtx
);
4086 PRE_MEM_READ( "_umtx_lock(mtx)", ARG1
, sizeof(struct vki_umtx
) );
4087 PRE_MEM_WRITE( "_umtx_lock(mtx)", ARG1
, sizeof(struct vki_umtx
) );
4090 POST(sys__umtx_lock
)
4093 POST_MEM_WRITE(ARG1
, sizeof(struct vki_umtx
));
4096 // SYS__umtx_unlock 434
4097 PRE(sys__umtx_unlock
)
4099 PRINT( "sys__umtx_unlock ( %#" FMT_REGWORD
"x )", ARG1
);
4100 PRE_REG_READ1(long, "_umtx_unlock", struct vki_umtx
*, umtx
);
4101 PRE_MEM_READ( "_umtx_unlock(mtx)", ARG1
, sizeof(struct vki_umtx
) );
4102 PRE_MEM_WRITE( "_umtx_unlock(mtx)", ARG1
, sizeof(struct vki_umtx
) );
4105 POST(sys__umtx_unlock
)
4108 POST_MEM_WRITE(ARG1
, sizeof(struct vki_umtx
));
4112 // SYS_jail_attach 436
4113 // int jail_attach(int jid);
4114 PRE(sys_jail_attach
)
4116 PRINT("sys_jail_attach ( %" FMT_REGWORD
"d )", SARG1
);
4117 PRE_REG_READ1(int, "jail_attach", int, jid
);
4120 // SYS_extattr_list_fd 437
4121 // ssize_t extattr_list_fd(int fd, int attrnamespace, void *data, size_t nbytes);
4122 PRE(sys_extattr_list_fd
)
4124 PRINT("extattr_list_fd ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", SARG1
, SARG2
, ARG3
, ARG4
);
4125 PRE_REG_READ4(ssize_t
, "extattr_list_fd", int, id
, int, attrnamespace
, void *,data
, size_t, nbytes
);
4126 PRE_MEM_WRITE("extattr_list_fd(data)", ARG3
, ARG4
);
4129 POST(sys_extattr_list_fd
)
4131 POST_MEM_WRITE(ARG3
, ARG4
);
4134 // SYS_extattr_list_file 438
4135 // ssize_t extattr_list_file(const char *path, int attrnamespace, void *data,
4137 PRE(sys_extattr_list_file
)
4139 PRINT("extattr_list_file ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
, SARG2
, ARG3
, ARG4
);
4140 PRE_REG_READ4(ssize_t
, "extattr_list_file", const char *, path
, int, attrnamespace
, void *,data
, size_t, nbytes
);
4141 PRE_MEM_RASCIIZ("extattr_list_file(path)", ARG1
);
4142 PRE_MEM_WRITE("extattr_list_file(data)", ARG3
, ARG4
);
4145 POST(sys_extattr_list_file
)
4147 POST_MEM_WRITE(ARG3
, ARG4
);
4150 // SYS_extattr_list_link 439
4151 // ssize_t extattr_get_link(const char *path, int attrnamespace,
4152 // const char *attrname, void *data, size_t nbytes);
4153 PRE(sys_extattr_list_link
)
4155 PRINT("extattr_list_link ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
, SARG2
, ARG3
, ARG4
);
4156 PRE_REG_READ4(ssize_t
, "extattr_list_link", const char *, path
, int, attrnamespace
, void *,data
, size_t, nbytes
);
4157 PRE_MEM_RASCIIZ("extattr_list_link(path)", ARG1
);
4158 PRE_MEM_WRITE("extattr_list_link(data)", ARG3
, ARG4
);
4161 POST(sys_extattr_list_link
)
4163 POST_MEM_WRITE(ARG3
, ARG4
);
4166 // SYS_ksem_timedwait 441
4169 // SYS_thr_suspend 442
4170 // int thr_suspend(struct timespec *timeout);
4171 PRE(sys_thr_suspend
)
4173 PRINT("sys_thr_suspend ( %#" FMT_REGWORD
"x )", ARG1
);
4174 PRE_REG_READ1(int, "thr_suspend", struct timespec
*, timeout
);
4175 PRE_MEM_READ("thr_suspend(timeout)", ARG1
, sizeof(struct vki_timespec
));
4177 VG_(message
)(Vg_UserMsg
, "thr_supend() not implemented");
4178 VG_(unimplemented
)("Valgrind does not support thr_suspend().");
4180 SET_STATUS_Failure(VKI_ENOSYS
);
4184 // int thr_wake(long id);
4187 PRINT("sys_thr_wake ( %" FMT_REGWORD
"d )", SARG1
);
4188 PRE_REG_READ1(long, "thr_wake", long, id
);
4190 if (VG_(is_valid_tid)(ARG1)) {
4191 VG_(threads)[ARG1].status = VgTs_Runnable;
4193 SET_STATUS_Failure( VKI_ESRCH );
4198 // SYS_kldunloadf 444
4199 // int kldunloadf(int fileid, int flags);
4202 PRINT("sys_kldunloadf ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d )", SARG1
, SARG2
);
4203 PRE_REG_READ2(int, "kldunloadf", int, fileid
, int, flags
);
4207 // int audit(const char *record, u_int length);
4211 // int auditon(int cmd, void *data, u_int length);
4215 // int getauid(au_id_t *auid);
4219 // int setauid(au_id_t *auid);
4223 // int getaudit(auditinfo_t *auditinfo);
4227 // int setaudit(auditinfo_t *auditinfo);
4230 // SYS_getaudit_addr 451
4231 // int getaudit_addr(auditinfo_addr_t *auditinfo_addr, u_int length);
4234 // SYS_setaudit_addr 452
4235 // int setaudit_addr(auditinfo_addr_t *auditinfo_addr, u_int length);
4242 // int _umtx_op(void *obj, int op, u_long val, void *uaddr, void *uaddr2);
4245 /* 5 args are always passed through. The last two can vary, but
4246 they're always pointers. They may not be used though. */
4248 case VKI_UMTX_OP_LOCK
:
4249 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, LOCK, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4250 PRE_REG_READ5(long, "_umtx_op_lock",
4251 struct umtx
*, obj
, int, op
, unsigned long, id
,
4252 size_t, timeout_size
, struct vki_timespec
*, timeout
);
4253 PRE_MEM_READ( "_umtx_op_lock(mtx)", ARG1
, sizeof(struct vki_umtx
) );
4255 PRE_MEM_READ( "_umtx_op_lock(timespec)", ARG5
, ARG4
);
4256 PRE_MEM_WRITE( "_umtx_op_lock(mtx)", ARG1
, sizeof(struct vki_umtx
) );
4257 *flags
|= SfMayBlock
;
4259 case VKI_UMTX_OP_UNLOCK
:
4260 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, UNLOCK, %" FMT_REGWORD
"u)", ARG1
, ARG3
);
4261 PRE_REG_READ3(long, "_umtx_op_unlock",
4262 struct umtx
*, obj
, int, op
, unsigned long, id
);
4263 PRE_MEM_READ( "_umtx_op_unlock(mtx)", ARG1
, sizeof(struct vki_umtx
) );
4264 PRE_MEM_WRITE( "_umtx_op_unlock(mtx)", ARG1
, sizeof(struct vki_umtx
) );
4266 case VKI_UMTX_OP_WAIT
:
4267 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, WAIT, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4268 PRE_REG_READ5(long, "_umtx_op_wait",
4269 long *, obj
, int, op
, unsigned long, val
,
4270 size_t, timeout_size
, struct vki_timespec
*, timeout
);
4272 PRE_MEM_READ( "_umtx_op_wait(val)", ARG1
, sizeof(long) );
4273 if (*(long*)ARG1
== (long)ARG3
) {
4274 *flags
|= SfMayBlock
;
4279 PRE_MEM_READ( "_umtx_op_wait(timeout)", ARG5
, ARG4
);
4283 case VKI_UMTX_OP_WAKE
:
4284 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, WAKE, %" FMT_REGWORD
"u)", ARG1
, ARG3
);
4285 PRE_REG_READ3(long, "_umtx_op_wake",
4286 struct umtx
*, obj
, int, op
, unsigned long, val
);
4287 PRE_MEM_READ( "_umtx_op_wake(mtx)", ARG1
, sizeof(struct vki_umtx
) );
4289 case VKI_UMTX_OP_MUTEX_TRYLOCK
:
4290 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, MUTEX_TRYLOCK, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4291 PRE_REG_READ5(long, "_umtx_op_mutex_trylock",
4292 struct umutex
*, obj
, int, op
, unsigned long, noid
,
4293 size_t, timeout_size
, struct vki_timespec
*, timeout
);
4294 PRE_MEM_READ( "_umtx_op_mutex_trylock(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4296 PRE_MEM_READ( "_umtx_op_mutex_trylock(timespec)", ARG5
, ARG4
);
4297 PRE_MEM_WRITE( "_umtx_op_mutex_trylock(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4299 case VKI_UMTX_OP_MUTEX_LOCK
:
4300 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, MUTEX_LOCK, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4301 PRE_REG_READ5(long, "_umtx_op_mutex_lock",
4302 struct umutex
*, obj
, int, op
, unsigned long, noid
,
4303 size_t, timeout_size
, struct vki_timespec
*, timeout
);
4304 PRE_MEM_READ( "_umtx_op_mutex_lock(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4306 PRE_MEM_READ( "_umtx_op_mutex_lock(timespec)", ARG5
, ARG4
);
4307 PRE_MEM_WRITE( "_umtx_op_mutex_lock(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4308 *flags
|= SfMayBlock
;
4310 case VKI_UMTX_OP_MUTEX_UNLOCK
:
4311 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, MUTEX_UNLOCK)", ARG1
);
4312 PRE_REG_READ2(long, "_umtx_op_mutex_unlock",
4313 struct umutex
*, obj
, int, op
);
4314 PRE_MEM_READ( "_umtx_op_mutex_unlock(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4315 PRE_MEM_WRITE( "_umtx_op_mutex_unlock(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4317 case VKI_UMTX_OP_SET_CEILING
:
4318 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, SET_CEILING, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
);
4319 PRE_REG_READ4(long, "_umtx_op_set_ceiling",
4320 struct umutex
*, obj
, int, op
, unsigned int, ceiling
,
4321 unsigned int *, old_ceiling
);
4322 PRE_MEM_READ( "_umtx_op_set_ceiling(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4323 PRE_MEM_WRITE( "_umtx_op_set_ceiling(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4325 PRE_MEM_WRITE( "_umtx_op_set_ceiling(old_ceiling)", ARG4
, sizeof(vki_uint32_t
) );
4327 case VKI_UMTX_OP_CV_WAIT
:
4328 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, CV_WAIT, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4329 PRE_REG_READ5(long, "_umtx_op_cv_wait",
4330 struct ucond
*, obj
, int, op
, unsigned long, wflags
,
4331 struct umutex
*, umtx
, struct vki_timespec
*, timeout
);
4332 PRE_MEM_READ( "_umtx_op_cv_wait(cond)", ARG1
, sizeof(struct vki_ucond
) );
4333 PRE_MEM_WRITE( "_umtx_op_cv_wait(cond)", ARG1
, sizeof(struct vki_ucond
) );
4334 PRE_MEM_READ( "_umtx_op_cv_wait(mutex)", ARG4
, sizeof(struct vki_umutex
) );
4335 PRE_MEM_WRITE( "_umtx_op_cv_wait(mutex)", ARG4
, sizeof(struct vki_umutex
) );
4337 PRE_MEM_READ( "_umtx_op_cv_wait(timespec)", ARG5
, sizeof(struct vki_timespec
) );
4338 *flags
|= SfMayBlock
;
4340 case VKI_UMTX_OP_CV_SIGNAL
:
4341 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, CV_SIGNAL)", ARG1
);
4342 PRE_REG_READ2(long, "_umtx_op_cv_signal",
4343 struct ucond
*, obj
, int, op
);
4344 PRE_MEM_READ( "_umtx_op_cv_signal(cond)", ARG1
, sizeof(struct vki_ucond
) );
4345 PRE_MEM_WRITE( "_umtx_op_cv_signal(cond)", ARG1
, sizeof(struct vki_ucond
) );
4347 case VKI_UMTX_OP_CV_BROADCAST
:
4348 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, CV_BROADCAST, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4349 PRE_REG_READ2(long, "_umtx_op_cv_broadcast",
4350 struct ucond
*, obj
, int, op
);
4351 PRE_MEM_READ( "_umtx_op_cv_broadcast(cond)", ARG1
, sizeof(struct vki_ucond
) );
4352 PRE_MEM_WRITE( "_umtx_op_cv_broadcast(cond)", ARG1
, sizeof(struct vki_ucond
) );
4354 case VKI_UMTX_OP_WAIT_UINT
:
4355 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, CV_WAIT_UINT, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4356 PRE_REG_READ5(long, "_umtx_op_wait_uint",
4357 int *, obj
, int, op
, unsigned long, id
,
4358 size_t, timeout_wait
, struct vki_timespec
*, timeout
);
4359 PRE_MEM_READ( "_umtx_op_wait(uint)", ARG1
, sizeof(int) );
4361 PRE_MEM_READ( "_umtx_op_wait(timespec)", ARG5
, ARG4
);
4362 *flags
|= SfMayBlock
;
4364 case VKI_UMTX_OP_RW_RDLOCK
:
4365 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, RW_RDLOCK, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4366 PRE_REG_READ5(long, "_umtx_op_rw_rdlock",
4367 struct urwlock
*, obj
, int, op
, unsigned long, noid
,
4368 void *, zero
, struct vki_timespec
*, timeout
);
4369 PRE_MEM_READ( "_umtx_op_rw_rdlock(rw)", ARG1
, sizeof(struct vki_urwlock
) );
4370 PRE_MEM_WRITE( "_umtx_op_rw_rdlock(rw)", ARG1
, sizeof(struct vki_urwlock
) );
4371 *flags
|= SfMayBlock
;
4373 case VKI_UMTX_OP_RW_WRLOCK
:
4374 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, RW_WRLOCK, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4375 PRE_REG_READ5(long, "_umtx_op_rw_wrlock",
4376 struct urwlock
*, obj
, int, op
, unsigned long, noid
,
4377 void *, zero
, struct vki_timespec
*, timeout
);
4378 PRE_MEM_READ( "_umtx_op_rw_wrlock(rw)", ARG1
, sizeof(struct vki_urwlock
) );
4379 PRE_MEM_WRITE( "_umtx_op_rw_wrlock(rw)", ARG1
, sizeof(struct vki_urwlock
) );
4380 *flags
|= SfMayBlock
;
4382 case VKI_UMTX_OP_RW_UNLOCK
:
4383 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, RW_UNLOCK, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4384 PRE_REG_READ2(long, "_umtx_op_rw_unlock",
4385 struct urwlock
*, obj
, int, op
);
4386 PRE_MEM_READ( "_umtx_op_rw_unlock(rw)", ARG1
, sizeof(struct vki_urwlock
) );
4387 PRE_MEM_WRITE( "_umtx_op_rw_unlock(rw)", ARG1
, sizeof(struct vki_urwlock
) );
4389 case VKI_UMTX_OP_WAIT_UINT_PRIVATE
:
4390 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, CV_WAIT_UINT_PRIVATE, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4391 PRE_REG_READ5(long, "_umtx_op_wait_uint_private",
4392 int *, obj
, int, op
, unsigned long, id
,
4393 size_t, timeout_size
, struct vki_timespec
*, timeout
);
4394 PRE_MEM_READ( "_umtx_op_wait_private(uint)", ARG1
, sizeof(int) );
4396 PRE_MEM_READ( "_umtx_op_wait_private(umtx_time)", ARG5
, ARG4
);
4397 *flags
|= SfMayBlock
;
4399 case VKI_UMTX_OP_WAKE_PRIVATE
:
4400 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, CV_WAKE_PRIVATE, %" FMT_REGWORD
"u)", ARG1
, ARG3
);
4401 PRE_REG_READ3(long, "_umtx_op_wake_private",
4402 struct umtx
*, obj
, int, op
, unsigned long, id
);
4403 PRE_MEM_READ( "_umtx_op_wake_private(mtx)", ARG1
, sizeof(struct vki_umtx
) );
4405 case VKI_UMTX_OP_MUTEX_WAIT
:
4406 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, MUTEX_WAIT, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4407 PRE_REG_READ2(long, "_umtx_op_mutex_wait",
4408 struct umutex
*, obj
, int, op
);
4409 PRE_MEM_READ( "_umtx_op_mutex_wait(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4410 PRE_MEM_WRITE( "_umtx_op_mutex_wait(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4411 *flags
|= SfMayBlock
;
4413 case VKI_UMTX_OP_MUTEX_WAKE
:
4414 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, MUTEX_WAKE, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4415 PRE_REG_READ2(long, "_umtx_op_mutex_wake",
4416 struct umutex
*, obj
, int, op
);
4417 PRE_MEM_READ( "_umtx_op_mutex_wake(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4418 PRE_MEM_WRITE( "_umtx_op_mutex_wake(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4420 case VKI_UMTX_OP_SEM_WAIT
:
4421 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, SEM_WAIT, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4422 PRE_REG_READ5(long, "_umtx_op_sem_wait",
4423 struct usem
*, obj
, int, op
, unsigned long, id
,
4424 size_t, timeout_size
, struct vki_timespec
*, timeout
);
4425 PRE_MEM_READ( "_umtx_op_sem_wait(usem)", ARG1
, sizeof(struct vki_usem
) );
4426 PRE_MEM_WRITE( "_umtx_op_sem_wait(usem)", ARG1
, sizeof(struct vki_usem
) );
4428 PRE_MEM_READ( "_umtx_op_sem_wait(umtx_time)", ARG5
, ARG4
);
4429 *flags
|= SfMayBlock
;
4431 case VKI_UMTX_OP_SEM_WAKE
:
4432 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, SEM_WAKE, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4433 PRE_REG_READ2(long, "_umtx_op_sem_wake",
4434 struct umutex
*, obj
, int, op
);
4435 PRE_MEM_READ( "_umtx_op_sem_wake(mutex)", ARG1
, sizeof(struct vki_usem
) );
4436 PRE_MEM_WRITE( "_umtx_op_sem_wake(mutex)", ARG1
, sizeof(struct vki_usem
) );
4438 case VKI_UMTX_OP_NWAKE_PRIVATE
:
4439 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, NWAKE_PRIVATE, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4440 PRE_REG_READ3(long, "_umtx_op_nwake_private",
4441 struct umutex
*, obj
, int, op
, int, count
);
4442 PRE_MEM_READ( "_umtx_op_nwake_private(mtxs)", ARG1
, ARG3
* sizeof(void *) );
4443 PRE_MEM_WRITE( "_umtx_op_mutex_wake(mtxs)", ARG1
, sizeof(struct vki_umutex
) );
4445 case VKI_UMTX_OP_MUTEX_WAKE2
:
4446 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, MUTEX_WAKE2, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4447 PRE_REG_READ3(long, "_umtx_op_mutex_wake2",
4448 struct umutex
*, obj
, int, op
, unsigned long, flags
);
4449 PRE_MEM_READ( "_umtx_op_mutex_wake(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4450 PRE_MEM_WRITE( "_umtx_op_mutex_wake(mutex)", ARG1
, sizeof(struct vki_umutex
) );
4452 case VKI_UMTX_OP_SEM2_WAIT
:
4453 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, SEM2_WAIT, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4454 PRE_REG_READ3(long, "_umtx_op_sem2_wake",
4455 struct _usem2
*, obj
, int, op
, unsigned long, flags
);
4456 PRE_MEM_READ( "_umtx_op_sem2_wait(mutex)", ARG1
, sizeof(struct vki_usem2
) );
4457 PRE_MEM_WRITE( "_umtx_op_sem2_wait(mutex)", ARG1
, sizeof(struct vki_usem2
) );
4458 *flags
|= SfMayBlock
;
4460 case VKI_UMTX_OP_SEM2_WAKE
:
4461 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, SEM2_WAKE, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4462 PRE_REG_READ3(long, "_umtx_op_sem2_wake",
4463 struct _usem2
*, obj
, int, op
, unsigned long, flags
);
4464 PRE_MEM_READ( "_umtx_op_sem2_wait(mutex)", ARG1
, sizeof(struct vki_usem2
) );
4465 PRE_MEM_WRITE( "_umtx_op_sem2_wait(mutex)", ARG1
, sizeof(struct vki_usem2
) );
4467 case VKI_UMTX_OP_SHM
:
4468 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, SHM, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4469 PRE_REG_READ4(long, "_umtx_op_shm",
4470 void *, obj
, int, op
, unsigned long, val
, void*, uaddr
);
4472 case VKI_UMTX_OP_ROBUST_LISTS
:
4473 // val (ARG2) ought to be the same as sizeof(struct vki_umtx_robust_lists_params)
4474 // then the structure contains a pointer to mutex structures
4475 if (ARG1
!= sizeof(struct vki_umtx_robust_lists_params
))
4476 SET_STATUS_Failure( VKI_ENOSYS
);
4477 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, ROBUST_LISTS, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x)", ARG1
, ARG3
, ARG4
, ARG5
);
4478 PRE_REG_READ3(long, "_umtx_op_robust_lists",
4479 struct umtx_robust_lists_params
*, obj
, int, op
, unsigned long, flags
);
4480 PRE_MEM_READ( "_umtx_op_robust_lists(mutex)", ARG3
, sizeof(struct vki_umtx_robust_lists_params
) );
4483 VG_(umsg
)("WARNING: _umtx_op unsupported value.\n");
4484 PRINT( "sys__umtx_op ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u(UNKNOWN), %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )", ARG1
, ARG2
, ARG3
, ARG4
, ARG5
);
4492 case VKI_UMTX_OP_LOCK
:
4494 POST_MEM_WRITE( ARG1
, sizeof(struct vki_umtx
) );
4496 case VKI_UMTX_OP_UNLOCK
:
4498 POST_MEM_WRITE( ARG1
, sizeof(struct vki_umtx
) );
4500 case VKI_UMTX_OP_WAIT
:
4501 case VKI_UMTX_OP_WAKE
:
4502 case VKI_UMTX_OP_WAIT_UINT
:
4503 case VKI_UMTX_OP_WAIT_UINT_PRIVATE
:
4504 case VKI_UMTX_OP_WAKE_PRIVATE
:
4506 case VKI_UMTX_OP_MUTEX_TRYLOCK
:
4507 case VKI_UMTX_OP_MUTEX_LOCK
:
4508 case VKI_UMTX_OP_MUTEX_UNLOCK
:
4509 case VKI_UMTX_OP_MUTEX_WAIT
: /* Sets/clears contested bits */
4510 case VKI_UMTX_OP_MUTEX_WAKE
: /* Sets/clears contested bits */
4512 POST_MEM_WRITE( ARG1
, sizeof(struct vki_umutex
) );
4514 case VKI_UMTX_OP_SET_CEILING
:
4516 POST_MEM_WRITE( ARG1
, sizeof(struct vki_umutex
) );
4518 POST_MEM_WRITE( ARG4
, sizeof(vki_uint32_t
) );
4521 case VKI_UMTX_OP_CV_WAIT
:
4523 POST_MEM_WRITE( ARG1
, sizeof(struct vki_ucond
) );
4524 POST_MEM_WRITE( ARG4
, sizeof(struct vki_umutex
) );
4527 case VKI_UMTX_OP_CV_SIGNAL
:
4529 POST_MEM_WRITE( ARG1
, sizeof(struct vki_ucond
) );
4532 case VKI_UMTX_OP_CV_BROADCAST
:
4534 POST_MEM_WRITE( ARG1
, sizeof(struct vki_ucond
) );
4537 case VKI_UMTX_OP_RW_RDLOCK
:
4538 case VKI_UMTX_OP_RW_WRLOCK
:
4539 case VKI_UMTX_OP_RW_UNLOCK
:
4541 POST_MEM_WRITE( ARG1
, sizeof(struct vki_urwlock
) );
4544 case VKI_UMTX_OP_SEM2_WAIT
:
4545 case VKI_UMTX_OP_SEM2_WAKE
:
4547 POST_MEM_WRITE( ARG1
, sizeof(struct vki_usem2
) );
4550 case VKI_UMTX_OP_SHM
:
4551 case VKI_UMTX_OP_ROBUST_LISTS
:
4561 // int sigqueue(pid_t pid, int signo, const union sigval value);
4564 PRINT("sys_sigqueue ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )",
4566 PRE_REG_READ3(int, "sigqueue", vki_pid_t
, pid
, int, signo
, const union vki_sigval
, value
);
4570 // mqd_t mq_open(const char *name, int oflag, ...);
4571 // int kmq_open(_In_z_ const char *path, int flags, mode_t mode, _In_opt_ const struct mq_attr *attr);
4574 if (ARG2
& VKI_O_CREAT
) {
4575 PRINT("sys_kmq_open( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %hu, %#" FMT_REGWORD
"x )",
4576 ARG1
,(char *)ARG1
,ARG2
,(vki_mode_t
)ARG3
,ARG4
);
4577 PRE_REG_READ4(long, "mq_open",
4578 const char *, name
, int, oflag
, vki_mode_t
, mode
,
4579 struct mq_attr
*, attr
);
4581 PRINT("sys_kmq_open( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %hu)",
4582 ARG1
,(char *)ARG1
,ARG2
,(vki_mode_t
)ARG3
);
4583 PRE_REG_READ3(long, "mq_open",
4584 const char *, name
, int, oflag
, vki_mode_t
, mode
);
4586 PRE_MEM_RASCIIZ( "mq_open(name)", ARG1
);
4587 if (ARG2
& VKI_O_CREAT
) {
4588 PRE_MEM_READ("mq_open(attr)", ARG4
, sizeof(struct vki_mq_attr
));
4589 if (ML_(safe_to_deref
)((struct vki_mq_attr
*)ARG4
, sizeof(struct vki_mq_attr
))) {
4590 const struct vki_mq_attr
*attr
= (struct vki_mq_attr
*)ARG4
;
4591 PRE_MEM_READ("mq_open(attr->mq_maxmsg)",
4592 (Addr
)&attr
->mq_maxmsg
, sizeof(attr
->mq_maxmsg
) );
4593 PRE_MEM_READ("mq_open(attr->mq_msgsize)",
4594 (Addr
)&attr
->mq_msgsize
, sizeof(attr
->mq_msgsize
) );
4602 if (!ML_(fd_allowed
)(RES
, "mq_open", tid
, True
)) {
4604 SET_STATUS_Failure( VKI_EMFILE
);
4606 if (VG_(clo_track_fds
))
4607 ML_(record_fd_open_with_given_name
)(tid
, RES
, (const HChar
*)ARG1
);
4611 // SYS_kmq_setattr 458
4612 // int mq_setattr(mqd_t mqdes, const struct mq_attr *restrict mqstat,
4613 // struct mq_attr *restrict omqstat);
4614 PRE(sys_kmq_setattr
)
4616 PRINT("sys_kmq_getattr( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )", ARG1
,ARG2
,ARG3
);
4617 PRE_REG_READ3(int, "mq_setattr",
4618 vki_mqd_t
, mqdes
, const struct mq_attr
*, mqstat
,
4619 struct mq_attr
*, omqstat
);
4620 if (!ML_(fd_allowed
)(ARG1
, "mq_getattr", tid
, False
)) {
4621 SET_STATUS_Failure( VKI_EBADF
);
4623 if (ML_(safe_to_deref
)((struct vki_mq_attr
*)ARG2
, sizeof(struct vki_mq_attr
))) {
4624 const struct vki_mq_attr
*attr
= (struct vki_mq_attr
*)ARG2
;
4625 PRE_MEM_READ( "mq_setattr(mqstat->mq_flags)",
4626 (Addr
)&attr
->mq_flags
, sizeof(attr
->mq_flags
) );
4628 PRE_MEM_WRITE( "mq_setattr(omqstat)", ARG3
,
4629 sizeof(struct vki_mq_attr
) );
4633 // SYS_kmq_timedreceive 459
4634 // ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
4635 // unsigned *msg_prio, const struct timespec *abs_timeout);
4636 PRE(sys_kmq_timedreceive
)
4638 *flags
|= SfMayBlock
;
4639 PRINT("sys_kmq_timedreceive( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %llu, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",
4640 ARG1
,ARG2
,(ULong
)ARG3
,ARG4
,ARG5
);
4641 PRE_REG_READ5(ssize_t
, "mq_timedreceive",
4642 vki_mqd_t
, mqdes
, char *, msg_ptr
, vki_size_t
, msg_len
,
4643 unsigned int *, msg_prio
,
4644 const struct timespec
*, abs_timeout
);
4645 if (!ML_(fd_allowed
)(ARG1
, "mq_timedreceive", tid
, False
)) {
4646 SET_STATUS_Failure( VKI_EBADF
);
4648 PRE_MEM_WRITE( "mq_timedreceive(msg_ptr)", ARG2
, ARG3
);
4650 PRE_MEM_WRITE( "mq_timedreceive(msg_prio)",
4651 ARG4
, sizeof(unsigned int) );
4653 PRE_MEM_READ( "mq_timedreceive(abs_timeout)",
4654 ARG5
, sizeof(struct vki_timespec
) );
4658 POST(sys_kmq_timedreceive
)
4660 POST_MEM_WRITE( ARG2
, ARG3
);
4662 POST_MEM_WRITE( ARG4
, sizeof(unsigned int) );
4665 // SYS_kmq_timedsend 460
4666 // int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
4667 // unsigned msg_prio, const struct timespec *abs_timeout);
4668 PRE(sys_kmq_timedsend
)
4670 *flags
|= SfMayBlock
;
4671 PRINT("sys_kmq_timedsend ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %llu, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )",
4672 ARG1
,ARG2
,(ULong
)ARG3
,ARG4
,ARG5
);
4673 PRE_REG_READ5(int, "mq_timedsend",
4674 vki_mqd_t
, mqdes
, const char *, msg_ptr
, vki_size_t
, msg_len
,
4675 unsigned int, msg_prio
, const struct timespec
*, abs_timeout
);
4676 if (!ML_(fd_allowed
)(ARG1
, "mq_timedsend", tid
, False
)) {
4677 SET_STATUS_Failure( VKI_EBADF
);
4679 PRE_MEM_READ( "mq_timedsend(msg_ptr)", ARG2
, ARG3
);
4681 PRE_MEM_READ( "mq_timedsend(abs_timeout)", ARG5
,
4682 sizeof(struct vki_timespec
) );
4686 // SYS_kmq_notify 461
4687 // int mq_notify(mqd_t mqdes, const struct sigevent *notification);
4690 PRINT("sys_kmq_notify( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
,ARG2
);
4691 PRE_REG_READ2(int, "mq_notify",
4692 vki_mqd_t
, mqdes
, const struct sigevent
*, notification
);
4693 if (!ML_(fd_allowed
)(ARG1
, "mq_notify", tid
, False
))
4694 SET_STATUS_Failure( VKI_EBADF
);
4696 PRE_MEM_READ( "mq_notify(notification)",
4697 ARG2
, sizeof(struct vki_sigevent
) );
4700 // SYS_kmq_unlink 462
4701 // int kmq_unlink(const char *path);
4704 PRINT("sys_kmq_unlink ( %#" FMT_REGWORD
"x(%s) )", ARG1
,(char *)ARG1
);
4705 PRE_REG_READ1(int, "mq_unlink", const char *, name
);
4706 PRE_MEM_RASCIIZ( "mq_unlink(name)", ARG1
);
4710 // void abort2(const char *why, int nargs, void **args);
4713 PRINT( "sys_abort2 ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", ARG1
, SARG2
, ARG3
);
4714 PRE_REG_READ3(void, "abort2", const char *, why
, int, nargs
, void **, args
);
4715 // max length of 'why' is 128
4716 PRE_MEM_RASCIIZ( "abort2(why)", ARG2
);
4717 // max val for nargs is 16
4718 PRE_MEM_READ("abort2(args", ARG3
, ARG2
*sizeof(void*));
4721 // SYS_thr_set_name 464
4722 // int thr_set_name(long id, const char *name);
4723 PRE(sys_thr_set_name
)
4725 PRINT( "sys_thr_set_name ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
, ARG2
);
4726 PRE_REG_READ2(int, "thr_set_name", long, id
, const char *, name
);
4727 PRE_MEM_RASCIIZ( "thr_set_name(name)", ARG2
);
4729 if (ML_(safe_to_deref
)((void*)ARG2
, 1)) {
4730 const HChar
* new_name
= (const HChar
*) (Addr
)ARG2
;
4731 ThreadState
* tst
= VG_(get_ThreadState
)(tid
);
4732 SizeT new_len
= VG_(strnlen
)(new_name
, VKI_MAXCOMLEN
+1);
4733 tst
->thread_name
= VG_(realloc
)("syswrap.thr_set_name", tst
->thread_name
, new_len
+ 1);
4734 VG_(strlcpy
)(tst
->thread_name
, new_name
, new_len
+ 1);
4738 // SYS_aio_fsync 465
4739 // int aio_fsync(int op, struct aiocb *iocb);
4742 PRINT("aio_fsync ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
,ARG2
);
4743 PRE_REG_READ2(int, "aio_fsync", int, op
, struct vki_aiocb
*, iocb
);
4744 PRE_MEM_READ( "aio_fsync(iocb)", ARG2
, sizeof(struct vki_aiocb
) );
4747 // SYS_rtprio_thread 466
4748 // int rtprio_thread(int function, lwpid_t lwpid, struct rtprio *rtp);
4749 PRE(sys_rtprio_thread
)
4751 PRINT( "sys_rtprio_thread ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", ARG1
, ARG2
, ARG3
);
4752 PRE_REG_READ3(int, "rtprio_thread",
4753 int, function
, __vki_lwpid_t
, lwpid
, struct vki_rtprio
*, rtp
);
4754 if (ARG1
== VKI_RTP_SET
) {
4755 PRE_MEM_READ( "rtprio_thread(rtp#set)", ARG3
, sizeof(struct vki_rtprio
));
4756 } else if (ARG1
== VKI_RTP_LOOKUP
) {
4757 PRE_MEM_WRITE( "rtprio_thread(rtp#lookup)", ARG3
, sizeof(struct vki_rtprio
));
4763 POST(sys_rtprio_thread
)
4765 if (ARG1
== VKI_RTP_LOOKUP
&& RES
== 0)
4766 POST_MEM_WRITE( ARG3
, sizeof(struct vki_rtprio
));
4769 // SYS_sctp_peeloff 471
4770 // int sctp_peeloff(int s, sctp_assoc_t id);
4774 // SYS_sctp_generic_sendmsg 472
4775 // int sctp_generic_sendmsg(int s, void *msg, int msglen, struct sockaddr *to,
4776 // socklen_t len, struct sctp_sndrcvinfo *sinfo, int flags);
4778 // Not called directly from libc
4779 PRE(sys_sctp_generic_sendmsg
)
4781 *flags
|= SfMayBlock
;
4782 PRINT("sys_sctp_generic_sendmsg ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d )",SARG1
,ARG2
,ARG3
,ARG4
,SARG5
,ARG6
,SARG7
);
4783 PRE_REG_READ7(ssize_t
, "sctp_generic_sendmsg",
4784 int, s
, void *, msg
, int, msglen
,
4785 struct sockaddr
*, to
, socklen_t
, len
,
4786 struct sctp_sndrcvinfo
*, sinfo
, int, flags
);
4788 PRE_MEM_READ( "sctp_generic_sendmsg(msg)", ARG2
, ARG3
);
4790 ML_(pre_mem_read_sockaddr
) (tid
, "sctp_generic_sendmsg(to)", (struct vki_sockaddr
*)ARG4
, ARG5
);
4792 if (ARG6
!= (Addr
)NULL
)
4793 PRE_MEM_READ( "sctp_generic_sendmsg(sinfo)", ARG6
, sizeof(struct vki_sctp_sndrcvinfo
));
4796 // SYS_sctp_generic_sendmsg_iov 473
4797 // int sctp_generic_sendmsg_iov(int s, struct iovec *iov, int iovlen,
4798 // struct sockaddr *to, struct sctp_sndrcvinfo *sinfo, int flags);
4801 // SYS_sctp_generic_recvmsg 474
4802 // int sctp_generic_recvmsg(int s, struct iovec *iov, int iovlen,
4803 // struct sockaddr *from, socklen_t *fromlen,
4804 // struct sctp_sndrcvinfo *sinfo, int *msgflags);
4806 // Not called directly from libc
4807 PRE(sys_sctp_generic_recvmsg
)
4809 *flags
|= SfMayBlock
;
4810 PRINT("sys_sctp_generic_recvmsg ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",SARG1
,ARG2
,SARG3
,ARG4
,ARG5
,ARG6
,ARG7
);
4811 PRE_REG_READ7(ssize_t
, "sctp_generic_recvmsg",
4812 int, s
, struct iovec
*, iov
, int, iovlen
,
4813 struct sockaddr
*, from
, socklen_t
*, fromlen
,
4814 struct sctp_sndrcvinfo
*, sinfo
, int *, msgflags
);
4816 // in the sctp_recvmsg libc wrapper this is always 1
4817 if ((Int
)ARG3
> 0) {
4818 PRE_MEM_READ( "sctp_generic_recvmsg(iov)", ARG2
, ARG3
* sizeof(struct vki_iovec
) );
4820 if (ML_(safe_to_deref
)((const void*)ARG2
, ARG3
* sizeof(struct vki_iovec
))) {
4821 struct vki_iovec
* iovec
= (struct vki_iovec
*)ARG2
;
4822 PRE_MEM_WRITE("sctp_generic_recvmsg(iov.iov_base)", (Addr
)iovec
->iov_base
, iovec
->iov_len
);
4825 if (ARG4
!= (Addr
)NULL
)
4826 ML_(buf_and_len_pre_check
) (tid
, ARG4
, ARG5
,
4827 "sctp_generic_recvmsg(from)",
4828 "sctp_generic_recvmsg(fromlen_in)");
4830 if (ARG6
!= (Addr
)NULL
)
4831 PRE_MEM_WRITE("sctp_generic_recvmsg(sinfo)", ARG6
, sizeof(struct vki_sctp_sndrcvinfo
));
4833 if (ARG7
!= (Addr
)NULL
)
4834 PRE_MEM_WRITE("sctp_generic_recvmsg(msgflags)", ARG7
, sizeof(int));
4837 POST(sys_sctp_generic_recvmsg
)
4840 struct vki_iovec
* iovec
= (struct vki_iovec
*)ARG2
;
4841 POST_MEM_WRITE((Addr
)iovec
->iov_base
, iovec
->iov_len
);
4843 POST_MEM_WRITE( ARG2
, ARG3
*sizeof(struct vki_iovec
) );
4845 if (ARG4
!= (Addr
)NULL
)
4846 ML_(buf_and_len_post_check
) (tid
, VG_(mk_SysRes_Success
)(RES
), ARG4
, ARG5
,
4847 "sctp_generic_recvmsg(fromlen_out)");
4849 if (ARG6
!= (Addr
)NULL
)
4850 POST_MEM_WRITE(ARG6
, sizeof(struct vki_sctp_sndrcvinfo
));
4852 if (ARG7
!= (Addr
)NULL
)
4853 POST_MEM_WRITE(ARG7
, sizeof(int));
4871 // SYS_ftruncate 480
4874 // SYS_thr_kill2 481
4875 // int thr_kill2(pid_t pid, long id, int sig);
4878 PRINT("sys_thr_kill2 ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )", ARG1
,ARG2
,ARG3
);
4879 PRE_REG_READ3(int, "thr_kill2", pid_t
, pid
, long, tid
, int, sig
);
4880 if (!ML_(client_signal_OK
)(ARG3
)) {
4881 SET_STATUS_Failure( VKI_EINVAL
);
4885 /* Check to see if this kill gave us a pending signal */
4886 *flags
|= SfPollAfter
;
4888 if (VG_(clo_trace_signals
))
4889 VG_(message
)(Vg_DebugMsg
, "thr_kill2: sending signal %lu to pid %lu/%lu\n",
4892 /* If we're sending SIGKILL, check to see if the target is one of
4893 our threads and handle it specially. */
4894 if (ARG3
== VKI_SIGKILL
&& ML_(do_sigkill
)(ARG2
, ARG1
)) {
4895 SET_STATUS_Success(0);
4899 /* Ask to handle this syscall via the slow route, since that's the
4900 only one that sets tst->status to VgTs_WaitSys. If the result
4901 of doing the syscall is an immediate run of
4902 async_signalhandler() in m_signals, then we need the thread to
4903 be properly tidied away. I have the impression the previous
4904 version of this wrapper worked on x86/amd64 only because the
4905 kernel did not immediately deliver the async signal to this
4906 thread (on ppc it did, which broke the assertion re tst->status
4907 at the top of async_signalhandler()). */
4908 *flags
|= SfMayBlock
;
4913 if (VG_(clo_trace_signals
))
4914 VG_(message
)(Vg_DebugMsg
, "thr_kill2: sent signal %lu to pid %lu/%lu\n",
4919 // int shm_open(const char *path, int flags, mode_t mode);
4922 PRE_REG_READ3(int, "shm_open",
4923 const char *, path
, int, flags
, vki_mode_t
, mode
);
4924 if (ARG1
== VKI_SHM_ANON
) {
4925 PRINT("sys_shm_open(%#" FMT_REGWORD
"x(SHM_ANON), %" FMT_REGWORD
"u, %hu)", ARG1
, ARG2
, (vki_mode_t
)ARG3
);
4927 PRINT("sys_shm_open(%#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %hu)", ARG1
, (HChar
*)ARG1
, ARG2
, (vki_mode_t
)ARG3
);
4928 PRE_MEM_RASCIIZ( "shm_open(path)", ARG1
);
4930 *flags
|= SfMayBlock
;
4936 if (!ML_(fd_allowed
)(RES
, "shm_open", tid
, True
)) {
4938 SET_STATUS_Failure( VKI_EMFILE
);
4940 if (VG_(clo_track_fds
))
4941 ML_(record_fd_open_with_given_name
)(tid
, RES
, (HChar
*)ARG1
);
4945 // SYS_shm_unlink 483
4946 // int shm_unlink(const char *path);
4949 PRINT("sys_shm_unlink(%#" FMT_REGWORD
"x(%s))", ARG1
, (char *)ARG1
);
4950 PRE_REG_READ1(int, "shm_unlink",
4951 const char *, path
);
4953 PRE_MEM_RASCIIZ( "shm_unlink(path)", ARG1
);
4955 *flags
|= SfMayBlock
;
4959 // int cpuset(cpusetid_t *setid);
4962 PRINT("sys_cpuset ( %#" FMT_REGWORD
"x )", ARG1
);
4963 PRE_REG_READ1(int, "cpuset", vki_cpusetid_t
*, setid
);
4964 PRE_MEM_WRITE("cpuset(setid)", ARG1
, sizeof(vki_cpusetid_t
));
4969 POST_MEM_WRITE(ARG1
, sizeof(vki_cpusetid_t
));
4972 // SYS_cpuset_setid 485
4975 // SYS_cpuset_getid 486
4978 // SYS_cpuset_getaffinity 487
4981 // SYS_cpuset_setaffinity 488
4984 // SYS_faccessat 489
4985 // int faccessat(int fd, const char *path, int mode, int flag);
4988 PRINT("sys_faccessat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u )", ARG1
,ARG2
,(char*)ARG2
,ARG3
);
4989 PRE_REG_READ3(int, "faccessat",
4990 int, fd
, const char *, path
, int, flag
);
4991 PRE_MEM_RASCIIZ( "faccessat(path)", ARG2
);
4995 // int fchmodat(int fd, const char *path, mode_t mode, int flag);
4998 PRINT("sys_fchmodat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u )", ARG1
,ARG2
,(char*)ARG2
,ARG3
);
4999 PRE_REG_READ4(int, "fchmodat",
5000 int, fd
, const char *, path
, vki_mode_t
, mode
, int, flag
);
5001 PRE_MEM_RASCIIZ( "fchmodat(path)", ARG2
);
5005 // int fchownat(int fd, const char *path, uid_t owner, gid_t group, int flag);
5008 PRINT("sys_fchownat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), 0x%" FMT_REGWORD
"x, 0x%" FMT_REGWORD
"x, %" FMT_REGWORD
"d )",
5009 ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
, SARG5
);
5010 PRE_REG_READ5(int, "fchownat",
5011 int, fd
, const char *, path
,
5012 vki_uid_t
, owner
, vki_gid_t
, group
, int, flag
);
5013 PRE_MEM_RASCIIZ( "fchownat(path)", ARG2
);
5017 // int fexecve(int fd, char *const argv[], char *const envp[]);
5020 PRINT("sys_fexecve ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",
5022 PRE_REG_READ3(int, "fexecve",
5023 int, fd
, char * const *, argv
,
5024 char * const *, envp
);
5026 if (!ML_(fd_allowed
)(ARG1
, "fexecve", tid
, False
)) {
5027 SET_STATUS_Failure(VKI_EBADF
);
5033 if (VG_(resolve_filename
)(ARG1
, &fname
) == False
) {
5034 SET_STATUS_Failure(VKI_ENOENT
);
5038 struct vg_stat stats
;
5039 if (VG_(fstat
)(ARG1
, &stats
) != 0) {
5040 SET_STATUS_Failure(VKI_EACCES
);
5046 if (VG_(resolve_filemode
)(ARG1
, &openFlags
) == False
) {
5047 SET_STATUS_Failure(VKI_ENOENT
);
5052 * openFlags is in kernel FFLAGS format
5053 * (see /usr/include/sys/fcntl.h)
5054 * which alllows us to tell if RDONLY is set
5058 Bool isScript
= False
;
5061 res
= VG_(open
)(fname
, VKI_O_RDONLY
,
5062 VKI_S_IRUSR
|VKI_S_IRGRP
|VKI_S_IROTH
);
5063 if (sr_isError(res
)) {
5064 SET_STATUS_Failure(VKI_ENOENT
);
5068 VG_(read
)((Int
)sr_Res(res
), buf
, 2);
5069 VG_(close
)((Int
)sr_Res(res
));
5070 if (buf
[0] == '#' && buf
[1] == '!')
5077 if (!(openFlags
& VKI_FREAD
)) {
5078 SET_STATUS_Failure(VKI_EACCES
);
5082 if (!((openFlags
& VKI_O_EXEC
) ||
5083 (stats
.mode
& (VKI_S_IXUSR
|VKI_S_IXGRP
|VKI_S_IXOTH
)))) {
5084 SET_STATUS_Failure(VKI_EACCES
);
5089 Addr arg_2
= (Addr
)ARG2
;
5090 Addr arg_3
= (Addr
)ARG3
;
5092 handle_pre_sys_execve(tid
, status
, (Addr
)fname
, arg_2
, arg_3
, FEXECVE
, False
);
5095 // SYS_freebsd11_fstatat 493
5096 // int fstatat(int fd, const char *path, struct stat *sb, int flag);
5097 #if (FREEBSD_VERS >= FREEBSD_12)
5098 PRE(sys_freebsd11_fstatat
)
5100 PRINT("sys_freebsd11_fstatat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x )", ARG1
,ARG2
,(char*)ARG2
,ARG3
);
5101 PRE_REG_READ4(int, "fstatat",
5102 int, fd
, const char *, path
, struct freebsd11_stat
*, buf
, int, flag
);
5103 PRE_MEM_RASCIIZ( "fstatat(path)", ARG2
);
5104 PRE_MEM_WRITE( "fstatat(sb)", ARG3
, sizeof(struct vki_freebsd11_stat
) );
5107 POST(sys_freebsd11_fstatat
)
5109 POST_MEM_WRITE( ARG3
, sizeof(struct vki_freebsd11_stat
) );
5114 PRINT("sys_fstatat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x )", ARG1
,ARG2
,(char*)ARG2
,ARG3
);
5115 PRE_REG_READ4(int, "fstatat",
5116 int, fd
, const char *, path
, struct stat
*, buf
, int, flag
);
5117 PRE_MEM_RASCIIZ( "fstatat(path)", ARG2
);
5118 PRE_MEM_WRITE( "fstatat(sb)", ARG3
, sizeof(struct vki_freebsd11_stat
) );
5123 POST_MEM_WRITE( ARG3
, sizeof(struct vki_freebsd11_stat
) );
5127 // SYS_futimesat 494
5128 // int futimesat(int fd, const char *path, const struct timeval times[2]);
5131 PRINT("sys_futimesat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x )", ARG1
,ARG2
,(char*)ARG2
,ARG3
);
5132 PRE_REG_READ3(int, "futimesat",
5133 int, fd
, const char *, path
, struct timeval
*, times
);
5135 PRE_MEM_RASCIIZ( "futimesat(path)", ARG2
);
5137 PRE_MEM_READ( "futimesat(times)", ARG3
, 2 * sizeof(struct vki_timeval
) );
5141 // int linkat(int fd1, const char *name1, int fd2, const char *name2, int flag);
5144 *flags
|= SfMayBlock
;
5145 PRINT("sys_linkat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u )",ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
,(char*)ARG4
,ARG5
);
5146 PRE_REG_READ5(int, "linkat",
5147 int, fd1
, const char *, name1
,
5148 int, fd2
, const char *, name2
,
5150 PRE_MEM_RASCIIZ( "linkat(name1)", ARG2
);
5151 PRE_MEM_RASCIIZ( "linkat(name2)", ARG4
);
5155 // int mkdirat(int fd, const char *path, mode_t mode);
5158 *flags
|= SfMayBlock
;
5159 PRINT("sys_mkdirat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u )", ARG1
,ARG2
,(char*)ARG2
,ARG3
);
5160 PRE_REG_READ3(int, "mkdirat",
5161 int, fd
, const char *, path
, int, mode
);
5162 PRE_MEM_RASCIIZ( "mkdirat(path)", ARG2
);
5166 // int mkfifoat(int fd, const char *path, mode_t mode);
5169 PRINT("sys_mkfifoat ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x(%s), 0x%" FMT_REGWORD
"x )",
5170 SARG1
,ARG2
,(HChar
*)ARG2
,ARG3
);
5171 PRE_REG_READ3(int, "mkfifoat",
5172 int, fd
, const char *, path
, vki_mode_t
, mode
);
5173 PRE_MEM_RASCIIZ( "mkfifoat(path)", ARG2
);
5176 // SYS_freebsd11_mknodat 498
5177 // int mknodat(int fd, const char *path, mode_t mode, dev_t dev);
5178 #if (FREEBSD_VERS >= FREEBSD_12)
5179 PRE(sys_freebsd11_mknodat
)
5181 PRINT("sys_freebsd11_mknodat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), 0x%" FMT_REGWORD
"x, 0x%" FMT_REGWORD
"x )", ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
);
5182 PRE_REG_READ4(long, "mknodat",
5183 int, dfd
, const char *, pathname
, int, mode
, unsigned, dev
);
5184 PRE_MEM_RASCIIZ( "mknodat(pathname)", ARG2
);
5189 PRINT("sys_mknodat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), 0x%" FMT_REGWORD
"x, 0x%" FMT_REGWORD
"x )", ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
);
5190 PRE_REG_READ4(long, "mknodat",
5191 int, dfd
, const char *, pathname
, int, mode
, unsigned, dev
);
5192 PRE_MEM_RASCIIZ( "mknodat(pathname)", ARG2
);
5197 // int openat(int fd, const char *path, int flags, ...);
5201 if (ARG3
& VKI_O_CREAT
) {
5203 PRINT("sys_openat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )",ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
);
5204 PRE_REG_READ4(int, "openat",
5205 int, fd
, const char *, path
, int, flags
, vki_mode_t
, mode
);
5208 PRINT("sys_openat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u )",ARG1
,ARG2
,(char*)ARG2
,ARG3
);
5209 PRE_REG_READ3(int, "openat",
5210 int, fd
, const char *, path
, int, flags
);
5213 if (ARG1
!= (unsigned)VKI_AT_FDCWD
&& !ML_(fd_allowed
)(ARG1
, "openat", tid
, False
))
5214 SET_STATUS_Failure( VKI_EBADF
);
5216 PRE_MEM_RASCIIZ( "openat(path)", ARG2
);
5218 /* Otherwise handle normally */
5219 *flags
|= SfMayBlock
;
5225 if (!ML_(fd_allowed
)(RES
, "openat", tid
, True
)) {
5227 SET_STATUS_Failure( VKI_EMFILE
);
5229 if (VG_(clo_track_fds
))
5230 ML_(record_fd_open_with_given_name
)(tid
, RES
, (HChar
*)ARG2
);
5234 // SYS_readlinkat 500
5235 // ssize_t readlinkat(int fd, const char *restrict path, char *restrict buf,
5242 PRINT("sys_readlinkat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x, %llu )", ARG1
,ARG2
,(char*)ARG2
,ARG3
,(ULong
)ARG4
);
5243 PRE_REG_READ4(ssize_t
, "readlinkat",
5244 int, fd
, const char *, path
, char *, buf
, int, bufsize
);
5245 PRE_MEM_RASCIIZ( "readlinkat(path)", ARG2
);
5246 PRE_MEM_WRITE( "readlinkat(buf)", ARG3
,ARG4
);
5249 * Handle the case where readlinkat is looking at /proc/curproc/file or
5252 VG_(sprintf
)(name
, "/proc/%d/file", VG_(getpid
)());
5253 if (ML_(safe_to_deref
)((void*)ARG2
, 1)
5254 && (VG_(strcmp
)((HChar
*)ARG2
, name
) == 0
5255 || VG_(strcmp
)((HChar
*)ARG2
, "/proc/curproc/file") == 0)) {
5256 VG_(sprintf
)(name
, "/proc/self/fd/%d", VG_(cl_exec_fd
));
5257 SET_STATUS_from_SysRes( VG_(do_syscall4
)(saved
, ARG1
, (UWord
)name
,
5261 SET_STATUS_from_SysRes( VG_(do_syscall4
)(saved
, ARG1
, ARG2
, ARG3
, ARG4
));
5265 POST(sys_readlinkat
)
5267 POST_MEM_WRITE( ARG3
, RES
);
5271 // int renameat(int fromfd, const char *from, int tofd, const char *to);
5274 PRINT("sys_renameat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s) )", ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
,(char*)ARG4
);
5275 PRE_REG_READ4(int, "renameat",
5276 int, fromfd
, const char *, from
,
5277 int, tofd
, const char *, to
);
5278 PRE_MEM_RASCIIZ( "renameat(oldpath)", ARG2
);
5279 PRE_MEM_RASCIIZ( "renameat(newpath)", ARG4
);
5282 // SYS_symlinkat 502
5283 // int symlinkat(const char *name1, int fd, const char *name2);
5286 *flags
|= SfMayBlock
;
5287 PRINT("sys_symlinkat ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s) )",ARG1
,(char*)ARG1
,ARG2
,ARG3
,(char*)ARG3
);
5288 PRE_REG_READ3(int, "symlinkat",
5289 const char *, name1
, int, fd
, const char *, name2
);
5290 PRE_MEM_RASCIIZ( "symlinkat(name1)", ARG1
);
5291 PRE_MEM_RASCIIZ( "symlinkat(name2)", ARG3
);
5295 // int unlinkat(int fd, const char *path, int flag);
5298 *flags
|= SfMayBlock
;
5299 PRINT("sys_unlinkat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u ",
5300 ARG1
, ARG2
, (char*)ARG2
, ARG3
);
5301 PRE_REG_READ3(int, "unlinkat", int, fd
, const char *, path
, int, flag
);
5302 PRE_MEM_RASCIIZ( "unlinkat(path)", ARG2
);
5305 // SYS_posix_openpt 504
5306 // int posix_openpt(int oflag);
5307 PRE(sys_posix_openpt
)
5309 PRINT("sys_posix_openpt ( %" FMT_REGWORD
"d )", SARG1
);
5310 PRE_REG_READ1(int, "posix_openpt", int, oflag
);
5313 // SYS_gssd_syscall 505
5315 // see https://www.freebsd.org/cgi/man.cgi?format=html&query=gssapi(3)
5316 // syscalls.master says ; 505 is initialised by the kgssapi code, if present.
5319 // int jail_get(struct iovec *iov, u_int niov, int flags);
5322 PRINT("sys_jail_get ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )", ARG1
, ARG2
, ARG3
);
5323 PRE_REG_READ3(int, "jail_get", struct vki_iovec
*, iov
, unsigned int,
5325 PRE_MEM_READ("jail_get(iov)", ARG1
, ARG2
* sizeof(struct vki_iovec
));
5329 // int jail_set(struct iovec *iov, u_int niov, int flags);
5332 PRINT("sys_jail_set ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )", ARG1
, ARG2
, ARG3
);
5333 PRE_REG_READ3(int, "jail_set", struct vki_iovec
*, iov
, unsigned int,
5335 PRE_MEM_READ("jail_set(iovs)", ARG1
, ARG2
* sizeof(struct vki_iovec
));
5338 // SYS_jail_remove 508
5339 // int jail_remove(int jid);
5340 PRE(sys_jail_remove
)
5342 PRINT("sys_jail_remove ( %" FMT_REGWORD
"d )", SARG1
);
5343 PRE_REG_READ1(int, "jail_remove", int, jid
);
5346 // SYS_closefrom 509
5347 // void closefrom(int lowfd);
5350 PRINT("sys_closefrom ( %" FMT_REGWORD
"dx )", SARG1
);
5351 PRE_REG_READ1(int, "closefrom", int, lowfd
);
5354 * Can't pass this on to the kernel otherwise it will close
5355 * all of the host files like the log
5358 for (int i
= ARG1
; i
< VG_(fd_soft_limit
); ++i
) {
5362 SET_STATUS_Success(0);
5366 // int semctl(int semid, int semnum, int cmd, ...);
5367 // int __semctl(int semid, int semnum, int cmd, _Inout_ union semun *arg);
5373 PRINT("sys_semctl ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )",ARG1
,ARG2
,ARG3
,ARG4
);
5374 PRE_REG_READ4(int, "semctl",
5375 int, semid
, int, semnum
, int, cmd
, struct seminfo
*, arg
);
5380 PRINT("sys_semctl ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )",ARG1
,ARG2
,ARG3
,ARG4
);
5381 PRE_REG_READ4(long, "semctl",
5382 int, semid
, int, semnum
, int, cmd
, struct semid_ds
*, arg
);
5386 PRINT("sys_semctl ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )",ARG1
,ARG2
,ARG3
,ARG4
);
5387 PRE_REG_READ4(long, "semctl",
5388 int, semid
, int, semnum
, int, cmd
, unsigned short *, arg
);
5391 PRINT("sys_semctl ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
5392 PRE_REG_READ3(long, "semctl",
5393 int, semid
, int, semnum
, int, cmd
);
5396 ML_(generic_PRE_sys_semctl
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
5401 ML_(generic_POST_sys_semctl
)(tid
, RES
,ARG1
,ARG2
,ARG3
,ARG4
);
5405 // int msgctl(int msqid, int cmd, struct msqid_ds *buf);
5408 PRINT("sys_msgctl ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
,SARG2
,ARG3
);
5410 PRE_REG_READ3(int, "msgctl", int, msqid
, int, cmd
, struct msqid_ds
*, buf
);
5412 switch (ARG2
/* cmd */) {
5414 PRE_MEM_WRITE( "msgctl(IPC_STAT, buf)",
5415 ARG3
, sizeof(struct vki_msqid_ds
) );
5418 PRE_MEM_READ( "msgctl(IPC_SET, buf)",
5419 ARG3
, sizeof(struct vki_msqid_ds
) );
5426 switch (ARG2
/* cmd */) {
5428 POST_MEM_WRITE( ARG3
, sizeof(struct vki_msqid_ds
) );
5435 // int shmctl(int shmid, int cmd, struct shmid_ds *buf);
5438 PRINT("sys_shmctl ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )",SARG1
,SARG2
,ARG3
);
5439 PRE_REG_READ3(int, "shmctl",
5440 int, shmid
, int, cmd
, struct vki_shmid_ds
*, buf
);
5441 switch (ARG2
/* cmd */) {
5443 PRE_MEM_WRITE( "shmctl(IPC_STAT, buf)",
5444 ARG3
, sizeof(struct vki_shmid_ds
) );
5447 PRE_MEM_READ( "shmctl(IPC_SET, buf)",
5448 ARG3
, sizeof(struct vki_shmid_ds
) );
5455 if (ARG2
== VKI_IPC_STAT
) {
5456 POST_MEM_WRITE( ARG3
, sizeof(struct vki_shmid_ds
) );
5460 // SYS_lpathconf 513
5461 // long lpathconf(const char *path, int name);
5464 PRINT("sys_lpathconf ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d)", ARG1
, SARG2
);
5465 PRE_REG_READ2(long, "lpathconf", const char *, path
, int, name
);
5466 PRE_MEM_RASCIIZ("lpathconf(path)", ARG1
);
5469 // SYS___cap_rights_get 515
5470 // note extra 1st argument for the internal function which is not present
5471 // in the public interface
5472 // int __cap_rights_get(int version, int fd, cap_rights_t *rights);
5473 PRE(sys_cap_rights_get
)
5475 PRINT("sys_cap_rights_get ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
, SARG2
, ARG3
);
5476 PRE_REG_READ3(long, "cap_rights_get", int, version
, int, fd
, vki_cap_rights_t
*, rights
);
5477 PRE_MEM_WRITE("cap_rights_get(rights)", ARG3
, sizeof(vki_cap_rights_t
));
5480 POST(sys_cap_rights_get
)
5482 POST_MEM_WRITE(ARG2
, sizeof(vki_cap_rights_t
));
5485 // SYS_cap_enter 516
5486 // int cap_enter(void);
5489 PRINT("%s", "sys_cap_enter ( )");
5490 PRE_REG_READ0(int, "cap_enter");
5491 static Bool warning_given
= False
;
5492 if (!warning_given
) {
5493 warning_given
= True
;
5494 capabiltyMode
= True
;
5496 "WARNING: Valgrind may not operate correctly in capability mode.\n"
5497 " Please consider disabling capability by using the RUNNING_ON_VALGRIND mechanism.\n"
5498 " See http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq\n");
5502 // SYS_cap_getmode 517
5503 // int cap_getmode(u_int *modep);
5504 PRE(sys_cap_getmode
)
5506 PRINT("sys_cap_getmode ( %#" FMT_REGWORD
"x )", ARG1
);
5507 PRE_REG_READ1(int, "cap_getmode", u_int
*, modep
);
5508 PRE_MEM_WRITE("cap_getmode(modep)", ARG1
, sizeof(u_int
));
5511 POST(sys_cap_getmode
)
5513 POST_MEM_WRITE(ARG1
, sizeof(u_int
));
5516 static vki_sigset_t pdfork_saved_mask
;
5519 // pid_t pdfork(int *fdp, int flags);
5526 PRINT("sys_pdfork ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )", ARG1
, ARG2
);
5527 PRE_REG_READ2(pid_t
, "pdfork", int*, fdp
, int, flags
);
5529 /* Block all signals during fork, so that we can fix things up in
5530 the child without being interrupted. */
5531 VG_(sigfillset
)(&mask
);
5532 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &mask
, &pdfork_saved_mask
);
5534 VG_(do_atfork_pre
)(tid
);
5536 SET_STATUS_from_SysRes( VG_(do_syscall2
)(__NR_pdfork
, ARG1
, ARG2
) );
5538 if (!SUCCESS
) return;
5540 // RES is 0 for child, non-0 (the child's PID) for parent.
5541 is_child
= ( RES
== 0 ? True
: False
);
5542 child_pid
= ( is_child
? -1 : RES
);
5545 VG_(do_atfork_child
)(tid
);
5547 /* restore signal mask */
5548 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &pdfork_saved_mask
, NULL
);
5550 VG_(do_atfork_parent
)(tid
);
5552 PRINT(" fork: process %d created child %d\n", VG_(getpid
)(), child_pid
);
5554 /* restore signal mask */
5555 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &pdfork_saved_mask
, NULL
);
5559 PRE_MEM_WRITE( "pdfork(fdp)", ARG1
, sizeof(int) );
5566 POST_MEM_WRITE( ARG1
, sizeof(int) );
5571 //int pdkill(int fd, int signum)
5574 PRINT("sys_pdkill ( %" FMT_REGWORD
"u, %" FMT_REGWORD
"d )", ARG1
, SARG2
);
5575 PRE_REG_READ2(int, "pdkill", int, fd
, int, signum
);
5577 if (!ML_(client_signal_OK
)(ARG2
)) {
5578 SET_STATUS_Failure( VKI_EINVAL
);
5582 /* Ther was some code here to check if the kill is to this process
5584 * But it was totally wrong
5586 * It was calling ML_(do_sigkill)(Int pid, Int tgid)
5588 * With a file descriptor
5590 * Fortunately this will never match a real process otherwise
5591 * it might have accidentally killed us.
5593 * For a start we need the pid, obtained with pdgetpid
5594 * Next ML_(do_sigkill) doesn't map to FreeBSD. It takes a
5595 * pid (lwpid) and a tgid (threadgroup)
5597 * On FreeBSD lwpid is the tid and threadgroup is the pid
5598 * The kill functions operate on pids, not tids.
5600 * One last thing, I don't see how pdkill could do a self
5601 * kill 9. It neads an fd which implied pdfork whichimplies
5602 * that the fd/pid are for a child process
5605 SET_STATUS_from_SysRes(VG_(do_syscall2
)(SYSNO
, ARG1
, ARG2
));
5607 if (VG_(clo_trace_signals
))
5608 VG_(message
)(Vg_DebugMsg
, "pdkill: sent signal %ld to fd %ld\n",
5611 /* This kill might have given us a pending signal. Ask for a check once
5612 the syscall is done. */
5613 *flags
|= SfPollAfter
;
5618 // int pdgetpid(int fd, pid_t *pidp);
5621 PRINT("pdgetpid ( %" FMT_REGWORD
"d, %#lx )", SARG1
, ARG2
);
5622 PRE_REG_READ2(int, "pdgetpid",
5623 int, fd
, pid_t
*, pidp
);
5624 PRE_MEM_WRITE( "pdgetpid(pidp))", ARG2
, sizeof(vki_pid_t
) );
5629 POST_MEM_WRITE( ARG2
, sizeof(vki_pid_t
) );
5634 // int pselect(int nfds, fd_set * restrict readfds, fd_set * restrict writefds,
5635 // fd_set * restrict exceptfds,
5636 // const struct timespec * restrict timeout,
5637 // const sigset_t * restrict newsigmask);
5640 *flags
|= SfMayBlock
| SfPostOnFail
;
5641 PRINT("sys_pselect ( %ld, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %#"
5642 FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",
5643 SARG1
, ARG2
, ARG3
, ARG4
, ARG5
, ARG6
);
5644 PRE_REG_READ6(int, "pselect",
5645 int, nfds
, vki_fd_set
*, readfds
, vki_fd_set
*, writefds
,
5646 vki_fd_set
*, exceptfds
, struct vki_timespec
*, timeout
,
5647 const sigset_t
*, newsigmask
);
5648 // XXX: this possibly understates how much memory is read.
5650 PRE_MEM_READ( "pselect(readfds)",
5651 ARG2
, ARG1
/8 /* __FD_SETSIZE/8 */ );
5653 PRE_MEM_READ( "pselect(writefds)",
5654 ARG3
, ARG1
/8 /* __FD_SETSIZE/8 */ );
5656 PRE_MEM_READ( "pselect(exceptfds)",
5657 ARG4
, ARG1
/8 /* __FD_SETSIZE/8 */ );
5659 PRE_MEM_READ( "pselect(timeout)", ARG5
, sizeof(struct vki_timeval
) );
5662 PRE_MEM_READ( "pselect(sig)", ARG6
, sizeof(vki_sigset_t
) );
5663 ARG6
= ML_(make_safe_mask
)("syswrap.pselect.1", (Addr
)ARG6
);
5669 ML_(free_safe_mask
) ( (Addr
)ARG6
);
5672 // SYS_getloginclass 523
5673 // int getloginclass(char *name, size_t len);
5674 PRE(sys_getloginclass
)
5676 PRINT("sys_getloginclass ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
, ARG2
);
5677 PRE_REG_READ2(int, "getloginclass", char *, name
, size_t, len
);
5678 // The buffer should be at least MAXLOGNAME bytes in length.
5679 PRE_MEM_WRITE("getloginclass(name)", ARG1
, ARG2
);
5682 POST(sys_getloginclass
)
5684 POST_MEM_WRITE(ARG1
, ARG2
);
5687 // SYS_setloginclass 524
5688 // int setloginclass(const char *name);
5689 PRE(sys_setloginclass
)
5691 PRINT("sys_setloginclass ( %#" FMT_REGWORD
"x(%s) )", ARG1
, (HChar
*)ARG1
);
5692 PRE_REG_READ1(int, "setloginclass", const char *, name
);
5693 PRE_MEM_RASCIIZ("rctl_setloginclass(name)", ARG1
);
5696 // SYS_rctl_get_racct 525
5697 // int rctl_get_racct(const char *inbufp, size_t inbuflen, char *outbufp,
5698 // size_t outbuflen);
5699 PRE(sys_rctl_get_racct
)
5701 PRINT("sys_rctl_get_racct ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"xd, %" FMT_REGWORD
"u )", ARG1
, ARG2
, ARG3
, ARG4
);
5702 PRE_REG_READ4(int, "rctl_get_racct", const char *, inbufp
, size_t, inbuflen
, char *, outbufp
,
5704 PRE_MEM_READ("rctl_get_racct(inbufp)", ARG1
, ARG2
);
5705 PRE_MEM_WRITE("rctl_get_racct(outbufp)", ARG3
, ARG4
);
5708 POST(sys_rctl_get_racct
)
5710 POST_MEM_WRITE(ARG3
, ARG4
);
5713 // SYS_rctl_get_rules 526
5714 // int rctl_get_rules(const char *inbufp, size_t inbuflen, char *outbufp,
5715 // size_t outbuflen);
5716 PRE(sys_rctl_get_rules
)
5718 PRINT("sys_rctl_get_rules ( %#" FMT_REGWORD
"xd, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"xd, %" FMT_REGWORD
"u )", ARG1
, ARG2
, ARG3
, ARG4
);
5719 PRE_REG_READ4(int, "rctl_get_rules", const char *, inbufp
, size_t, inbuflen
, char *, outbufp
,
5721 PRE_MEM_READ("rctl_get_rules(inbufp)", ARG1
, ARG2
);
5722 PRE_MEM_WRITE("rctl_get_rules(outbufp)", ARG3
, ARG4
);
5725 POST(sys_rctl_get_rules
)
5727 POST_MEM_WRITE(ARG3
, ARG4
);
5730 // SYS_rctl_get_limits 527
5731 // int rctl_get_limits(const char *inbufp, size_t inbuflen, char *outbufp,
5732 // size_t outbuflen);
5733 PRE(sys_rctl_get_limits
)
5735 PRINT("sys_rctl_get_limits ( %#" FMT_REGWORD
"xd, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"xd, %" FMT_REGWORD
"u )", ARG1
, ARG2
, ARG3
, ARG4
);
5736 PRE_REG_READ4(int, "rctl_get_limits", const char *, inbufp
, size_t, inbuflen
, char *, outbufp
,
5738 PRE_MEM_READ("rctl_get_limits(inbufp)", ARG1
, ARG2
);
5739 PRE_MEM_WRITE("rctl_get_limits(outbufp)", ARG3
, ARG4
);
5742 POST(sys_rctl_get_limits
)
5744 POST_MEM_WRITE(ARG3
, ARG4
);
5747 // SYS_rctl_add_rule 528
5748 // int rctl_add_rule(const char *inbufp, size_t inbuflen, char *outbufp,
5749 // size_t outbuflen);
5750 PRE(sys_rctl_add_rule
)
5752 PRINT("sys_rctl_add_rule ( %#" FMT_REGWORD
"xd, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"xd, %" FMT_REGWORD
"u )", ARG1
, ARG2
, ARG3
, ARG4
);
5753 PRE_REG_READ2(int, "rctl_add_rule", const char *, inbufp
, size_t, inbuflen
);
5754 PRE_MEM_READ("rctl_add_rule(inbufp)", ARG1
, ARG2
);
5756 // The outbufp and outbuflen arguments are unused
5757 //PRE_MEM_WRITE("rctl_add_rule(outbufp)", ARG3, ARG4);
5760 POST(sys_rctl_add_rule
)
5762 //POST_MEM_WRITE(ARG3, ARG4);
5765 // SYS_rctl_remove_rule 529
5766 // int rctl_remove_rule(const char *inbufp, size_t inbuflen, char *outbufp,
5767 // size_t outbuflen);
5768 PRE(sys_rctl_remove_rule
)
5770 PRINT("sys_rctl_remove_rule ( %#" FMT_REGWORD
"xd, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"xd, %" FMT_REGWORD
"u )", ARG1
, ARG2
, ARG3
, ARG4
);
5771 PRE_REG_READ2(int, "rctl_remove_rule", const char *, inbufp
, size_t, inbuflen
);
5772 PRE_MEM_READ("rctl_remove_rule(inbufp)", ARG1
, ARG2
);
5774 // The outbufp and outbuflen arguments are unused
5775 //PRE_MEM_WRITE("rctl_remove_rule(outbufp)", ARG3, ARG4);
5778 POST(sys_rctl_remove_rule
)
5780 //POST_MEM_WRITE(ARG3, ARG4);
5783 // SYS_posix_fallocate 530
5786 // SYS_posix_fadvise 531
5792 // SYS_cap_rights_limit 533
5793 //int cap_rights_limit(int fd, const cap_rights_t *rights);
5794 PRE(sys_cap_rights_limit
)
5796 PRINT("sys_cap_rights_limit ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
, ARG2
);
5797 PRE_REG_READ2(int, "cap_rights_limit",
5798 int, fd
, const cap_rights_t
*, rights
);
5799 PRE_MEM_READ( "cap_rights_limit(rights)", ARG2
, sizeof(struct vki_cap_rights
) );
5802 // SYS_cap_ioctls_limit 534
5803 // int cap_ioctls_limit(int fd, const unsigned long *cmds, size_t ncmds);
5804 PRE(sys_cap_ioctls_limit
)
5806 PRINT("cap_ioctls_limit ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
, ARG2
, ARG3
);
5807 PRE_REG_READ3(int, "cap_ioctls_limit",
5808 int, fd
, unsigned long*, rights
, vki_size_t
, ncmds
);
5809 // "can be up to 256" taking that to not be inclusive
5811 PRE_MEM_READ( "cap_ioctls_limit(cmds))", ARG2
, ARG3
*sizeof(unsigned long) );
5816 // SYS_cap_ioctls_get 535
5817 // int cap_ioctls_get(int fd, unsigned long *cmds, size_t maxcmds);
5818 PRE(sys_cap_ioctls_get
)
5820 PRINT("sys_cap_ioctls_get ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", SARG1
, ARG2
, ARG3
);
5821 PRE_REG_READ3(int, "cap_ioctls_get", int, fd
, unsigned long *, cmds
, size_t, maxcmds
);
5823 PRE_MEM_WRITE("cap_ioctls_get(cmds)", ARG2
, ARG3
*sizeof(unsigned long));
5827 POST(sys_cap_ioctls_get
)
5830 POST_MEM_WRITE(ARG2
, ARG3
*sizeof(unsigned long));
5835 // SYS_cap_fcntls_limit 536
5836 //int cap_fcntls_limit(int fd, uint32_t fcntlrights);
5837 PRE(sys_cap_fcntls_limit
)
5839 PRINT("cap_fcntls_limit ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"u )", SARG1
, ARG2
);
5840 PRE_REG_READ2(long, "cap_fcntls_limit",
5841 int, fd
, vki_uint32_t
, fcntlrights
);
5844 // SYS_cap_fcntls_get 537
5845 // int cap_fcntls_get(int fd, uint32_t *fcntlrightsp);
5846 PRE(sys_cap_fcntls_get
)
5848 PRINT("sys_cap_fcntls_get ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
, ARG2
);
5849 PRE_REG_READ2(int, "cap_fcntls_get", int, fd
, uint32_t *, fcntlrightsp
);
5850 PRE_MEM_WRITE("cap_fcntls_get(fcntlrightsp)", ARG2
, sizeof(uint32_t));
5853 POST(sys_cap_fcntls_get
)
5855 POST_MEM_WRITE(ARG2
, sizeof(uint32_t));
5859 // int bindat(int fd, int s, const struct sockaddr *addr, socklen_t addrlen);
5862 PRINT("sys_bindat ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"dx, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",
5863 SARG1
, SARG2
, ARG3
, ARG4
);
5864 PRE_REG_READ4(int, "bindat", int, fd
, int, s
, const struct vki_sockaddr
*, name
, vki_socklen_t
, namelen
);
5865 PRE_MEM_READ("bindat(name)", ARG3
, ARG4
);
5868 // SYS_connectat 539
5869 // int connectat(int fd, int s, const struct sockaddr *name, socklen_t namelen);
5872 PRINT("sys_connectat ( %" FMT_REGWORD
"d, %" FMT_REGWORD
"dx, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )",
5873 SARG1
, SARG2
, ARG3
, ARG4
);
5874 PRE_REG_READ4(int, "connectat", int, fd
, int, s
, const struct vki_sockaddr
*, name
, vki_socklen_t
, namelen
);
5875 PRE_MEM_READ("connectat(name)", ARG3
, ARG4
);
5878 // SYS_chflagsat 540
5879 // int chflagsat(int fd, const char *path, unsigned long flags, int atflag);
5882 PRINT("sys_chglagsat ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"d )",
5883 SARG1
, ARG2
, ARG3
, SARG4
);
5884 PRE_REG_READ4(int, "chflagsat", int, fd
, const char *, path
, unsigned long, flags
, int, atflag
);
5885 PRE_MEM_RASCIIZ("chflagsat(path)", ARG2
);
5889 // int accept4(int s, struct sockaddr * restrict addr,
5890 // socklen_t * restrict addrlen, int flags);
5893 *flags
|= SfMayBlock
;
5894 PRINT("sys_accept4 ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u)",ARG1
,ARG2
,ARG3
,ARG4
);
5895 PRE_REG_READ4(int, "accept4",
5896 int, s
, struct sockaddr
*, addr
, int, *addrlen
, int, flags
);
5897 ML_(generic_PRE_sys_accept
)(tid
, ARG1
,ARG2
,ARG3
);
5904 r
= ML_(generic_POST_sys_accept
)(tid
, VG_(mk_SysRes_Success
)(RES
),
5906 SET_STATUS_from_SysRes(r
);
5910 // int pipe2(int fildes[2], int flags);
5913 PRINT("sys_pipe2 ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
, ARG2
);
5914 PRE_REG_READ2(int, "pipe2",
5915 int *, fildes
, int, flags
);
5916 PRE_MEM_WRITE("pipe2(fildes)", ARG1
, 2 * sizeof(int));
5927 POST_MEM_WRITE(ARG1
, 2 * sizeof(int));
5928 fildes
= (int *)ARG1
;
5930 if (!ML_(fd_allowed
)(fildes
[0], "pipe2", tid
, True
) ||
5931 !ML_(fd_allowed
)(fildes
[1], "pipe2", tid
, True
)) {
5932 VG_(close
)(fildes
[0]);
5933 VG_(close
)(fildes
[1]);
5934 SET_STATUS_Failure( VKI_EMFILE
);
5935 } else if (VG_(clo_track_fds
)) {
5936 ML_(record_fd_open_nameless
)(tid
, fildes
[0]);
5937 ML_(record_fd_open_nameless
)(tid
, fildes
[1]);
5941 // SYS_aio_mlock 543
5942 // int aio_mlock(struct aiocb *iocb);
5945 PRINT("sys_aio_mlock ( %#" FMT_REGWORD
"x )", ARG1
);
5946 PRE_REG_READ1(int, "aio_mlock", struct vki_aiocb
*, iocb
);
5947 PRE_MEM_READ("aio_mlock(iocb", ARG1
, sizeof(struct vki_aiocb
));
5948 // this locks memory into RAM, don't think that we need to do
5956 // int ppoll(struct pollfd fds[], nfds_t nfds,
5957 // const struct timespec * restrict timeout,
5958 // const sigset_t * restrict newsigmask);
5961 PRINT("sys_ppoll ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %#" FMT_REGWORD
5962 "x, %#" FMT_REGWORD
"x )",
5963 ARG1
, ARG2
, ARG3
, ARG4
);
5965 struct vki_pollfd
* fds
= (struct vki_pollfd
*)(Addr
)ARG1
;
5966 *flags
|= SfMayBlock
| SfPostOnFail
;
5967 PRE_REG_READ4(long, "ppoll",
5968 struct vki_pollfd
*, fds
, unsigned int, nfds
,
5969 struct vki_timespec
*, timeout
, vki_sigset_t
*, newsigmask
);
5971 if (ML_(safe_to_deref
)(fds
, ARG2
*sizeof(struct vki_pollfd
))) {
5972 for (i
= 0; i
< ARG2
; i
++) {
5973 PRE_MEM_READ( "ppoll(fds.fd)",
5974 (Addr
)(&fds
[i
].fd
), sizeof(fds
[i
].fd
) );
5975 PRE_MEM_READ( "ppoll(fds.events)",
5976 (Addr
)(&fds
[i
].events
), sizeof(fds
[i
].events
) );
5977 PRE_MEM_WRITE( "ppoll(fds.revents)",
5978 (Addr
)(&fds
[i
].revents
), sizeof(fds
[i
].revents
) );
5983 PRE_MEM_READ( "ppoll(timeout)", ARG3
,
5984 sizeof(struct vki_timespec
) );
5987 PRE_MEM_READ( "ppoll(newsigmask)", ARG4
, sizeof(vki_sigset_t
));
5988 ARG4
= ML_(make_safe_mask
)("syswrap.ppoll.1", (Addr
)ARG4
);
5994 if (SUCCESS
&& ((Word
)RES
!= -1)) {
5996 struct vki_pollfd
* ufds
= (struct vki_pollfd
*)(Addr
)ARG1
;
5997 for (i
= 0; i
< ARG2
; i
++)
5998 POST_MEM_WRITE( (Addr
)(&ufds
[i
].revents
), sizeof(ufds
[i
].revents
) );
6000 ML_(free_safe_mask
) ( (Addr
)ARG4
);
6004 // int futimens(int fd, const struct timespec times[2]);
6007 PRINT("sys_futimens ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
, ARG2
);
6008 PRE_REG_READ2(int, "futimens", int, fd
, const struct timespec
*, times
);
6009 PRE_MEM_READ("futimens(times)", ARG2
, 2*sizeof(struct vki_timespec
));
6012 // SYS_utimensat 547
6013 // int utimensat(int fd, const char *path, const struct timespec times[2],
6017 PRINT("sys_utimensat ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d )",
6018 SARG1
, ARG2
, ARG3
, SARG4
);
6019 PRE_REG_READ4(int, "utimensat", int, fd
, const char *,path
, const struct timespec
*, times
,
6021 PRE_MEM_RASCIIZ("utimensat(path)", ARG2
);
6022 PRE_MEM_READ("utimensat(times)", ARG3
, 2*sizeof(struct vki_timespec
));
6025 // SYS_fdatasync 550
6026 // int fdatasync(int fd);
6029 PRINT("sys_fdatasync ( %" FMT_REGWORD
"d )",SARG1
);
6030 PRE_REG_READ1(int, "fdatasync", int, fd
);
6033 #if (FREEBSD_VERS >= FREEBSD_12)
6035 // int fstat(int fd, struct stat *sb);
6038 PRINT("sys_fstat ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )",SARG1
,ARG2
);
6039 PRE_REG_READ2(int, "fstat", int, fd
, struct stat
*, sb
);
6040 PRE_MEM_WRITE( "fstat(sb)", ARG2
, sizeof(struct vki_stat
) );
6045 POST_MEM_WRITE( ARG2
, sizeof(struct vki_stat
) );
6049 // int fstatat(int fd, const char *path, struct stat *sb, int flag);
6052 PRINT("sys_fstatat ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d )", SARG1
,ARG2
,(char*)ARG2
,ARG3
,SARG4
);
6053 PRE_REG_READ4(int, "fstatat",
6054 int, fd
, const char *, path
, struct stat
*, sb
, int, flag
);
6055 PRE_MEM_RASCIIZ( "fstatat(path)", ARG2
);
6056 PRE_MEM_WRITE( "fstatat(sb)", ARG3
, sizeof(struct vki_stat
) );
6061 POST_MEM_WRITE( ARG3
, sizeof(struct vki_stat
) );
6064 // int fhstat(const fhandle_t *fhp, struct stat *sb);
6067 PRINT("sys_fhstat ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",ARG1
,ARG2
);
6068 PRE_REG_READ2(long, "fhstat", const vki_fhandle_t
*, fhp
, struct stat
*, sb
);
6069 PRE_MEM_READ( "fhstat(fhp)", ARG1
, sizeof(struct vki_fhandle
) );
6070 PRE_MEM_WRITE( "fhstat(sb)", ARG2
, sizeof(struct vki_stat
) );
6075 POST_MEM_WRITE( ARG2
, sizeof(struct vki_stat
) );
6078 // SYS_getdirentries 554
6079 // ssize_t getdirentries(int fd, char *buf, size_t nbytes, off_t *basep);
6080 PRE(sys_getdirentries
)
6082 *flags
|= SfMayBlock
;
6083 PRINT("sys_getdirentries ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )", SARG1
,ARG2
,ARG3
,ARG4
);
6084 PRE_REG_READ4(ssize_t
, "getdirentries",
6085 int, fd
, char *, buf
,
6088 PRE_MEM_WRITE( "getdirentries(buf)", ARG2
, ARG3
);
6090 PRE_MEM_WRITE("getdirentries(basep)", ARG4
, sizeof (vki_off_t
));
6093 POST(sys_getdirentries
)
6097 POST_MEM_WRITE( ARG2
, RES
);
6099 POST_MEM_WRITE( ARG4
, sizeof (vki_off_t
));
6104 // int statfs(const char *path, struct statfs *buf);
6107 PRINT("sys_statfs ( %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x )",ARG1
,(char *)ARG1
,ARG2
);
6108 PRE_REG_READ2(int, "statfs", const char *, path
, struct statfs
*, buf
);
6109 PRE_MEM_RASCIIZ( "statfs(path)", ARG1
);
6110 PRE_MEM_WRITE( "statfs(buf)", ARG2
, sizeof(struct vki_statfs
) );
6115 POST_MEM_WRITE( ARG2
, sizeof(struct vki_statfs
) );
6119 // int fstatfs(int fd, struct statfs *buf);
6122 PRINT("sys_fstatfs ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )",SARG1
,ARG2
);
6123 PRE_REG_READ2(int, "fstatfs",
6124 int, fd
, struct vki_statfs
*, buf
);
6125 PRE_MEM_WRITE( "fstatfs(buf)", ARG2
, sizeof(struct vki_statfs
) );
6130 POST_MEM_WRITE( ARG2
, sizeof(struct vki_statfs
) );
6133 // SYS_getfsstat 557
6134 // int getfsstat(struct statfs *buf, long bufsize, int mode);
6137 PRINT("sys_getfsstat ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )",ARG1
,ARG2
,ARG3
);
6138 PRE_REG_READ3(long, "getfsstat", struct vki_statfs
*, buf
, long, len
, int, flags
);
6139 PRE_MEM_WRITE( "getfsstat(buf)", ARG1
, ARG2
);
6145 if ((Word
)RES
!= -1) {
6146 POST_MEM_WRITE( ARG1
, RES
* sizeof(struct vki_statfs
) );
6151 // int fhstatfs(const fhandle_t *fhp, struct statfs *buf);
6154 PRINT("sys_fhstatfs ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )",ARG1
,ARG2
);
6155 PRE_REG_READ2(long, "fhstatfs",
6156 struct fhandle
*, fhp
, struct statfs
*, buf
);
6157 PRE_MEM_READ( "fhstatfs(fhp)", ARG1
, sizeof(struct vki_fhandle
) );
6158 PRE_MEM_WRITE( "fhstatfs(buf)", ARG2
, sizeof(struct vki_statfs
) );
6163 POST_MEM_WRITE( ARG2
, sizeof(struct vki_statfs
) );
6167 // int mknodat(int fd, const char *path, mode_t mode, dev_t dev);
6170 PRINT("sys_mknodat ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x(%s), 0x%" FMT_REGWORD
"x, 0x%" FMT_REGWORD
"x )", ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
);
6171 PRE_REG_READ4(long, "mknodat",
6172 int, fd
, const char *, path
, vki_mode_t
, mode
, vki_dev_t
, dev
);
6173 PRE_MEM_RASCIIZ( "mknodat(pathname)", ARG2
);
6177 // int kevent(int kq, const struct kevent *changelist, int nchanges,
6178 // struct kevent *eventlist, int nevents,
6179 // const struct timespec *timeout);
6182 PRINT("sys_kevent ( %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %#" FMT_REGWORD
"x )\n", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
6183 PRE_REG_READ6(int, "kevent",
6184 int, kq
, struct vki_kevent
*, changelist
, int, nchanges
,
6185 struct vki_kevent
*, eventlist
, int, nevents
,
6186 struct timespec
*, timeout
);
6187 if (ARG2
!= 0 && ARG3
!= 0)
6188 PRE_MEM_READ( "kevent(changelist)", ARG2
, sizeof(struct vki_kevent
)*ARG3
);
6189 if (ARG4
!= 0 && ARG5
!= 0)
6190 PRE_MEM_WRITE( "kevent(eventlist)", ARG4
, sizeof(struct vki_kevent
)*ARG5
);
6192 *flags
|= SfMayBlock
;
6194 PRE_MEM_READ( "kevent(timeout)",
6195 ARG6
, sizeof(struct vki_timespec
));
6201 if ((Word
)RES
!= -1) {
6203 POST_MEM_WRITE( ARG4
, sizeof(struct vki_kevent
)*RES
) ;
6207 // SYS_cpuset_getdomain 561
6210 // SYS_cpuset_setdomain 562
6213 // SYS_getrandom 563
6214 // ssize_t getrandom(void *buf, size_t buflen, unsigned int flags);
6217 PRINT("sys_getrandom ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )", ARG1
, ARG2
, ARG3
);
6218 PRE_REG_READ3(ssize_t
, "getrandom",
6219 void *, buf
, vki_size_t
, buflen
, unsigned int, flags
);
6220 PRE_MEM_WRITE( "getrandom(buf)", ARG1
, ARG2
);
6221 if ((ARG3
& VKI_GRND_NONBLOCK
) == 0) {
6222 *flags
|= SfMayBlock
;
6228 POST_MEM_WRITE( ARG1
, ARG2
);
6232 // int getfhat(int fd, const char *path, fhandle_t *fhp, int flag);
6235 PRINT("sys_getfhat ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"x, %" FMT_REGWORD
"d ", SARG1
, ARG2
, ARG3
, SARG4
);
6236 PRE_REG_READ4(int, "getfhat", int, fd
, const char*, path
, vki_fhandle_t
*, fhp
, int, flag
);
6237 PRE_MEM_RASCIIZ( "getfhat(path)", ARG2
);
6238 PRE_MEM_WRITE("getfhat(fhp)", ARG3
, sizeof(vki_fhandle_t
));
6243 POST_MEM_WRITE(ARG3
, sizeof(vki_fhandle_t
));
6247 // int fhlink(fhandle_t *fhp, const char *to);
6250 PRINT("sys_fhlink ( %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x )", ARG1
, ARG2
);
6251 PRE_REG_READ2(int, "fhlink", vki_fhandle_t
*, fhp
, const char *, to
);
6252 PRE_MEM_READ( "fhlink(fhp)", ARG1
, sizeof(vki_fhandle_t
));
6253 PRE_MEM_RASCIIZ("fhlink(buf)", ARG2
);
6257 // int fhlinkat(fhandle_t *fhp, int tofd, const char *to);
6260 PRINT("sys_fhlinkat ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"xu ", ARG1
, SARG2
, ARG3
);
6261 PRE_REG_READ3(int, "fhlinkat", vki_fhandle_t
*, fhp
, int, tofd
, const char *, to
);
6262 PRE_MEM_READ( "fhlinkat(fhp)", ARG1
, sizeof(vki_fhandle_t
));
6263 PRE_MEM_RASCIIZ("fhreadlink(to)", ARG3
);
6266 // SYS_fhreadlink 567
6267 // int fhreadlink(fhandle_t *fhp, char *buf, size_t bufsize);
6270 PRINT("sys_fhreadlink ( %#" FMT_REGWORD
"x, %" FMT_REGWORD
"x, %" FMT_REGWORD
"u ", ARG1
, ARG2
, ARG3
);
6271 PRE_REG_READ3(int, "fhreadlink", vki_fhandle_t
*, fhp
, char *, buf
, size_t, bufsize
);
6272 PRE_MEM_READ( "fhreadlink(fhp)", ARG1
, sizeof(vki_fhandle_t
));
6273 PRE_MEM_WRITE("fhreadlink(buf)", ARG2
, ARG3
);
6276 POST(sys_fhreadlink
)
6278 POST_MEM_WRITE(ARG2
, ARG3
);
6283 #if (FREEBSD_VERS >= FREEBSD_12_2)
6286 // int funlinkat(int dfd, const char *path, int fd, int flag);
6289 *flags
|= SfMayBlock
;
6290 PRINT("sys_funlinkat ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %" FMT_REGWORD
"u )",
6291 SARG1
, ARG2
, (char*)ARG2
, ARG4
, ARG5
);
6292 PRE_REG_READ4(int, "funlinkat", int, dfd
, const char *, path
, int, fd
, int, flag
);
6293 PRE_MEM_RASCIIZ( "funlinkat(path)", ARG2
);
6296 // SYS_copy_file_range 569
6297 // ssize_t copy_file_range(int infd, off_t *inoffp, int outfd, off_t *outoffp,
6298 // size_t len, unsigned int flags);
6299 PRE(sys_copy_file_range
)
6301 PRINT("sys_copy_file_range (%" FMT_REGWORD
"d, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"d, %" FMT_REGWORD
"d)",
6302 SARG1
, ARG2
, SARG3
, ARG4
, (char*)ARG4
, SARG5
, SARG6
);
6304 PRE_REG_READ6(vki_ssize_t
, "copy_file_range",
6306 vki_off_t
*, "inoffp",
6308 vki_off_t
*, "outoffp",
6310 unsigned int, "flags");
6312 /* File descriptors are "specially" tracked by valgrind.
6313 valgrind itself uses some, so make sure someone didn't
6314 put in one of our own... */
6315 if (!ML_(fd_allowed
)(ARG1
, "copy_file_range(infd)", tid
, False
) ||
6316 !ML_(fd_allowed
)(ARG3
, "copy_file_range(infd)", tid
, False
)) {
6317 SET_STATUS_Failure( VKI_EBADF
);
6319 /* Now see if the offsets are defined. PRE_MEM_READ will
6320 double check it can dereference them. */
6322 PRE_MEM_READ( "copy_file_range(inoffp)", ARG2
, sizeof(vki_off_t
));
6324 PRE_MEM_READ( "copy_file_range(outoffp)", ARG4
, sizeof(vki_off_t
));
6329 // SYS___sysctlbyname 570
6330 // int sysctlbyname(const char *name, void *oldp, size_t *oldlenp,
6331 // const void *newp, size_t newlen);
6333 // int __sysctlbyname(_In_reads_(namelen) const char *name, size_t namelen,
6334 // _Out_writes_bytes_opt_(*oldlenp) void *old,
6335 // _Inout_opt_ size_t *oldlenp, _In_reads_bytes_opt_(newlen) void *new,
6337 PRE(sys___sysctlbyname
)
6339 // this is very much like SYS___sysctl, instead of having an OID with length
6340 // here threre is an ascii string with length
6341 // @todo PJF factor out the common functionality of the two
6342 PRINT("sys___sysctlbyname ( %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u )", ARG1
,(const char*)ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
6343 PRE_REG_READ6(int, "__sysctlbyname", const char *, name
, vki_size_t
, namelen
,
6344 void *, oldp
, vki_size_t
*, oldlenp
,
6345 void *, newp
, vki_size_t
, newlen
);
6348 const char* name
= (const char*)ARG1
;
6349 if (ML_(safe_to_deref
)(name
, sizeof("kern.ps_strings")) &&
6350 VG_(strcmp
)(name
, "kern.ps_strings") == 0) {
6351 if (sysctl_kern_ps_strings((SizeT
*)ARG3
, (SizeT
*)ARG4
)) {
6352 SET_STATUS_Success(0);
6356 if (ML_(safe_to_deref
)(name
, sizeof("kern.usrstack")) &&
6357 VG_(strcmp
)(name
, "kern.usrstack") == 0) {
6358 sysctl_kern_usrstack((SizeT
*)ARG3
, (SizeT
*)ARG4
);
6359 SET_STATUS_Success(0);
6362 // read number of ints specified in ARG2 from mem pointed to by ARG1
6363 PRE_MEM_READ("__sysctlbyname(name)", (Addr
)ARG1
, ARG2
* sizeof(int));
6365 // if 'newp' is not NULL can read namelen bytes from that addess
6366 if (ARG5
!= (UWord
)NULL
)
6367 PRE_MEM_READ("__sysctlbyname(newp)", (Addr
)ARG5
, ARG6
);
6369 // there are two scenarios for oldlenp/oldp
6370 // 1. oldval is NULL and oldlenp is non-NULL
6371 // this is a query of oldlenp so oldlenp will be written
6372 // 2. Both are non-NULL
6373 // this is a query of oldp, oldlenp will be read and oldp will
6376 // is oldlenp is not NULL, can write
6377 if (ARG4
!= (UWord
)NULL
) {
6378 if (ARG3
!= (UWord
)NULL
) {
6380 PRE_MEM_READ("__sysctlbyname(oldlenp)", (Addr
)ARG4
, sizeof(vki_size_t
));
6381 if (ML_(safe_to_deref
)((void*)(Addr
)ARG4
, sizeof(vki_size_t
))) {
6382 PRE_MEM_WRITE("__sysctlbyname(oldp)", (Addr
)ARG3
, *(vki_size_t
*)ARG4
);
6384 VG_(dmsg
)("Warning: Bad oldlenp address %p in sysctlbyname\n",
6385 (void *)(Addr
)ARG4
);
6386 SET_STATUS_Failure ( VKI_EFAULT
);
6390 PRE_MEM_WRITE("__sysctlbyname(oldlenp)", (Addr
)ARG4
, sizeof(vki_size_t
));
6395 POST(sys___sysctlbyname
)
6397 if (ARG4
!= (UWord
)NULL
) {
6398 if (ARG3
!= (UWord
)NULL
) {
6399 //POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t));
6400 POST_MEM_WRITE((Addr
)ARG3
, *(vki_size_t
*)ARG4
);
6402 POST_MEM_WRITE((Addr
)ARG4
, sizeof(vki_size_t
));
6406 #endif // (FREEBSD_VERS >= FREEBSD_12_2)
6408 #if (FREEBSD_VERS >= FREEBSD_13_0)
6410 // SYS_shm_open2 571
6411 // from syscalls.master
6412 // int shm_open2(_In_z_ const char *path,
6416 // _In_z_ const char *name);
6419 PRE_REG_READ5(int, "shm_open2",
6420 const char *, path
, int, flags
, vki_mode_t
, mode
, int, shmflags
, const char*, name
);
6421 if (ARG1
== VKI_SHM_ANON
) {
6422 PRINT("sys_shm_open2(%#" FMT_REGWORD
"x(SHM_ANON), %" FMT_REGWORD
"u, %hu, %d, %#" FMT_REGWORD
"x(%s))",
6423 ARG1
, ARG2
, (vki_mode_t
)ARG3
, (Int
)ARG4
, ARG5
, (HChar
*)ARG5
);
6425 PRINT("sys_shm_open2(%#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u, %hu, %d, %#" FMT_REGWORD
"x(%s))",
6426 ARG1
, (HChar
*)ARG1
, ARG2
, (vki_mode_t
)ARG3
, (Int
)ARG4
, ARG5
, (HChar
*)ARG5
);
6427 PRE_MEM_RASCIIZ( "shm_open2(path)", ARG1
);
6431 PRE_MEM_RASCIIZ( "shm_open2(name)", ARG5
);
6433 *flags
|= SfMayBlock
;
6439 if (!ML_(fd_allowed
)(RES
, "shm_open2", tid
, True
)) {
6441 SET_STATUS_Failure( VKI_EMFILE
);
6443 if (VG_(clo_track_fds
))
6444 ML_(record_fd_open_with_given_name
)(tid
, RES
, (HChar
*)ARG1
);
6449 // int sigfastblock(int cmd, void *ptr);
6450 PRE(sys_sigfastblock
)
6452 PRINT("sys_sigfastblock ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x )", SARG1
, ARG2
);
6453 PRE_REG_READ2(int, "sigfasblock", int, cmd
, void*, ptr
);
6456 // SYS___realpathat 574
6457 // from syscalls.master
6458 // int __realpathat(int fd,
6459 // _In_z_ const char *path,
6460 // _Out_writes_z_(size) char *buf,
6463 PRE(sys___realpathat
)
6465 PRINT("sys___realpathat ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x(%s), %#" FMT_REGWORD
"x, %" FMT_REGWORD
"u %" FMT_REGWORD
"d )",
6466 SARG1
,ARG2
,(const char*)ARG2
,ARG3
,ARG4
,SARG5
);
6467 PRE_REG_READ5(int, "__realpathat", int, fd
, const char *, path
,
6468 char *, buf
, vki_size_t
, size
, int, flags
);
6469 PRE_MEM_RASCIIZ("__realpathat(path)", (Addr
)ARG2
);
6470 PRE_MEM_WRITE("__realpathat(buf)", (Addr
)ARG3
, ARG4
);
6473 POST(sys___realpathat
)
6475 POST_MEM_WRITE((Addr
)ARG3
, ARG4
);
6478 // SYS___specialfd 577
6480 // int __specialfd(int type,
6481 // _In_reads_bytes_(len) const void *req,
6483 PRE(sys___specialfd
)
6485 PRINT("sys___specialfd ( %" FMT_REGWORD
"d, %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u )",
6486 SARG1
,ARG2
,(const char*)ARG2
,ARG3
);
6487 PRE_REG_READ3(int, "__specialfd", int, type
, const void *, req
, vki_size_t
, len
);
6488 PRE_MEM_READ("__specialfd(req)", (Addr
)ARG2
, ARG3
);
6491 #endif // (FREEBSD_VERS >= FREEBSD_13_0)
6493 #if (FREEBSD_VERS >= FREEBSD_13_1)
6496 // int swapoff(const char *special, u_int flags);
6499 PRINT("sys_swapoff ( %#" FMT_REGWORD
"x(%s), %" FMT_REGWORD
"u )", ARG1
,(char *)ARG1
, ARG2
);
6500 PRE_REG_READ2(int, "swapoff", const char *, special
, u_int
, flags
);
6501 PRE_MEM_RASCIIZ( "swapoff(special)", ARG1
);
6509 const SyscallTableEntry
ML_(syscall_table
)[] = {
6510 // syscall (handled specially) // 0
6511 BSDX_(__NR_exit
, sys_exit
), // 1
6512 BSDX_(__NR_fork
, sys_fork
), // 2
6513 GENXY(__NR_read
, sys_read
), // 3
6515 GENX_(__NR_write
, sys_write
), // 4
6516 GENXY(__NR_open
, sys_open
), // 5
6517 GENXY(__NR_close
, sys_close
), // 6
6518 GENXY(__NR_wait4
, sys_wait4
), // 7
6521 GENX_(__NR_link
, sys_link
), // 9
6522 GENX_(__NR_unlink
, sys_unlink
), // 10
6525 GENX_(__NR_chdir
, sys_chdir
), // 12
6526 GENX_(__NR_fchdir
, sys_fchdir
), // 13
6527 GENX_(__NR_freebsd11_mknod
, sys_mknod
), // 14
6528 GENX_(__NR_chmod
, sys_chmod
), // 15
6530 GENX_(__NR_chown
, sys_chown
), // 16
6531 GENX_(__NR_break
, sys_brk
), // 17
6532 // freebsd 4 getfsstat 18
6535 GENX_(__NR_getpid
, sys_getpid
), // 20
6536 BSDX_(__NR_mount
, sys_mount
), // 21
6537 BSDX_(__NR_unmount
, sys_unmount
), // 22
6538 GENX_(__NR_setuid
, sys_setuid
), // 23
6540 GENX_(__NR_getuid
, sys_getuid
), // 24
6541 GENX_(__NR_geteuid
, sys_geteuid
), // 25
6542 BSDXY(__NR_ptrace
, sys_ptrace
), // 26
6543 BSDXY(__NR_recvmsg
, sys_recvmsg
), // 27
6545 BSDX_(__NR_sendmsg
, sys_sendmsg
), // 28
6546 BSDXY(__NR_recvfrom
, sys_recvfrom
), // 29
6547 BSDXY(__NR_accept
, sys_accept
), // 30
6548 BSDXY(__NR_getpeername
, sys_getpeername
), // 31
6550 BSDXY(__NR_getsockname
, sys_getsockname
), // 32
6551 GENX_(__NR_access
, sys_access
), // 33
6552 BSDX_(__NR_chflags
, sys_chflags
), // 34
6553 BSDX_(__NR_fchflags
, sys_fchflags
), // 35
6555 GENX_(__NR_sync
, sys_sync
), // 36
6556 GENX_(__NR_kill
, sys_kill
), // 37
6558 GENX_(__NR_getppid
, sys_getppid
), // 39
6561 GENXY(__NR_dup
, sys_dup
), // 41
6563 BSDXY(__NR_freebsd10_pipe
, sys_pipe
), // 42
6564 GENX_(__NR_getegid
, sys_getegid
), // 43
6566 GENX_(__NR_profil
, sys_ni_syscall
), // 44
6567 GENX_(__NR_ktrace
, sys_ni_syscall
), // 45
6569 GENX_(__NR_getgid
, sys_getgid
), // 47
6571 // 4.3 sigaction (int sigset) 48
6572 BSDXY(__NR_getlogin
, sys_getlogin
), // 49
6573 BSDX_(__NR_setlogin
, sys_setlogin
), // 50
6574 GENX_(__NR_acct
, sys_acct
), // 51
6576 // 4.3 sigpending 52
6577 GENXY(__NR_sigaltstack
, sys_sigaltstack
), // 53
6578 BSDXY(__NR_ioctl
, sys_ioctl
), // 54
6579 BSDX_(__NR_reboot
, sys_reboot
), // 55
6581 BSDX_(__NR_revoke
, sys_revoke
), // 56
6582 GENX_(__NR_symlink
, sys_symlink
), // 57
6583 GENX_(__NR_readlink
, sys_readlink
), // 58
6584 GENX_(__NR_execve
, sys_execve
), // 59
6586 GENX_(__NR_umask
, sys_umask
), // 60
6587 GENX_(__NR_chroot
, sys_chroot
), // 61
6589 // 4.3 getgerninfo 63
6591 // 4.3 getpagesize 64
6592 GENX_(__NR_msync
, sys_msync
), // 65
6593 BSDX_(__NR_vfork
, sys_vfork
), // 66
6597 BSDX_(__NR_sbrk
, sys_sbrk
), // 69
6598 // not implemented in OS sstk 70
6601 // freebsd11 vadvise 72
6602 GENXY(__NR_munmap
, sys_munmap
), // 73
6603 GENXY(__NR_mprotect
, sys_mprotect
), // 74
6604 GENX_(__NR_madvise
, sys_madvise
), // 75
6608 GENXY(__NR_mincore
, sys_mincore
), // 78
6609 GENXY(__NR_getgroups
, sys_getgroups
), // 79
6611 GENX_(__NR_setgroups
, sys_setgroups
), // 80
6612 GENX_(__NR_getpgrp
, sys_getpgrp
), // 81
6613 GENX_(__NR_setpgid
, sys_setpgid
), // 82
6614 GENXY(__NR_setitimer
, sys_setitimer
), // 83
6617 BSDX_(__NR_swapon
, sys_swapon
), // 85
6618 GENXY(__NR_getitimer
, sys_getitimer
), // 86
6619 // 4.3 gethostname 87
6621 // 4.3 sethostname 88
6622 BSDX_(__NR_getdtablesize
, sys_getdtablesize
), // 89
6623 GENXY(__NR_dup2
, sys_dup2
), // 90
6625 BSDXY(__NR_fcntl
, sys_fcntl
), // 92
6626 GENX_(__NR_select
, sys_select
), // 93
6627 GENX_(__NR_fsync
, sys_fsync
), // 95
6629 GENX_(__NR_setpriority
, sys_setpriority
), // 96
6630 BSDXY(__NR_socket
, sys_socket
), // 97
6631 BSDX_(__NR_connect
, sys_connect
), // 98
6634 GENX_(__NR_getpriority
, sys_getpriority
), // 100
6637 // 4.3 sigreturn 103
6639 BSDX_(__NR_bind
, sys_bind
), // 104
6640 BSDX_(__NR_setsockopt
, sys_setsockopt
), // 105
6641 BSDX_(__NR_listen
, sys_listen
), // 106
6646 // 4.3 sigsetmask 110
6647 // 4.3 sigsuspend 111
6654 GENXY(__NR_gettimeofday
, sys_gettimeofday
), // 116
6655 GENXY(__NR_getrusage
, sys_getrusage
), // 117
6656 BSDXY(__NR_getsockopt
, sys_getsockopt
), // 118
6658 GENXY(__NR_readv
, sys_readv
), // 120
6659 GENX_(__NR_writev
, sys_writev
), // 121
6660 GENX_(__NR_settimeofday
, sys_settimeofday
), // 122
6661 GENX_(__NR_fchown
, sys_fchown
), // 123
6663 GENX_(__NR_fchmod
, sys_fchmod
), // 124
6665 GENX_(__NR_setreuid
, sys_setreuid
), // 126
6666 GENX_(__NR_setregid
, sys_setregid
), // 127
6668 GENX_(__NR_rename
, sys_rename
), // 128
6670 // 4.3 ftruncate 130
6671 GENX_(__NR_flock
, sys_flock
), // 131
6673 BSDX_(__NR_mkfifo
, sys_mkfifo
), // 132
6674 BSDX_(__NR_sendto
, sys_sendto
), // 133
6675 BSDX_(__NR_shutdown
, sys_shutdown
), // 134
6676 BSDXY(__NR_socketpair
, sys_socketpair
), // 135
6678 GENX_(__NR_mkdir
, sys_mkdir
), // 136
6679 GENX_(__NR_rmdir
, sys_rmdir
), // 137
6680 GENX_(__NR_utimes
, sys_utimes
), // 138
6681 // 4.2 sigreturn 139
6683 BSDXY(__NR_adjtime
, sys_adjtime
), // 140
6684 // 4.3 getpeername 141
6685 // 4.3 gethostid 142
6686 // 4.3 sethostid 143
6688 // 4.3 getrlimit` 144
6689 // 4.3 setrlimit 145
6691 GENX_(__NR_setsid
, sys_setsid
), // 147
6693 BSDX_(__NR_quotactl
, sys_quotactl
), // 148
6695 // 4.3 getsockname 150
6696 // bsd/os sem_lock 151
6698 // bsd/os sem_wakeup 152
6699 // bsd/os asyncdaemon 153
6701 // no idea what the following syscall does
6702 // unimp SYS_nlm_syscall 154
6704 // a somewhat complicated NFS API
6705 // takes a flag and a void* that can point to one of
6706 // three different types of struct depending on the flag
6707 // unimp SYS_nfssvc 155
6709 // 4.3 getdirentries 156
6710 // freebsd 4 statfs 157
6711 // freebsd 4 fstatfs 158
6713 BSDXY(__NR_lgetfh
, sys_lgetfh
), // 160
6714 BSDXY(__NR_getfh
, sys_getfh
), // 161
6715 #if (FREEBSD_VERS <= FREEBSD_10)
6716 BSDXY(__NR_freebsd4_getdomainname
, sys_freebsd4_getdomainname
), // 162
6717 BSDX_(__NR_freebsd4_setdomainname
, sys_freebsd4_setdomainname
), // 163
6718 BSDXY(__NR_freebsd4_uname
, sys_freebsd4_uname
), // 164
6720 BSDXY(__NR_sysarch
, sys_sysarch
), // 165
6721 BSDXY(__NR_rtprio
, sys_rtprio
), // 166
6723 // the following 3 seem only to be defines in a header
6728 #if (FREEBSD_VERS <= FREEBSD_10)
6729 BSDXY(__NR_freebsd6_pread
, sys_freebsd6_pread
), // 173
6730 BSDX_(__NR_freebsd6_pwrite
, sys_freebsd6_pwrite
), // 174
6732 BSDX_(__NR_setfib
, sys_setfib
), // 175
6734 // @todo PJF this exists on Darwin and Solaris as well
6735 // and it isn't implememented on either
6736 // looking at the manpage there is a rather fearsome
6737 // timex struct with a mixture of ro and rw fields
6738 // BSDXY(__NR_ntp_adjtime, sys_ntp_adjtime), // 176
6741 // bsd/os getdescriptor 178
6742 // bsd/os setdescriptor 179
6744 GENX_(__NR_setgid
, sys_setgid
), // 181
6745 BSDX_(__NR_setegid
, sys_setegid
), // 182
6746 BSDX_(__NR_seteuid
, sys_seteuid
), // 183
6748 // obs lfs_bmapv 184
6749 // obs lfs_markv 185
6750 // obs lfs_segclean 186
6751 // obs lfs_segwait 187
6753 #if (FREEBSD_VERS >= FREEBSD_12)
6754 BSDXY(__NR_freebsd11_stat
, sys_freebsd11_stat
), // 188
6755 BSDXY(__NR_freebsd11_fstat
, sys_freebsd11_fstat
), // 189
6756 BSDXY(__NR_freebsd11_lstat
, sys_freebsd11_lstat
), // 190
6758 BSDXY(__NR_stat
, sys_stat
), // 188
6759 BSDXY(__NR_fstat
, sys_fstat
), // 189
6760 BSDXY(__NR_lstat
, sys_lstat
), // 190
6762 BSDX_(__NR_pathconf
, sys_pathconf
), // 191
6763 BSDX_(__NR_fpathconf
, sys_fpathconf
), // 192
6764 GENXY(__NR_getrlimit
, sys_getrlimit
), // 194
6765 GENX_(__NR_setrlimit
, sys_setrlimit
), // 195
6766 #if (FREEBSD_VERS >= FREEBSD_12)
6767 BSDXY(__NR_freebsd11_getdirentries
, sys_freebsd11_getdirentries
), // 196
6769 BSDXY(__NR_getdirentries
, sys_getdirentries
), // 196
6771 #if (FREEBSD_VERS <= FREEBSD_10)
6772 BSDX_(__NR_freebsd6_mmap
, sys_freebsd6_mmap
), // 197
6774 // __syscall (handled specially) // 198
6775 #if (FREEBSD_VERS <= FREEBSD_10)
6776 BSDX_(__NR_freebsd6_lseek
, sys_freebsd6_lseek
), // 199
6777 BSDX_(__NR_freebsd6_truncate
, sys_freebsd6_truncate
), // 200
6778 BSDX_(__NR_freebsd6_ftruncate
, sys_freebsd6_ftruncate
), // 201
6780 BSDXY(__NR___sysctl
, sys___sysctl
), // 202
6781 GENX_(__NR_mlock
, sys_mlock
), // 203
6783 GENX_(__NR_munlock
, sys_munlock
), // 204
6784 BSDX_(__NR_undelete
, sys_undelete
), // 205
6785 BSDX_(__NR_futimes
, sys_futimes
), // 206
6786 GENX_(__NR_getpgid
, sys_getpgid
), // 207
6788 // netbsd newreboot 208
6789 GENXY(__NR_poll
, sys_poll
), // 209
6791 BSDXY(__NR_freebsd7___semctl
, sys_freebsd7___semctl
), // 220
6792 BSDX_(__NR_semget
, sys_semget
), // 221
6793 BSDX_(__NR_semop
, sys_semop
), // 222
6794 // obs semconfig 223
6796 BSDXY(__NR_freebsd7_msgctl
, sys_freebsd7_msgctl
), // 224
6797 BSDX_(__NR_msgget
, sys_msgget
), // 225
6798 BSDX_(__NR_msgsnd
, sys_msgsnd
), // 226
6799 BSDXY(__NR_msgrcv
, sys_msgrcv
), // 227
6801 BSDXY(__NR_shmat
, sys_shmat
), // 228
6802 BSDXY(__NR_freebsd7_shmctl
, sys_freebsd7_shmctl
), // 229
6803 BSDXY(__NR_shmdt
, sys_shmdt
), // 230
6804 BSDX_(__NR_shmget
, sys_shmget
), // 231
6806 BSDXY(__NR_clock_gettime
, sys_clock_gettime
), // 232
6807 BSDX_(__NR_clock_settime
, sys_clock_settime
), // 233
6808 BSDXY(__NR_clock_getres
, sys_clock_getres
), // 234
6809 BSDXY(__NR_ktimer_create
, sys_timer_create
), // 235
6810 BSDX_(__NR_ktimer_delete
, sys_timer_delete
), // 236
6811 BSDXY(__NR_ktimer_settime
, sys_timer_settime
), // 237
6812 BSDXY(__NR_ktimer_gettime
, sys_timer_gettime
), // 238
6813 BSDX_(__NR_ktimer_getoverrun
, sys_timer_getoverrun
), // 239
6815 GENXY(__NR_nanosleep
, sys_nanosleep
), // 240
6816 // unimpl SYS_ffclock_getcounter 241
6817 // unimpl SYS_ffclock_setestimate 242
6818 // unimpl SYS_ffclock_getestimate 243
6820 BSDXY(__NR_clock_nanosleep
, sys_clock_nanosleep
), // 244
6821 BSDXY(__NR_clock_getcpuclockid2
, sys_clock_getcpuclockid2
), // 247
6823 // unimpl SYS_ntp_gettime 248
6824 BSDXY(__NR_minherit
, sys_minherit
), // 250
6825 BSDX_(__NR_rfork
, sys_rfork
), // 251
6827 // openbsd_poll // 252
6828 BSDX_(__NR_issetugid
, sys_issetugid
), // 253
6829 GENX_(__NR_lchown
, sys_lchown
), // 254
6830 BSDXY(__NR_aio_read
, sys_aio_read
), // 255
6831 BSDXY(__NR_aio_write
, sys_aio_write
), // 256
6832 BSDX_(__NR_lio_listio
, sys_lio_listio
), // 257
6834 GENXY(__NR_freebsd11_getdents
, sys_getdents
), // 272
6835 BSDX_(__NR_lchmod
, sys_lchmod
), // 274
6836 // netbsd_lchown // 275
6838 BSDX_(__NR_lutimes
, sys_lutimes
), // 276
6840 // unimpl SYS_freebsd11_nstat 278
6841 // unimpl SYS_freebsd11_nfstat 279
6843 // unimpl SYS_freebsd11_nlstat 280
6845 BSDXY(__NR_preadv
, sys_preadv
), // 289
6846 BSDX_(__NR_pwritev
, sys_pwritev
), // 290
6848 // freebsd 4 fhstatfs 297
6849 BSDXY(__NR_fhopen
, sys_fhopen
), // 298
6850 #if (FREEBSD_VERS >= FREEBSD_12)
6851 BSDXY(__NR_freebsd11_fhstat
, sys_freebsd11_fhstat
), // 299
6853 BSDXY(__NR_fhstat
, sys_fhstat
), // 299
6856 BSDX_(__NR_modnext
, sys_modnext
), // 300
6857 BSDXY(__NR_modstat
, sys_modstat
), // 301
6858 BSDX_(__NR_modfnext
, sys_modfnext
), // 302
6859 BSDX_(__NR_modfind
, sys_modfind
), // 303
6861 BSDX_(__NR_kldload
, sys_kldload
), // 304
6862 BSDX_(__NR_kldunload
, sys_kldunload
), // 305
6863 BSDX_(__NR_kldfind
, sys_kldfind
), // 306
6864 BSDX_(__NR_kldnext
, sys_kldnext
), // 307
6866 BSDXY(__NR_kldstat
, sys_kldstat
), // 308
6867 BSDX_(__NR_kldfirstmod
, sys_kldfirstmod
), // 309
6868 GENX_(__NR_getsid
, sys_getsid
), // 310
6869 BSDX_(__NR_setresuid
, sys_setresuid
), // 311
6871 BSDX_(__NR_setresgid
, sys_setresgid
), // 312
6872 // obsol signanosleep 313
6873 BSDX_(__NR_aio_return
, sys_aio_return
), // 314
6874 BSDX_(__NR_aio_suspend
, sys_aio_suspend
), // 315
6876 BSDX_(__NR_aio_cancel
, sys_aio_cancel
), // 316
6877 BSDX_(__NR_aio_error
, sys_aio_error
), // 317
6878 // freebsd 6 aio_read 318
6879 // freebsd 6 aio_write 319
6880 // freebsd 6 lio_listio 320
6881 BSDX_(__NR_yield
, sys_yield
), // 321
6882 // obs thr_sleep 322
6883 // obs thr_wakeup 323
6885 GENX_(__NR_mlockall
, sys_mlockall
), // 324
6886 BSDX_(__NR_munlockall
, sys_munlockall
), // 325
6887 BSDXY(__NR___getcwd
, sys___getcwd
), // 326
6888 BSDX_(__NR_sched_setparam
, sys_sched_setparam
), // 327
6889 BSDXY(__NR_sched_getparam
, sys_sched_getparam
), // 328
6890 BSDX_(__NR_sched_setscheduler
, sys_sched_setscheduler
), // 329
6891 BSDX_(__NR_sched_getscheduler
, sys_sched_getscheduler
), // 330
6892 BSDX_(__NR_sched_yield
, sys_sched_yield
), // 331
6894 BSDX_(__NR_sched_get_priority_max
, sys_sched_get_priority_max
), // 332
6895 BSDX_(__NR_sched_get_priority_min
, sys_sched_get_priority_min
), // 333
6896 BSDXY(__NR_sched_rr_get_interval
, sys_sched_rr_get_interval
), // 334
6897 BSDX_(__NR_utrace
, sys_utrace
), // 335
6899 // freebsd 4 sendfile 336
6900 BSDXY(__NR_kldsym
, sys_kldsym
), // 337
6901 BSDX_(__NR_jail
, sys_jail
), // 338
6902 // unimpl SYS_nnpfs_syscall 339
6904 BSDXY(__NR_sigprocmask
, sys_sigprocmask
), // 340
6905 BSDXY(__NR_sigsuspend
, sys_sigsuspend
), // 341
6906 // freebsd 4 sigaction 342
6907 BSDXY(__NR_sigpending
, sys_sigpending
), // 343
6909 // freebsd 4 sigreturn 344
6910 BSDXY(__NR_sigtimedwait
, sys_sigtimedwait
), // 345
6911 BSDXY(__NR_sigwaitinfo
, sys_sigwaitinfo
), // 346
6912 BSDXY(__NR___acl_get_file
, sys___acl_get_file
), // 347
6914 BSDX_(__NR___acl_set_file
, sys___acl_set_file
), // 348
6915 BSDXY(__NR___acl_get_fd
, sys___acl_get_fd
), // 349
6916 BSDX_(__NR___acl_set_fd
, sys___acl_set_fd
), // 350
6917 BSDX_(__NR___acl_delete_file
, sys___acl_delete_file
), // 351
6919 BSDX_(__NR___acl_delete_fd
, sys___acl_delete_fd
), // 352
6920 BSDX_(__NR___acl_aclcheck_file
, sys___acl_aclcheck_file
), // 353
6921 BSDX_(__NR___acl_aclcheck_fd
, sys___acl_aclcheck_fd
), // 354
6922 BSDX_(__NR_extattrctl
, sys_extattrctl
), // 355
6923 BSDX_(__NR_extattr_set_file
, sys_extattr_set_file
), // 356
6924 BSDXY(__NR_extattr_get_file
, sys_extattr_get_file
), // 357
6925 BSDX_(__NR_extattr_delete_file
, sys_extattr_delete_file
), // 358
6926 BSDXY(__NR_aio_waitcomplete
, sys_aio_waitcomplete
), // 359
6928 BSDXY(__NR_getresuid
, sys_getresuid
), // 360
6929 BSDXY(__NR_getresgid
, sys_getresgid
), // 361
6930 BSDXY(__NR_kqueue
, sys_kqueue
), // 362
6931 #if (FREEBSD_VERS >= FREEBSD_12)
6932 BSDXY(__NR_freebsd11_kevent
, sys_freebsd11_kevent
), // 363
6934 BSDXY(__NR_kevent
, sys_kevent
), // 363
6936 // obs __cap_get_proc 364
6937 // obs __cap_set_proc 365
6938 // obs __cap_get_fd 366
6939 // obs __cap_get_file 367
6940 // obs __cap_set_fd 368
6941 // obs __cap_set_file 369
6943 BSDX_(__NR_extattr_set_fd
, sys_extattr_set_fd
), // 371
6944 BSDXY(__NR_extattr_get_fd
, sys_extattr_get_fd
), // 372
6945 BSDX_(__NR_extattr_delete_fd
, sys_extattr_delete_fd
), // 373
6946 BSDX_(__NR___setugid
, sys___setugid
), // 374
6949 BSDX_(__NR_eaccess
, sys_eaccess
), // 376
6950 // unimpl afs3_syscall 377
6951 BSDX_(__NR_nmount
, sys_nmount
), // 378
6953 // obs kse_wakeup 380
6954 // obs kse_create 381
6955 // obs kse_thr_interrupt 382
6956 // obs kse_release 383
6958 // unimpl __mac_get_proc 384
6959 // unimpl __mac_set_proc 385
6960 // unimpl __mac_get_fd 386
6961 // unimpl __mac_get_file 387
6962 // unimpl __mac_set_fd 388
6963 // unimpl __mac_set_file 389
6964 BSDXY(__NR_kenv
, sys_kenv
), // 390
6965 BSDX_(__NR_lchflags
, sys_lchflags
), // 391
6967 BSDXY(__NR_uuidgen
, sys_uuidgen
), // 392
6968 BSDXY(__NR_sendfile
, sys_sendfile
), // 393
6969 // unimpl mac_syscall 394
6971 #if (FREEBSD_VERS >= FREEBSD_12)
6972 BSDXY(__NR_freebsd11_getfsstat
, sys_freebsd11_getfsstat
), // 395
6973 BSDXY(__NR_freebsd11_statfs
, sys_statfs
), // 396
6974 BSDXY(__NR_freebsd11_fstatfs
, sys_fstatfs
), // 397
6975 BSDXY(__NR_freebsd11_fhstatfs
, sys_fhstatfs
), // 398
6977 BSDXY(__NR_getfsstat
, sys_getfsstat
), // 395
6978 BSDXY(__NR_statfs
, sys_statfs
), // 396
6979 BSDXY(__NR_fstatfs
, sys_fstatfs
), // 397
6980 BSDXY(__NR_fhstatfs
, sys_fhstatfs
), // 398
6983 // unimpl ksem_close 400
6984 // unimpl ksem_post 401
6985 // unimpl ksem_wait 402
6986 // unimpl ksem_trywait 403
6988 // unimpl ksem_init 404
6989 // unimpl ksem_open 405
6990 // unimpl ksem_unlink 406
6991 // unimpl ksem_getvalue 407
6993 // unimpl ksem_destroy 408
6994 // unimpl __mac_get_pid 409
6995 // unimpl __mac_get_link 410
6996 // unimpl __mac_set_link 411
6998 BSDX_(__NR_extattr_set_link
, sys_extattr_set_link
), // 412
6999 BSDXY(__NR_extattr_get_link
, sys_extattr_get_link
), // 413
7000 BSDX_(__NR_extattr_delete_link
, sys_extattr_delete_link
), // 414
7001 // unimpl __mac_execve 415
7003 BSDXY(__NR_sigaction
, sys_sigaction
), // 416
7004 BSDX_(__NR_sigreturn
, sys_sigreturn
), // 417
7006 BSDXY(__NR_getcontext
, sys_getcontext
), // 421
7007 BSDX_(__NR_setcontext
, sys_setcontext
), // 422
7008 BSDXY(__NR_swapcontext
, sys_swapcontext
), // 423
7010 #if (FREEBSD_VERS >= FREEBSD_13_1)
7011 BSDX_(__NR_freebsd13_swapoff
, sys_freebsd13_swapoff
), // 424
7013 BSDX_(__NR_swapoff
, sys_swapoff
), // 424
7015 BSDXY(__NR___acl_get_link
, sys___acl_get_link
), // 425
7016 BSDX_(__NR___acl_set_link
, sys___acl_set_link
), // 426
7017 BSDX_(__NR___acl_delete_link
, sys___acl_delete_link
), // 427
7019 BSDX_(__NR___acl_aclcheck_link
, sys___acl_aclcheck_link
), // 428
7020 BSDXY(__NR_sigwait
, sys_sigwait
), // 429
7021 BSDX_(__NR_thr_create
, sys_thr_create
), // 430
7022 BSDX_(__NR_thr_exit
, sys_thr_exit
), // 431
7024 BSDXY(__NR_thr_self
, sys_thr_self
), // 432
7025 BSDXY(__NR_thr_kill
, sys_thr_kill
), // 433
7026 #if (FREEBSD_VERS <= FREEBSD_10)
7027 BSDXY(__NR__umtx_lock
, sys__umtx_lock
), // 434
7028 BSDXY(__NR__umtx_unlock
, sys__umtx_unlock
), // 435
7031 BSDX_(__NR_jail_attach
, sys_jail_attach
), // 436
7032 BSDXY(__NR_extattr_list_fd
, sys_extattr_list_fd
), // 437
7033 BSDXY(__NR_extattr_list_file
, sys_extattr_list_file
), // 438
7034 BSDXY(__NR_extattr_list_link
, sys_extattr_list_link
), // 439
7036 // obs kse_switchin 440
7037 // unimpl ksem_timedwait 441
7038 BSDX_(__NR_thr_suspend
, sys_thr_suspend
), // 442
7039 BSDX_(__NR_thr_wake
, sys_thr_wake
), // 443
7040 BSDX_(__NR_kldunloadf
, sys_kldunloadf
), // 444
7042 // unimpl auditon 446
7043 // unimpl getauid 447
7045 // unimpl setauid 448
7046 // unimpl getaudit 449
7047 // unimpl setaudit 450
7048 // unimpl getaudit_addr 451
7049 // unimpl setaudit_addr 452
7050 // unimpl auditctl 453
7051 BSDXY(__NR__umtx_op
, sys__umtx_op
), // 454
7052 BSDX_(__NR_thr_new
, sys_thr_new
), // 455
7054 BSDX_(__NR_sigqueue
, sys_sigqueue
), // 456
7055 BSDXY(__NR_kmq_open
, sys_kmq_open
), // 457
7056 BSDX_(__NR_kmq_setattr
, sys_kmq_setattr
), // 458
7057 BSDXY(__NR_kmq_timedreceive
, sys_kmq_timedreceive
), // 459
7059 BSDX_(__NR_kmq_timedsend
, sys_kmq_timedsend
), // 460
7060 BSDX_(__NR_kmq_notify
, sys_kmq_notify
), // 461
7061 BSDX_(__NR_kmq_unlink
, sys_kmq_unlink
), // 462
7062 BSDX_(__NR_abort2
, sys_abort2
), // 463
7064 BSDX_(__NR_thr_set_name
, sys_thr_set_name
), // 464
7065 BSDX_(__NR_aio_fsync
, sys_aio_fsync
), // 465
7066 BSDXY(__NR_rtprio_thread
, sys_rtprio_thread
), // 466
7068 // unimpl sctp_peeloff 471
7069 BSDX_(__NR_sctp_generic_sendmsg
, sys_sctp_generic_sendmsg
), // 472
7070 // unimpl sctp_generic_sendmsg_iov 473
7071 BSDXY(__NR_sctp_generic_recvmsg
, sys_sctp_generic_recvmsg
), // 474
7072 BSDXY(__NR_pread
, sys_pread
), // 475
7074 BSDX_(__NR_pwrite
, sys_pwrite
), // 476
7075 BSDX_(__NR_mmap
, sys_mmap
), // 477
7076 BSDX_(__NR_lseek
, sys_lseek
), // 478
7077 BSDX_(__NR_truncate
, sys_truncate
), // 479
7078 BSDX_(__NR_ftruncate
, sys_ftruncate
), // 480
7079 BSDXY(__NR_thr_kill2
, sys_thr_kill2
), // 481
7080 BSDXY(__NR_shm_open
, sys_shm_open
), // 482
7081 BSDX_(__NR_shm_unlink
, sys_shm_unlink
), // 483
7083 BSDXY(__NR_cpuset
, sys_cpuset
), // 484
7084 BSDX_(__NR_cpuset_setid
, sys_cpuset_setid
), // 485
7085 BSDXY(__NR_cpuset_getid
, sys_cpuset_getid
), // 486
7087 BSDXY(__NR_cpuset_getaffinity
, sys_cpuset_getaffinity
), // 487
7088 BSDX_(__NR_cpuset_setaffinity
, sys_cpuset_setaffinity
), // 488
7089 BSDX_(__NR_faccessat
, sys_faccessat
), // 489
7090 BSDX_(__NR_fchmodat
, sys_fchmodat
), // 490
7091 BSDX_(__NR_fchownat
, sys_fchownat
), // 491
7093 BSDX_(__NR_fexecve
, sys_fexecve
), // 492
7094 #if (FREEBSD_VERS >= FREEBSD_12)
7095 BSDXY(__NR_freebsd11_fstatat
, sys_freebsd11_fstatat
), // 493
7097 BSDXY(__NR_fstatat
, sys_fstatat
), // 493
7099 BSDX_(__NR_futimesat
, sys_futimesat
), // 494
7100 BSDX_(__NR_linkat
, sys_linkat
), // 495
7102 BSDX_(__NR_mkdirat
, sys_mkdirat
), // 496
7103 BSDX_(__NR_mkfifoat
, sys_mkfifoat
), // 497
7105 #if (FREEBSD_VERS >= FREEBSD_12)
7106 BSDX_(__NR_freebsd11_mknodat
, sys_freebsd11_mknodat
), // 498
7108 BSDX_(__NR_mknodat
, sys_mknodat
), // 498
7111 BSDXY(__NR_openat
, sys_openat
), // 499
7113 BSDXY(__NR_readlinkat
, sys_readlinkat
), // 500
7114 BSDX_(__NR_renameat
, sys_renameat
), // 501
7115 BSDX_(__NR_symlinkat
, sys_symlinkat
), // 502
7116 BSDX_(__NR_unlinkat
, sys_unlinkat
), // 503
7118 BSDX_(__NR_posix_openpt
, sys_posix_openpt
), // 504
7119 // unimp gssd_syscall 505
7120 BSDX_(__NR_jail_get
, sys_jail_get
), // 506
7121 BSDX_(__NR_jail_set
, sys_jail_set
), // 507
7122 BSDX_(__NR_jail_remove
, sys_jail_remove
), // 508
7123 BSDX_(__NR_closefrom
, sys_closefrom
), // 509
7124 BSDXY(__NR___semctl
, sys___semctl
), // 510
7125 BSDXY(__NR_msgctl
, sys_msgctl
), // 511
7126 BSDXY(__NR_shmctl
, sys_shmctl
), // 512
7127 BSDX_(__NR_lpathconf
, sys_lpathconf
), // 513
7128 /* 514 is obsolete cap_new */
7129 BSDXY(__NR___cap_rights_get
, sys_cap_rights_get
), // 515
7130 BSDX_(__NR_cap_enter
, sys_cap_enter
), // 516
7131 BSDXY(__NR_cap_getmode
, sys_cap_getmode
), // 517
7132 BSDXY(__NR_pdfork
, sys_pdfork
), // 518
7133 BSDX_(__NR_pdkill
, sys_pdkill
), // 519
7134 BSDXY(__NR_pdgetpid
, sys_pdgetpid
), // 520
7135 BSDXY(__NR_pselect
, sys_pselect
), // 522
7136 BSDXY(__NR_getloginclass
, sys_getloginclass
), // 523
7137 BSDX_(__NR_setloginclass
, sys_setloginclass
), // 524
7138 BSDXY(__NR_rctl_get_racct
, sys_rctl_get_racct
), // 525
7139 BSDXY(__NR_rctl_get_rules
, sys_rctl_get_rules
), // 526
7140 BSDXY(__NR_rctl_get_limits
, sys_rctl_get_limits
), // 527
7141 BSDXY(__NR_rctl_add_rule
, sys_rctl_add_rule
), // 528
7142 BSDXY(__NR_rctl_remove_rule
, sys_rctl_remove_rule
), // 529
7143 BSDX_(__NR_posix_fallocate
, sys_posix_fallocate
), // 530
7144 BSDX_(__NR_posix_fadvise
, sys_posix_fadvise
), // 531
7145 BSDXY(__NR_wait6
, sys_wait6
), // 532
7146 BSDX_(__NR_cap_rights_limit
, sys_cap_rights_limit
), // 533
7147 BSDX_(__NR_cap_ioctls_limit
, sys_cap_ioctls_limit
), // 534
7148 BSDXY(__NR_cap_ioctls_get
, sys_cap_ioctls_get
), // 535
7149 BSDX_(__NR_cap_fcntls_limit
, sys_cap_fcntls_limit
), // 536
7150 BSDXY(__NR_cap_fcntls_get
, sys_cap_fcntls_get
), // 537
7151 BSDX_(__NR_bindat
, sys_bindat
), // 538
7152 BSDX_(__NR_connectat
, sys_connectat
), // 539
7153 BSDX_(__NR_chflagsat
, sys_chflagsat
), // 540
7154 BSDXY(__NR_accept4
, sys_accept4
), // 541
7155 BSDXY(__NR_pipe2
, sys_pipe2
), // 542
7156 BSDX_(__NR_aio_mlock
, sys_aio_mlock
), // 543
7157 BSDXY(__NR_procctl
, sys_procctl
), // 544
7159 // 544 is the highest syscall on FreeBSD 9
7161 #if (FREEBSD_VERS >= FREEBSD_10)
7163 BSDXY(__NR_ppoll
, sys_ppoll
), // 545
7164 BSDX_(__NR_futimens
, sys_futimens
), // 546
7165 BSDX_(__NR_utimensat
, sys_utimensat
), // 547
7167 #endif // FREEBSD_VERS >= FREEBSD_10
7169 #if (FREEBSD_VERS >= FREEBSD_11)
7171 /* 548 is obsolete numa_getaffinity */
7172 /* 549 is obsolete numa_setaffinity */
7173 BSDX_(__NR_fdatasync
, sys_fdatasync
), // 550
7175 #endif // FREEBSD_VERS >= FREEBSD_11
7177 #if (FREEBSD_VERS >= FREEBSD_12)
7178 BSDXY(__NR_fstat
, sys_fstat
), // 551
7179 BSDXY(__NR_fstatat
, sys_fstatat
), // 552
7180 BSDXY(__NR_fhstat
, sys_fhstat
), // 553
7181 BSDXY(__NR_getdirentries
, sys_getdirentries
), // 554
7182 BSDXY(__NR_statfs
, sys_statfs
), // 555
7183 BSDXY(__NR_fstatfs
, sys_fstatfs
), // 556
7184 BSDXY(__NR_getfsstat
, sys_getfsstat
), // 557
7185 BSDXY(__NR_fhstatfs
, sys_fhstatfs
), // 558
7186 BSDX_(__NR_mknodat
, sys_mknodat
), // 559
7187 BSDXY(__NR_kevent
, sys_kevent
), // 560
7188 BSDXY(__NR_cpuset_getdomain
, sys_cpuset_getdomain
), // 561
7189 BSDX_(__NR_cpuset_setdomain
, sys_cpuset_setdomain
), // 562
7190 BSDXY(__NR_getrandom
, sys_getrandom
), // 563
7191 BSDXY(__NR_getfhat
, sys_getfhat
), // 564
7192 BSDX_(__NR_fhlink
, sys_fhlink
), // 565
7193 BSDX_(__NR_fhlinkat
, sys_fhlinkat
), // 566
7194 BSDXY(__NR_fhreadlink
, sys_fhreadlink
), // 567
7195 #endif // FREEBSD_VERS >= FREEBSD_12
7197 #if (FREEBSD_VERS >= FREEBSD_12_2)
7198 BSDX_(__NR_funlinkat
, sys_funlinkat
), // 568
7199 BSDX_(__NR_copy_file_range
, sys_copy_file_range
), // 569
7200 BSDXY(__NR___sysctlbyname
, sys___sysctlbyname
), // 570
7202 #if (FREEBSD_VERS >= FREEBSD_13_0)
7203 BSDXY(__NR_shm_open2
, sys_shm_open2
), // 571
7204 // unimpl __NR_shm_rename 572
7205 BSDX_(__NR_sigfastblock
, sys_sigfastblock
), // 573
7206 BSDXY( __NR___realpathat
, sys___realpathat
), // 574
7208 // unimpl __NR_close_range 575
7211 #if (FREEBSD_VERS >= FREEBSD_13_0)
7212 // unimpl __NR_rpctls_syscall 576
7213 BSDX_(__NR___specialfd
, sys___specialfd
), // 577
7214 // unimpl __NR_aio_writev 578
7215 // unimpl __NR_aio_readv 579
7218 #if (FREEBSD_VERS >= FREEBSD_13_1)
7219 // unimpl __NR_fspacectl 580
7220 // unimpl __NR_sched_getcpu 581
7221 BSDX_(__NR_swapoff
, sys_swapoff
), // 582
7224 BSDX_(__NR_fake_sigreturn
, sys_fake_sigreturn
), // 1000, fake sigreturn
7228 const SyscallTableEntry
* ML_(get_freebsd_syscall_entry
) ( UInt sysno
)
7230 const UInt syscall_table_size
7231 = sizeof(ML_(syscall_table
)) / sizeof(ML_(syscall_table
)[0]);
7233 /* Is it in the contiguous initial section of the table? */
7234 if (sysno
< syscall_table_size
) {
7235 const SyscallTableEntry
* sys
= &ML_(syscall_table
)[sysno
];
7236 if (sys
->before
== NULL
)
7237 return NULL
; /* no entry */
7242 /* Can't find a wrapper */
7246 /*--------------------------------------------------------------------*/
7248 /*--------------------------------------------------------------------*/
7250 #endif // defined(VGO_freebsd)