From: Ivo Raisr Date: Tue, 25 Oct 2016 04:55:35 +0000 (+0000) Subject: Solaris: Add wrapper for fcntl(F_DUPFD_CLOEXEC) X-Git-Tag: svn/VALGRIND_3_13_0~316 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a32762d5294295cf8a86b532fe0159ceb72c6605;p=thirdparty%2Fvalgrind.git Solaris: Add wrapper for fcntl(F_DUPFD_CLOEXEC) n-i-bz git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16105 --- diff --git a/coregrind/m_syswrap/syswrap-solaris.c b/coregrind/m_syswrap/syswrap-solaris.c index 64aeb827fc..a059c2167f 100644 --- a/coregrind/m_syswrap/syswrap-solaris.c +++ b/coregrind/m_syswrap/syswrap-solaris.c @@ -3938,6 +3938,7 @@ PRE(sys_fcntl) /* These ones use ARG3 as "arg". */ case VKI_F_DUPFD: + case VKI_F_DUPFD_CLOEXEC: case VKI_F_SETFD: case VKI_F_SETFL: case VKI_F_DUP2FD: @@ -4032,8 +4033,15 @@ POST(sys_fcntl) if (!ML_(fd_allowed)(RES, "fcntl(F_DUPFD)", tid, True)) { VG_(close)(RES); SET_STATUS_Failure(VKI_EMFILE); - } - else if (VG_(clo_track_fds)) + } else if (VG_(clo_track_fds)) + ML_(record_fd_open_named)(tid, RES); + break; + + case VKI_F_DUPFD_CLOEXEC: + if (!ML_(fd_allowed)(RES, "fcntl(F_DUPFD_CLOEXEC)", tid, True)) { + VG_(close)(RES); + SET_STATUS_Failure(VKI_EMFILE); + } else if (VG_(clo_track_fds)) ML_(record_fd_open_named)(tid, RES); break; @@ -4041,8 +4049,7 @@ POST(sys_fcntl) if (!ML_(fd_allowed)(RES, "fcntl(F_DUP2FD)", tid, True)) { VG_(close)(RES); SET_STATUS_Failure(VKI_EMFILE); - } - else if (VG_(clo_track_fds)) + } else if (VG_(clo_track_fds)) ML_(record_fd_open_named)(tid, RES); break; diff --git a/include/vki/vki-solaris.h b/include/vki/vki-solaris.h index 002b2dfa0c..4a74698e2c 100644 --- a/include/vki/vki-solaris.h +++ b/include/vki/vki-solaris.h @@ -500,6 +500,7 @@ typedef struct vki_kcf_door_arg_s { #define VKI_O_LARGEFILE O_LARGEFILE #define VKI_F_DUPFD F_DUPFD +#define VKI_F_DUPFD_CLOEXEC F_DUPFD_CLOEXEC #define VKI_F_GETFD F_GETFD #define VKI_F_SETFD F_SETFD #define VKI_F_GETFL F_GETFL diff --git a/memcheck/tests/solaris/scalar.c b/memcheck/tests/solaris/scalar.c index d660ca2673..1d2a87085b 100644 --- a/memcheck/tests/solaris/scalar.c +++ b/memcheck/tests/solaris/scalar.c @@ -307,6 +307,13 @@ static void sys_fcntl2(void) __attribute__((noinline)) static void sys_fcntl3(void) +{ + GO(SYS_fcntl, "(DUPFD_CLOEXEC) 3s 0m"); + SY(SYS_fcntl, x0 - 1, x0 + F_DUPFD_CLOEXEC, x0); FAILx(EBADF); +} + +__attribute__((noinline)) +static void sys_fcntl4(void) { GO(SYS_fcntl, "(GETLK) 3s 5m"); SY(SYS_fcntl, x0 - 1, x0 + F_GETLK, x0); FAILx(EBADF); @@ -1755,6 +1762,7 @@ int main(void) sys_fcntl(); sys_fcntl2(); sys_fcntl3(); + sys_fcntl4(); /* SYS_ulimit 63 */ /* XXX Missing wrapper. */