]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Handle the dup3 system call. Closes #215448.
authorTom Hughes <tom@compton.nu>
Mon, 23 Nov 2009 08:19:20 +0000 (08:19 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 23 Nov 2009 08:19:20 +0000 (08:19 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10945

coregrind/m_syswrap/priv_syswrap-linux.h
coregrind/m_syswrap/syswrap-amd64-linux.c
coregrind/m_syswrap/syswrap-linux.c
coregrind/m_syswrap/syswrap-ppc32-linux.c
coregrind/m_syswrap/syswrap-ppc64-linux.c
coregrind/m_syswrap/syswrap-x86-linux.c

index cc3e98c6cbaafbf32ebbd24e826807404e4ec631..f2575037d40886f3668374999388194592d383df 100644 (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);
index 293dc2560de081462a4da3edb4daf1333ff06a16..eded6d1387a5d3ed3446270966292438254193c6 100644 (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
 
index b4a4563308b7396b1c35fd62b331c88052dc8141..fa519d907feddce73e9c54eb38c5d2a122f3592c 100644 (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);
index f49131fc28098a15162cb2840072bfc66d0b69a9..306db66c71530cb3f41430bf18167b5e2c56bf0f 100644 (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
index 6fb13b020e3ef490f8e9745e8d2b6542ac911938..98ce4172c746b6e3a01c320e26e53d1da11f16c6 100644 (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
index 74401e00bc47b7a72ba0e45650fd736cc33158b1..0472e3f47344c5f3f4032ed70977b50ea617035d 100644 (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