ports/devel/valgrind/files/missing_fcntls.patch
Bryan Drewery 8631badb87 - Update to 3.10.1
- Add pipe(2) syscall
- Add cpuset_getaffinity(2) syscall
- Support arguments for cpuset_setaffinity(2) syscall
- sendfile(2) syscall fixes
- getsockopt(2) syscall fixes
- Add missing fcntl(2) handlers [1]
- Add missing jail syscalls [2]
- Add missing kldload syscalls [3]
- Add missing accept4(2) syscall [4]

PR:		196451 [1]
Obtained from:	https://bitbucket.org/stass/valgrind-freebsd/issues/15/missing-fcntl-commands [1]
PR:		152899 [2]
Obtained from:	https://bitbucket.org/stass/valgrind-freebsd/pull-requests/10/implement-some-of-the-jails-syscalls/diff [2]

Obtained from:	https://bitbucket.org/stass/valgrind-freebsd/pull-requests/11/fix-issue-25-add-kldload-kldunload-kldfind/diff [3]
Obtained from:	https://bitbucket.org/stass/valgrind-freebsd/pull-requests/8/fix-issue-21-accept4-is-unimplemented-on/diff [4]
2016-04-19 20:03:17 +00:00

54 lines
2 KiB
Diff

diff --git a/coregrind/m_syswrap/syswrap-freebsd.c b/coregrind/m_syswrap/syswrap-freebsd.c
--- a/coregrind/m_syswrap/syswrap-freebsd.c
+++ b/coregrind/m_syswrap/syswrap-freebsd.c
@@ -3278,9 +3278,12 @@ 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_SETOWN:
+ case VKI_F_READAHEAD:
+ case VKI_F_RDAHEAD:
PRINT("sys_fcntl[ARG3=='arg'] ( %ld, %ld, %ld )", ARG1,ARG2,ARG3);
PRE_REG_READ3(long, "fcntl",
unsigned int, fd, unsigned int, cmd, unsigned long, arg);
@@ -3300,6 +3303,7 @@ PRE(sys_fcntl)
// This one uses ARG3 as "oldd" and ARG4 as "newd".
case VKI_F_DUP2FD:
+ case VKI_F_DUP2FD_CLOEXEC:
PRINT("sys_fcntl[ARG3=='oldd', ARG4=='newd'] ( %ld, %ld, %ld, %ld )",
ARG1,ARG2,ARG3,ARG4);
PRE_REG_READ4(long, "fcntl",
@@ -3339,6 +3343,15 @@ POST(sys_fcntl)
ML_(record_fd_open_named)(tid, RES);
}
}
+ else if (ARG2 == VKI_F_DUPFD_CLOEXEC) {
+ if (!ML_(fd_allowed)(RES, "fcntl(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);
+ }
+ }
}
PRE(sys_ioctl)
diff --git a/include/vki/vki-freebsd.h b/include/vki/vki-freebsd.h
--- a/include/vki/vki-freebsd.h
+++ b/include/vki/vki-freebsd.h
@@ -1554,6 +1554,10 @@ struct vki_dirent {
#define VKI_F_SETLK 12 /* set record locking information */
#define VKI_F_SETLKW 13 /* F_SETLK; wait if blocked */
#define VKI_F_SETLK_REMOTE 14 /* debugging support for remote locks */
+#define VKI_F_READAHEAD 15 /* read ahead */
+#define VKI_F_RDAHEAD 16 /* Darwin compatible read ahead */
+#define VKI_F_DUPFD_CLOEXEC 17 /* Like F_DUPFD, but FD_CLOEXEC is set */
+#define VKI_F_DUP2FD_CLOEXEC 18 /* Like F_DUP2FD, but FD_CLOEXEC is set */
/* for F_[GET|SET]FL */
#define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */