|
From: <sv...@va...> - 2009-05-24 22:32:46
|
Author: njn
Date: 2009-05-24 23:32:33 +0100 (Sun, 24 May 2009)
New Revision: 10131
Log:
DARWIN sync: sys_open wrapper.
Modified:
trunk/coregrind/m_syswrap/syswrap-generic.c
Modified: trunk/coregrind/m_syswrap/syswrap-generic.c
===================================================================
--- trunk/coregrind/m_syswrap/syswrap-generic.c 2009-05-24 18:10:41 UTC (rev 10130)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c 2009-05-24 22:32:33 UTC (rev 10131)
@@ -3393,9 +3393,6 @@
PRE(sys_open)
{
- HChar name[30];
- SysRes sres;
-
if (ARG2 & VKI_O_CREAT) {
// 3-arg version
PRINT("sys_open ( %#lx(%s), %ld, %ld )",ARG1,(char*)ARG1,ARG2,ARG3);
@@ -3413,19 +3410,25 @@
/proc/<pid>/cmdline, and just give it a copy of the fd for the
fake file we cooked up at startup (in m_main). Also, seek the
cloned fd back to the start. */
+ {
+ HChar name[30];
+ Char* arg1s = (Char*) ARG1;
+ SysRes sres;
- VG_(sprintf)(name, "/proc/%d/cmdline", VG_(getpid)());
- if (ML_(safe_to_deref)( (void*)ARG1, 1 )
- && (VG_(strcmp)((Char *)ARG1, name) == 0
- || VG_(strcmp)((Char *)ARG1, "/proc/self/cmdline") == 0)) {
- sres = VG_(dup)( VG_(cl_cmdline_fd) );
- SET_STATUS_from_SysRes( sres );
- if (!sr_isError(sres)) {
- OffT off = VG_(lseek)( sr_Res(sres), 0, VKI_SEEK_SET );
- if (off < 0)
- SET_STATUS_Failure( VKI_EMFILE );
+ VG_(sprintf)(name, "/proc/%d/cmdline", VG_(getpid)());
+ if (ML_(safe_to_deref)( arg1s, 1 ) &&
+ (VG_STREQ(arg1s, name) || VG_STREQ(arg1s, "/proc/self/cmdline"))
+ )
+ {
+ sres = VG_(dup)( VG_(cl_cmdline_fd) );
+ SET_STATUS_from_SysRes( sres );
+ if (!sr_isError(sres)) {
+ OffT off = VG_(lseek)( sr_Res(sres), 0, VKI_SEEK_SET );
+ if (off < 0)
+ SET_STATUS_Failure( VKI_EMFILE );
+ }
+ return;
}
- return;
}
/* Otherwise handle normally */
|