Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2007-08-13 19:08:25 +0400
committerCorinna Vinschen <corinna@vinschen.de>2007-08-13 19:08:25 +0400
commit19afaa1a50ad936d91cf898eb7bb7e24af8c573f (patch)
tree0a17146cd1be2f625f6ac68f802b3440339cba6f
parente31a79b1d67d76260a1024957a89ad1320575b97 (diff)
* devices.in (dev_storage): Use native NT device name for kmsg mailslot.
* devices.cc: Regenerate. * fhandler.cc (fhandler_base::operator =): Use path_conv assignment operator. (fhandler_base::set_name): Ditto. (fhandler_base::open): Use NT native path in debug output. * fhandler_mailslot.cc: Convert to NT native function calls. * ntdll.h (struct _FILE_MAILSLOT_SET_INFORMATION): Define. (NtCreateMailslotFile): Declare. * path.cc (path_conv::set_normalized_path): Don't set wide_path to NULL. (path_conv::set_name): Remove unused function. * path.h (path_conv::set_name): Drop declaration. (path_conv::operator =): Define.
-rw-r--r--winsup/cygwin/ChangeLog16
-rw-r--r--winsup/cygwin/devices.cc2
-rw-r--r--winsup/cygwin/devices.in2
-rw-r--r--winsup/cygwin/fhandler.cc17
-rw-r--r--winsup/cygwin/fhandler_mailslot.cc61
-rw-r--r--winsup/cygwin/ntdll.h8
-rw-r--r--winsup/cygwin/path.cc10
-rw-r--r--winsup/cygwin/path.h8
8 files changed, 79 insertions, 45 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index dc82967f7..ac9b4e0ba 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,19 @@
+2007-08-13 Corinna Vinschen <corinna@vinschen.de>
+
+ * devices.in (dev_storage): Use native NT device name for kmsg mailslot.
+ * devices.cc: Regenerate.
+ * fhandler.cc (fhandler_base::operator =): Use path_conv assignment
+ operator.
+ (fhandler_base::set_name): Ditto.
+ (fhandler_base::open): Use NT native path in debug output.
+ * fhandler_mailslot.cc: Convert to NT native function calls.
+ * ntdll.h (struct _FILE_MAILSLOT_SET_INFORMATION): Define.
+ (NtCreateMailslotFile): Declare.
+ * path.cc (path_conv::set_normalized_path): Don't set wide_path to NULL.
+ (path_conv::set_name): Remove unused function.
+ * path.h (path_conv::set_name): Drop declaration.
+ (path_conv::operator =): Define.
+
2007-08-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc (fhandler_base::open): Remove HIDDEN_DOT_FILES code.
diff --git a/winsup/cygwin/devices.cc b/winsup/cygwin/devices.cc
index 123b884cc..1915715c6 100644
--- a/winsup/cygwin/devices.cc
+++ b/winsup/cygwin/devices.cc
@@ -104,7 +104,7 @@ static const device dev_storage[] =
{"/dev/fifo", BRACK(FH_FIFO), "\\dev\\fifo"},
{"/dev/full", BRACK(FH_FULL), "\\dev\\full"},
{"/dev/kmem", BRACK(FH_KMEM), "\\dev\\mem"},
- {"/dev/kmsg", BRACK(FH_KMSG), "\\\\.\\mailslot\\cygwin\\dev\\kmsg"},
+ {"/dev/kmsg", BRACK(FH_KMSG), "\\Device\\MailSlot\\cygwin\\dev\\kmsg"},
{"/dev/mem", BRACK(FH_MEM), "\\dev\\mem"},
{"/dev/nst0", BRACK(FHDEV(DEV_TAPE_MAJOR, 128)), "\\Device\\Tape0"},
{"/dev/nst1", BRACK(FHDEV(DEV_TAPE_MAJOR, 129)), "\\Device\\Tape1"},
diff --git a/winsup/cygwin/devices.in b/winsup/cygwin/devices.in
index cbafcf259..e72d82138 100644
--- a/winsup/cygwin/devices.in
+++ b/winsup/cygwin/devices.in
@@ -97,7 +97,7 @@ const device dev_bad_storage =
"/dev/sdb%{a-z}s%(1-15)d", BRACK(FH_SDB{uc $1} | {$2}), "\\Device\\Harddisk{52 + ord($1) - ord('a')}\\Partition{$2 % 16}"
"/dev/sdc%{a-z}s%(1-15)d", BRACK(FH_SDC{uc $1} | {$2}), "\\Device\\Harddisk{78 + ord($1) - ord('a')}\\Partition{$2 % 16}"
"/dev/sdd%{a-x}s%(1-15)d", BRACK(FH_SDD{uc $1} | {$2}), "\\Device\\Harddisk{104 + ord($1) - ord('a')}\\Partition{$2 % 16}"
-"/dev/kmsg", BRACK(FH_KMSG), "\\\\.\\mailslot\\cygwin\\dev\\kmsg"
+"/dev/kmsg", BRACK(FH_KMSG), "\\Device\\MailSlot\\cygwin\\dev\\kmsg"
"/dev", BRACK(FH_DEV), "/dev"
%other {return NULL;}
%%
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 59ee6a496..8b180b1c1 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -45,7 +45,7 @@ inline fhandler_base&
fhandler_base::operator =(fhandler_base& x)
{
memcpy (this, &x, sizeof *this);
- pc.set_normalized_path (x.pc.normalized_path, false);
+ pc = x.pc;
rabuf = NULL;
ralen = 0;
raixget = 0;
@@ -154,8 +154,7 @@ fhandler_base::get_readahead_into_buffer (char *buf, size_t buflen)
void
fhandler_base::set_name (path_conv &in_pc)
{
- memcpy (&pc, &in_pc, in_pc.size ());
- pc.set_normalized_path (in_pc.normalized_path, false);
+ pc = in_pc;
}
char *fhandler_base::get_proc_fd_name (char *buf)
@@ -469,7 +468,7 @@ fhandler_base::open (int flags, mode_t mode)
IO_STATUS_BLOCK io;
NTSTATUS status;
- syscall_printf ("(%s, %p)", get_win32_name (), flags);
+ syscall_printf ("(%S, %p)", pc.get_nt_native_path (), flags);
pc.get_object_attr (attr, sa);
@@ -577,12 +576,12 @@ fhandler_base::open (int flags, mode_t mode)
set_open_status ();
done:
debug_printf ("%x = NtCreateFile "
- "(%p, %x, %s, io, NULL, %x, %x, %x, %x, NULL, 0)",
- status, x, access, get_win32_name (), file_attributes, shared,
- create_disposition, create_options);
+ "(%p, %x, %S, io, NULL, %x, %x, %x, %x, NULL, 0)",
+ status, x, access, pc.get_nt_native_path (), file_attributes,
+ shared, create_disposition, create_options);
- syscall_printf ("%d = fhandler_base::open (%s, %p)", res, get_win32_name (),
- flags);
+ syscall_printf ("%d = fhandler_base::open (%s, %p)",
+ res, pc.get_nt_native_path (), flags);
return res;
}
diff --git a/winsup/cygwin/fhandler_mailslot.cc b/winsup/cygwin/fhandler_mailslot.cc
index 543c7f806..d829deff2 100644
--- a/winsup/cygwin/fhandler_mailslot.cc
+++ b/winsup/cygwin/fhandler_mailslot.cc
@@ -53,39 +53,45 @@ int
fhandler_mailslot::open (int flags, mode_t mode)
{
int res = 0;
+ NTSTATUS status;
+ IO_STATUS_BLOCK io;
+ OBJECT_ATTRIBUTES attr;
HANDLE x;
+ LARGE_INTEGER timeout;
switch (flags & O_ACCMODE)
{
case O_RDONLY: /* Server */
- x = CreateMailslot (get_win32_name (),
- 0, /* Any message size */
- (flags & O_NONBLOCK) ? 0 : MAILSLOT_WAIT_FOREVER,
- &sec_none);
- if (x == INVALID_HANDLE_VALUE)
+ timeout.QuadPart = (flags & O_NONBLOCK) ? 0LL : 0x8000000000000000LL;
+ status = NtCreateMailslotFile (&x, GENERIC_READ | SYNCHRONIZE,
+ pc.get_object_attr (attr, sec_none),
+ &io, FILE_SYNCHRONOUS_IO_NONALERT,
+ 0, 0, &timeout);
+ if (!NT_SUCCESS (status))
{
/* FIXME: It's not possible to open the read side of an existing
- mailslot using CreateFile. You'll get a handle, but using it
- in ReadFile returns ERROR_INVALID_PARAMETER. On the other
- hand, CreateMailslot returns with ERROR_ALREADY_EXISTS if the
- mailslot has been created already.
+ mailslot again. You'll get a handle, but using it in ReadFile
+ returns ERROR_INVALID_PARAMETER. On the other hand,
+ NtCreateMailslotFile returns with STATUS_OBJECT_NAME_EXISTS if
+ the mailslot has been created already.
So this is an exclusive open for now. *Duplicating* read side
handles works, though, so it might be an option to duplicate
the handle from the first process to the current process for
opening the mailslot. */
#if 0
- if (GetLastError () != ERROR_ALREADY_EXISTS)
+ if (status != STATUS_OBJECT_NAME_COLLISION)
{
- __seterrno ();
+ __seterrno_from_nt_status (status);
break;
}
- x = CreateFile (get_win32_name (), GENERIC_READ,
- FILE_SHARE_VALID_FLAGS,
- &sec_none, OPEN_EXISTING, 0, 0);
+ status = NtOpenFile (&x, GENERIC_READ | SYNCHRONIZE,
+ pc.get_object_attr (attr, sec_none), &io,
+ FILE_SHARE_VALID_FLAGS,
+ FILE_SYNCHRONOUS_IO_NONALERT);
#endif
- if (x == INVALID_HANDLE_VALUE)
+ if (!NT_SUCCESS (status))
{
- __seterrno ();
+ __seterrno_from_nt_status (status);
break;
}
}
@@ -103,11 +109,13 @@ fhandler_mailslot::open (int flags, mode_t mode)
set_errno (EPERM); /* As on Linux. */
break;
}
- x = CreateFile (get_win32_name (), GENERIC_WRITE, FILE_SHARE_VALID_FLAGS,
- &sec_none, OPEN_EXISTING, 0, 0);
- if (x == INVALID_HANDLE_VALUE)
+ status = NtOpenFile (&x, GENERIC_WRITE | SYNCHRONIZE,
+ pc.get_object_attr (attr, sec_none), &io,
+ FILE_SHARE_VALID_FLAGS,
+ FILE_SYNCHRONOUS_IO_NONALERT);
+ if (!NT_SUCCESS (status))
{
- __seterrno ();
+ __seterrno_from_nt_status (status);
break;
}
set_io_handle (x);
@@ -140,15 +148,22 @@ int
fhandler_mailslot::ioctl (unsigned int cmd, void *buf)
{
int res = -1;
+ NTSTATUS status;
+ IO_STATUS_BLOCK io;
switch (cmd)
{
case FIONBIO:
{
- DWORD timeout = buf ? 0 : MAILSLOT_WAIT_FOREVER;
- if (!SetMailslotInfo (get_handle (), timeout))
+ FILE_MAILSLOT_SET_INFORMATION fmsi;
+ fmsi.ReadTimeout.QuadPart = buf ? 0LL : 0x8000000000000000LL;
+ status = NtSetInformationFile (get_handle (), &io, &fmsi, sizeof fmsi,
+ FileMailslotSetInformation);
+ if (!NT_SUCCESS (status))
{
- debug_printf ("SetMailslotInfo (%u): %E", timeout);
+ debug_printf ("NtSetInformationFile (%X): %08x",
+ fmsi.ReadTimeout.QuadPart, status);
+ __seterrno_from_nt_status (status);
break;
}
}
diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h
index 3c94010ca..ea4b3a698 100644
--- a/winsup/cygwin/ntdll.h
+++ b/winsup/cygwin/ntdll.h
@@ -745,6 +745,11 @@ typedef struct _FILE_FULL_EA_INFORMATION
CHAR EaName[1];
} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
+typedef struct _FILE_MAILSLOT_SET_INFORMATION
+{
+ LARGE_INTEGER ReadTimeout;
+} FILE_MAILSLOT_SET_INFORMATION, *PFILE_MAILSLOT_SET_INFORMATION;
+
typedef VOID NTAPI (*PIO_APC_ROUTINE)(PVOID, PIO_STATUS_BLOCK, ULONG);
/* Function declarations for ntdll.dll. These don't appear in any
@@ -757,6 +762,9 @@ extern "C"
NTSTATUS NTAPI NtCreateFile (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
PIO_STATUS_BLOCK, PLARGE_INTEGER, ULONG, ULONG,
ULONG, ULONG, PVOID, ULONG);
+ NTSTATUS NTAPI NtCreateMailslotFile(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
+ PIO_STATUS_BLOCK, ULONG, ULONG, ULONG,
+ PLARGE_INTEGER);
NTSTATUS NTAPI NtCreateSection (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
PLARGE_INTEGER, ULONG, ULONG, HANDLE);
NTSTATUS NTAPI NtCreateToken (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 6620b02a4..4efc4571c 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -536,7 +536,6 @@ path_conv::set_normalized_path (const char *path_copy, bool strip_tail)
}
memcpy (normalized_path, path_copy, n);
- wide_path = NULL;
}
PUNICODE_STRING
@@ -1178,15 +1177,6 @@ out:
#endif
}
-void
-path_conv::set_name (const char *win32, const char *posix)
-{
- if (!normalized_path_size && normalized_path)
- cfree (normalized_path);
- strcpy (path, win32);
- set_normalized_path (posix, false);
-}
-
path_conv::~path_conv ()
{
if (!normalized_path_size && normalized_path)
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index e911f4156..194a5648d 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -245,7 +245,6 @@ class path_conv
{path[0] = '\0';}
~path_conv ();
- void set_name (const char *win32, const char *posix);
inline char *get_win32 () { return path; }
PUNICODE_STRING get_nt_native_path ();
POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr,
@@ -256,6 +255,13 @@ class path_conv
operator DWORD &() {return fileattr;}
operator int () {return fileattr; }
char operator [](int i) const {return path[i];}
+ path_conv &operator =(path_conv &pc)
+ {
+ memcpy (this, &pc, pc.size ());
+ set_normalized_path (pc.normalized_path, false);
+ wide_path = NULL;
+ return *this;
+ }
DWORD get_devn () const {return dev.devn;}
short get_unitn () const {return dev.minor;}
DWORD file_attributes () const {return fileattr;}