MSVCRT_fopen passes random pmode with _O_CREAT
Pavel Roskin
proski at gnu.org
Wed Oct 22 00:16:40 CDT 2003
Hello!
I have noticed what running lcclnk (from lcc-win32 compiler) under Wine
results in warnings like this:
fixme:msvcrt:MSVCRT__sopen : pmode 0x40340000 ignored
It happens when _open() is called from MSVCRT_fopen(). Indeed,
MSVCRT_fopen() always calls _open() with two arguments, even if it sets
_O_CREAT flag.
It should be OK to always use the 3-argument form. The last argument
could be _S_IREAD | _S_IWRITE. Files newly created by fopen() are
readable (all files are readable) and writable. In fact, our
MSVCRT__sopen() implementation ignores pmode.
While debugging MSVCRT__sopen() I also discovered that it complains about
_O_WRONLY in a trace message. The original core wrongly assumed that
_O_RDWR (2) covers _O_WRONLY (1), which is incorrect. I added _O_WRONLY
and elevated the message to ERR - it's a very serious event if some open()
flags are unknown.
ChangeLog:
* dlls/msvcrt/file.c:
Make MSVCRT__sopen() complain louder about unknown oflags, but not
about _O_WRONLY.
MSVCRT_fopen() should pass third argument to _open() because it
may set _O_CREAT.
--
Regards,
Pavel Roskin
-------------- next part --------------
--- dlls/msvcrt/file.c
+++ dlls/msvcrt/file.c
@@ -1005,8 +1005,8 @@ int MSVCRT__sopen( const char *path, int
}
if (oflags & ~(_O_BINARY|_O_TEXT|_O_APPEND|_O_TRUNC|_O_EXCL
- |_O_CREAT|_O_RDWR|_O_TEMPORARY|_O_NOINHERIT))
- TRACE(":unsupported oflags 0x%04x\n",oflags);
+ |_O_CREAT|_O_RDWR|_O_WRONLY|_O_TEMPORARY|_O_NOINHERIT))
+ ERR(":unsupported oflags 0x%04x\n",oflags);
sa.nLength = sizeof( SECURITY_ATTRIBUTES );
sa.lpSecurityDescriptor = NULL;
@@ -1885,7 +1885,7 @@ MSVCRT_FILE* MSVCRT_fopen(const char *pa
FIXME(":unknown flag %c not supported\n",mode[-1]);
}
- fd = _open(path, flags);
+ fd = _open(path, flags, _S_IREAD | _S_IWRITE);
if (fd < 0)
return NULL;
More information about the wine-patches
mailing list