Cleanup calls to CreateFile throughout.
* dcrt0.cc (__api_fatal): Correctly check for failing return from CreateFile. * assert.cc (__assert): Don't check return value from CreateFile for NULL. * fhandler_console.cc (set_console_state_for_spawn): Ditto. * fork.cc (fork_parent): Ditto.
This commit is contained in:
parent
776044d554
commit
580e99a151
|
@ -1,3 +1,11 @@
|
|||
2002-09-19 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
Cleanup calls to CreateFile throughout.
|
||||
* dcrt0.cc (__api_fatal): Correctly check for failing return from CreateFile.
|
||||
* assert.cc (__assert): Don't check return value from CreateFile for NULL.
|
||||
* fhandler_console.cc (set_console_state_for_spawn): Ditto.
|
||||
* fork.cc (fork_parent): Ditto.
|
||||
|
||||
2002-09-18 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* cygthread.cc (cygthread::initialized): Avoid copying on fork or some
|
||||
|
|
|
@ -28,9 +28,9 @@ __assert (const char *file, int line, const char *failedexpr)
|
|||
/* If we don't have a console in a Windows program, then bring up a
|
||||
message box for the assertion failure. */
|
||||
|
||||
h = CreateFileA ("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, &sec_none_nih,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (h == INVALID_HANDLE_VALUE || h == 0)
|
||||
h = CreateFile ("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, &sec_none_nih,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
|
|
|
@ -1057,10 +1057,10 @@ __api_fatal (const char *fmt, ...)
|
|||
a serious error. */
|
||||
if (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) != FILE_TYPE_CHAR)
|
||||
{
|
||||
HANDLE h = CreateFileA ("CONOUT$", GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE | FILE_SHARE_WRITE, &sec_none,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
if (h)
|
||||
HANDLE h = CreateFile ("CONOUT$", GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE | FILE_SHARE_WRITE,
|
||||
&sec_none, OPEN_EXISTING, 0, 0);
|
||||
if (h != INVALID_HANDLE_VALUE)
|
||||
(void) WriteFile (h, buf, len, &done, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ fhandler_base::open (path_conv *pc, int flags, mode_t mode)
|
|||
x = CreateFile (get_win32_name (), access, shared, &sa, creation_distribution,
|
||||
file_attributes, 0);
|
||||
|
||||
syscall_printf ("%p = CreateFileA (%s, %p, %p, %p, %p, %p, 0)",
|
||||
syscall_printf ("%p = CreateFile (%s, %p, %p, %p, %p, %p, 0)",
|
||||
x, get_win32_name (), access, shared, &sa,
|
||||
creation_distribution, file_attributes);
|
||||
|
||||
|
|
|
@ -135,11 +135,11 @@ tty_list::get_tty (int n)
|
|||
int __stdcall
|
||||
set_console_state_for_spawn ()
|
||||
{
|
||||
HANDLE h = CreateFileA ("CONIN$", GENERIC_READ, FILE_SHARE_WRITE,
|
||||
&sec_none_nih, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
HANDLE h = CreateFile ("CONIN$", GENERIC_READ, FILE_SHARE_WRITE,
|
||||
&sec_none_nih, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
|
||||
if (h == INVALID_HANDLE_VALUE || h == NULL)
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
return 0;
|
||||
|
||||
if (shared_console_info != NULL)
|
||||
|
@ -547,9 +547,9 @@ fhandler_console::open (path_conv *, int flags, mode_t)
|
|||
set_flags ((flags & ~O_TEXT) | O_BINARY);
|
||||
|
||||
/* Open the input handle as handle_ */
|
||||
h = CreateFileA ("CONIN$", GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, &sec_none,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
h = CreateFile ("CONIN$", GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, &sec_none,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
@ -559,9 +559,9 @@ fhandler_console::open (path_conv *, int flags, mode_t)
|
|||
set_io_handle (h);
|
||||
set_r_no_interrupt (1); // Handled explicitly in read code
|
||||
|
||||
h = CreateFileA ("CONOUT$", GENERIC_READ|GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, &sec_none,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
h = CreateFile ("CONOUT$", GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, &sec_none,
|
||||
OPEN_EXISTING, 0, 0);
|
||||
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
|
|
@ -362,12 +362,12 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
|
|||
|
||||
/* If we don't have a console, then don't create a console for the
|
||||
child either. */
|
||||
HANDLE console_handle = CreateFileA ("CONOUT$", GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE, &sec_none_nih,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
HANDLE console_handle = CreateFile ("CONOUT$", GENERIC_WRITE,
|
||||
FILE_SHARE_WRITE, &sec_none_nih,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
|
||||
if (console_handle != INVALID_HANDLE_VALUE && console_handle != 0)
|
||||
if (console_handle != INVALID_HANDLE_VALUE)
|
||||
CloseHandle (console_handle);
|
||||
else
|
||||
c_flags |= DETACHED_PROCESS;
|
||||
|
|
|
@ -91,12 +91,11 @@ NTReadEA (const char *file, const char *attrname, char *attrbuf, int len)
|
|||
int easize;
|
||||
|
||||
hFileSource = CreateFile (file, FILE_READ_EA,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
&sec_none_nih, // sa
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS,
|
||||
NULL
|
||||
);
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
&sec_none_nih, // sa
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS,
|
||||
NULL);
|
||||
|
||||
if (hFileSource == INVALID_HANDLE_VALUE)
|
||||
return 0;
|
||||
|
|
|
@ -60,13 +60,9 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, void *addr)
|
|||
TRUE, mapname);
|
||||
}
|
||||
if (!shared_h &&
|
||||
!(shared_h = CreateFileMappingA (INVALID_HANDLE_VALUE,
|
||||
&sec_all,
|
||||
PAGE_READWRITE,
|
||||
0,
|
||||
size,
|
||||
mapname)))
|
||||
api_fatal ("CreateFileMappingA, %E. Terminating.");
|
||||
!(shared_h = CreateFileMapping (INVALID_HANDLE_VALUE, &sec_all,
|
||||
PAGE_READWRITE, 0, size, mapname)))
|
||||
api_fatal ("CreateFileMapping, %E. Terminating.");
|
||||
}
|
||||
|
||||
shared = (shared_info *) MapViewOfFileEx (shared_h,
|
||||
|
|
|
@ -420,13 +420,10 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
|||
that it is NOT a script file */
|
||||
while (*ext == '\0')
|
||||
{
|
||||
HANDLE hnd = CreateFileA (real_path,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
&sec_none_nih,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
0);
|
||||
HANDLE hnd = CreateFile (real_path, GENERIC_READ,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
&sec_none_nih, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (hnd == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
__seterrno ();
|
||||
|
|
|
@ -648,15 +648,10 @@ _link (const char *a, const char *b)
|
|||
|
||||
BOOL bSuccess;
|
||||
|
||||
hFileSource = CreateFile (
|
||||
real_a,
|
||||
FILE_WRITE_ATTRIBUTES,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE /*| FILE_SHARE_DELETE*/,
|
||||
&sec_none_nih, // sa
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
hFileSource = CreateFile (real_a, FILE_WRITE_ATTRIBUTES,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE /*| FILE_SHARE_DELETE*/,
|
||||
&sec_none_nih, // sa
|
||||
OPEN_EXISTING, 0, NULL);
|
||||
|
||||
if (hFileSource == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
@ -2433,12 +2428,10 @@ logout (char *line)
|
|||
return 0;
|
||||
|
||||
ut_fd = CreateFile (win32_path.get_win32 (),
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
&sec_none_nih,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
&sec_none_nih, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (ut_fd != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
struct utmp *ut;
|
||||
|
|
|
@ -471,13 +471,11 @@ utimes (const char *path, struct timeval *tvp)
|
|||
the times of directories. */
|
||||
/* Note: It's not documented in MSDN that FILE_WRITE_ATTRIBUTES is
|
||||
sufficient to change the timestamps... */
|
||||
HANDLE h = CreateFileA (win32.get_win32 (),
|
||||
FILE_WRITE_ATTRIBUTES,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
&sec_none_nih,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
|
||||
0);
|
||||
HANDLE h = CreateFile (win32, FILE_WRITE_ATTRIBUTES,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
&sec_none_nih, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
|
||||
0);
|
||||
|
||||
if (h == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue