]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Solaris: Add wrapper for fcntl(F_DUPFD_CLOEXEC)
authorIvo Raisr <ivosh@ivosh.net>
Tue, 25 Oct 2016 04:55:35 +0000 (04:55 +0000)
committerIvo Raisr <ivosh@ivosh.net>
Tue, 25 Oct 2016 04:55:35 +0000 (04:55 +0000)
n-i-bz

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16105

coregrind/m_syswrap/syswrap-solaris.c
include/vki/vki-solaris.h
memcheck/tests/solaris/scalar.c

index 64aeb827fc33c5526c8ca2661d7498a6d36cf5b6..a059c2167f1bcf2bbb0308039406cfe7d8112e07 100644 (file)
@@ -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;
 
index 002b2dfa0cbf3dc2b41fada5b26bf9070d25f028..4a74698e2c0d3d69bfd993affb785b9a9f69243e 100644 (file)
@@ -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
index d660ca2673043197a3673e62777888647626fca8..1d2a87085b324209742dfbbb3e7ef2f60a1174f7 100644 (file)
@@ -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. */