|
From: <sv...@va...> - 2016-10-25 04:55:45
|
Author: iraisr
Date: Tue Oct 25 05:55:35 2016
New Revision: 16105
Log:
Solaris: Add wrapper for fcntl(F_DUPFD_CLOEXEC)
n-i-bz
Modified:
trunk/coregrind/m_syswrap/syswrap-solaris.c
trunk/include/vki/vki-solaris.h
trunk/memcheck/tests/solaris/scalar.c
Modified: trunk/coregrind/m_syswrap/syswrap-solaris.c
==============================================================================
--- trunk/coregrind/m_syswrap/syswrap-solaris.c (original)
+++ trunk/coregrind/m_syswrap/syswrap-solaris.c Tue Oct 25 05:55:35 2016
@@ -3938,6 +3938,7 @@
/* 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 @@
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 @@
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;
Modified: trunk/include/vki/vki-solaris.h
==============================================================================
--- trunk/include/vki/vki-solaris.h (original)
+++ trunk/include/vki/vki-solaris.h Tue Oct 25 05:55:35 2016
@@ -500,6 +500,7 @@
#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
Modified: trunk/memcheck/tests/solaris/scalar.c
==============================================================================
--- trunk/memcheck/tests/solaris/scalar.c (original)
+++ trunk/memcheck/tests/solaris/scalar.c Tue Oct 25 05:55:35 2016
@@ -308,6 +308,13 @@
__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 @@
sys_fcntl();
sys_fcntl2();
sys_fcntl3();
+ sys_fcntl4();
/* SYS_ulimit 63 */
/* XXX Missing wrapper. */
|