Handle the dup3 system call. Closes #215448.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10945
This commit is contained in:
Tom Hughes 2009-11-23 08:19:20 +00:00
parent 2cf9be763f
commit 128df057cb
6 changed files with 20 additions and 4 deletions

View File

@ -50,6 +50,7 @@ DECL_TEMPLATE(linux, sys_umount);
DECL_TEMPLATE(linux, sys_perf_counter_open);
DECL_TEMPLATE(linux, sys_preadv);
DECL_TEMPLATE(linux, sys_pwritev);
DECL_TEMPLATE(linux, sys_dup3);
// POSIX, but various sub-cases differ between Linux and Darwin.
DECL_TEMPLATE(linux, sys_fcntl);

View File

@ -1373,7 +1373,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
LINX_(__NR_eventfd2, sys_eventfd2), // 290
LINXY(__NR_epoll_create1, sys_epoll_create1), // 291
// (__NR_dup3, sys_ni_syscall) // 292
LINXY(__NR_dup3, sys_dup3), // 292
LINXY(__NR_pipe2, sys_pipe2), // 293
LINXY(__NR_inotify_init1, sys_inotify_init1), // 294

View File

@ -2411,6 +2411,21 @@ POST(sys_pipe2)
}
}
PRE(sys_dup3)
{
PRINT("sys_dup3 ( %ld, %ld, %ld )", ARG1,ARG2,ARG3);
PRE_REG_READ3(long, "dup3", unsigned int, oldfd, unsigned int, newfd, int, flags);
if (!ML_(fd_allowed)(ARG2, "dup3", tid, True))
SET_STATUS_Failure( VKI_EBADF );
}
POST(sys_dup3)
{
vg_assert(SUCCESS);
if (VG_(clo_track_fds))
ML_(record_fd_open_named)(tid, RES);
}
PRE(sys_quotactl)
{
PRINT("sys_quotactl (0x%lx, %#lx, 0x%lx, 0x%lx )", ARG1,ARG2,ARG3, ARG4);

View File

@ -1865,7 +1865,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
LINXY(__NR_signalfd4, sys_signalfd4), // 313
LINX_(__NR_eventfd2, sys_eventfd2), // 314
LINXY(__NR_epoll_create1, sys_epoll_create1), // 315
// (__NR_dup3, sys_ni_syscall) // 316
LINXY(__NR_dup3, sys_dup3), // 316
LINXY(__NR_pipe2, sys_pipe2), // 317
LINXY(__NR_inotify_init1, sys_inotify_init1), // 318
LINXY(__NR_perf_counter_open, sys_perf_counter_open),// 319

View File

@ -1505,7 +1505,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
LINXY(__NR_signalfd4, sys_signalfd4), // 313
LINX_(__NR_eventfd2, sys_eventfd2), // 314
LINXY(__NR_epoll_create1, sys_epoll_create1), // 315
// (__NR_dup3, sys_ni_syscall) // 316
LINXY(__NR_dup3, sys_dup3), // 316
LINXY(__NR_pipe2, sys_pipe2), // 317
LINXY(__NR_inotify_init1, sys_inotify_init1), // 318
LINXY(__NR_perf_counter_open, sys_perf_counter_open),// 319

View File

@ -2252,7 +2252,7 @@ const SyscallTableEntry ML_(syscall_table)[] = {
LINX_(__NR_eventfd2, sys_eventfd2), // 328
LINXY(__NR_epoll_create1, sys_epoll_create1), // 329
// (__NR_dup3, sys_ni_syscall) // 330
LINXY(__NR_dup3, sys_dup3), // 330
LINXY(__NR_pipe2, sys_pipe2), // 331
LINXY(__NR_inotify_init1, sys_inotify_init1), // 332
LINXY(__NR_preadv, sys_preadv), // 333