* 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.
This commit is contained in:
parent
e31a79b1d6
commit
19afaa1a50
|
@ -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>
|
2007-08-12 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* fhandler.cc (fhandler_base::open): Remove HIDDEN_DOT_FILES code.
|
* fhandler.cc (fhandler_base::open): Remove HIDDEN_DOT_FILES code.
|
||||||
|
|
|
@ -104,7 +104,7 @@ static const device dev_storage[] =
|
||||||
{"/dev/fifo", BRACK(FH_FIFO), "\\dev\\fifo"},
|
{"/dev/fifo", BRACK(FH_FIFO), "\\dev\\fifo"},
|
||||||
{"/dev/full", BRACK(FH_FULL), "\\dev\\full"},
|
{"/dev/full", BRACK(FH_FULL), "\\dev\\full"},
|
||||||
{"/dev/kmem", BRACK(FH_KMEM), "\\dev\\mem"},
|
{"/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/mem", BRACK(FH_MEM), "\\dev\\mem"},
|
||||||
{"/dev/nst0", BRACK(FHDEV(DEV_TAPE_MAJOR, 128)), "\\Device\\Tape0"},
|
{"/dev/nst0", BRACK(FHDEV(DEV_TAPE_MAJOR, 128)), "\\Device\\Tape0"},
|
||||||
{"/dev/nst1", BRACK(FHDEV(DEV_TAPE_MAJOR, 129)), "\\Device\\Tape1"},
|
{"/dev/nst1", BRACK(FHDEV(DEV_TAPE_MAJOR, 129)), "\\Device\\Tape1"},
|
||||||
|
|
|
@ -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/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/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/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"
|
"/dev", BRACK(FH_DEV), "/dev"
|
||||||
%other {return NULL;}
|
%other {return NULL;}
|
||||||
%%
|
%%
|
||||||
|
|
|
@ -45,7 +45,7 @@ inline fhandler_base&
|
||||||
fhandler_base::operator =(fhandler_base& x)
|
fhandler_base::operator =(fhandler_base& x)
|
||||||
{
|
{
|
||||||
memcpy (this, &x, sizeof *this);
|
memcpy (this, &x, sizeof *this);
|
||||||
pc.set_normalized_path (x.pc.normalized_path, false);
|
pc = x.pc;
|
||||||
rabuf = NULL;
|
rabuf = NULL;
|
||||||
ralen = 0;
|
ralen = 0;
|
||||||
raixget = 0;
|
raixget = 0;
|
||||||
|
@ -154,8 +154,7 @@ fhandler_base::get_readahead_into_buffer (char *buf, size_t buflen)
|
||||||
void
|
void
|
||||||
fhandler_base::set_name (path_conv &in_pc)
|
fhandler_base::set_name (path_conv &in_pc)
|
||||||
{
|
{
|
||||||
memcpy (&pc, &in_pc, in_pc.size ());
|
pc = in_pc;
|
||||||
pc.set_normalized_path (in_pc.normalized_path, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *fhandler_base::get_proc_fd_name (char *buf)
|
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;
|
IO_STATUS_BLOCK io;
|
||||||
NTSTATUS status;
|
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);
|
pc.get_object_attr (attr, sa);
|
||||||
|
|
||||||
|
@ -577,12 +576,12 @@ fhandler_base::open (int flags, mode_t mode)
|
||||||
set_open_status ();
|
set_open_status ();
|
||||||
done:
|
done:
|
||||||
debug_printf ("%x = NtCreateFile "
|
debug_printf ("%x = NtCreateFile "
|
||||||
"(%p, %x, %s, io, NULL, %x, %x, %x, %x, NULL, 0)",
|
"(%p, %x, %S, io, NULL, %x, %x, %x, %x, NULL, 0)",
|
||||||
status, x, access, get_win32_name (), file_attributes, shared,
|
status, x, access, pc.get_nt_native_path (), file_attributes,
|
||||||
create_disposition, create_options);
|
shared, create_disposition, create_options);
|
||||||
|
|
||||||
syscall_printf ("%d = fhandler_base::open (%s, %p)", res, get_win32_name (),
|
syscall_printf ("%d = fhandler_base::open (%s, %p)",
|
||||||
flags);
|
res, pc.get_nt_native_path (), flags);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,39 +53,45 @@ int
|
||||||
fhandler_mailslot::open (int flags, mode_t mode)
|
fhandler_mailslot::open (int flags, mode_t mode)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
NTSTATUS status;
|
||||||
|
IO_STATUS_BLOCK io;
|
||||||
|
OBJECT_ATTRIBUTES attr;
|
||||||
HANDLE x;
|
HANDLE x;
|
||||||
|
LARGE_INTEGER timeout;
|
||||||
|
|
||||||
switch (flags & O_ACCMODE)
|
switch (flags & O_ACCMODE)
|
||||||
{
|
{
|
||||||
case O_RDONLY: /* Server */
|
case O_RDONLY: /* Server */
|
||||||
x = CreateMailslot (get_win32_name (),
|
timeout.QuadPart = (flags & O_NONBLOCK) ? 0LL : 0x8000000000000000LL;
|
||||||
0, /* Any message size */
|
status = NtCreateMailslotFile (&x, GENERIC_READ | SYNCHRONIZE,
|
||||||
(flags & O_NONBLOCK) ? 0 : MAILSLOT_WAIT_FOREVER,
|
pc.get_object_attr (attr, sec_none),
|
||||||
&sec_none);
|
&io, FILE_SYNCHRONOUS_IO_NONALERT,
|
||||||
if (x == INVALID_HANDLE_VALUE)
|
0, 0, &timeout);
|
||||||
|
if (!NT_SUCCESS (status))
|
||||||
{
|
{
|
||||||
/* FIXME: It's not possible to open the read side of an existing
|
/* FIXME: It's not possible to open the read side of an existing
|
||||||
mailslot using CreateFile. You'll get a handle, but using it
|
mailslot again. You'll get a handle, but using it in ReadFile
|
||||||
in ReadFile returns ERROR_INVALID_PARAMETER. On the other
|
returns ERROR_INVALID_PARAMETER. On the other hand,
|
||||||
hand, CreateMailslot returns with ERROR_ALREADY_EXISTS if the
|
NtCreateMailslotFile returns with STATUS_OBJECT_NAME_EXISTS if
|
||||||
mailslot has been created already.
|
the mailslot has been created already.
|
||||||
So this is an exclusive open for now. *Duplicating* read side
|
So this is an exclusive open for now. *Duplicating* read side
|
||||||
handles works, though, so it might be an option to duplicate
|
handles works, though, so it might be an option to duplicate
|
||||||
the handle from the first process to the current process for
|
the handle from the first process to the current process for
|
||||||
opening the mailslot. */
|
opening the mailslot. */
|
||||||
#if 0
|
#if 0
|
||||||
if (GetLastError () != ERROR_ALREADY_EXISTS)
|
if (status != STATUS_OBJECT_NAME_COLLISION)
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno_from_nt_status (status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
x = CreateFile (get_win32_name (), GENERIC_READ,
|
status = NtOpenFile (&x, GENERIC_READ | SYNCHRONIZE,
|
||||||
|
pc.get_object_attr (attr, sec_none), &io,
|
||||||
FILE_SHARE_VALID_FLAGS,
|
FILE_SHARE_VALID_FLAGS,
|
||||||
&sec_none, OPEN_EXISTING, 0, 0);
|
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||||
#endif
|
#endif
|
||||||
if (x == INVALID_HANDLE_VALUE)
|
if (!NT_SUCCESS (status))
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno_from_nt_status (status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,11 +109,13 @@ fhandler_mailslot::open (int flags, mode_t mode)
|
||||||
set_errno (EPERM); /* As on Linux. */
|
set_errno (EPERM); /* As on Linux. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
x = CreateFile (get_win32_name (), GENERIC_WRITE, FILE_SHARE_VALID_FLAGS,
|
status = NtOpenFile (&x, GENERIC_WRITE | SYNCHRONIZE,
|
||||||
&sec_none, OPEN_EXISTING, 0, 0);
|
pc.get_object_attr (attr, sec_none), &io,
|
||||||
if (x == INVALID_HANDLE_VALUE)
|
FILE_SHARE_VALID_FLAGS,
|
||||||
|
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||||
|
if (!NT_SUCCESS (status))
|
||||||
{
|
{
|
||||||
__seterrno ();
|
__seterrno_from_nt_status (status);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
set_io_handle (x);
|
set_io_handle (x);
|
||||||
|
@ -140,15 +148,22 @@ int
|
||||||
fhandler_mailslot::ioctl (unsigned int cmd, void *buf)
|
fhandler_mailslot::ioctl (unsigned int cmd, void *buf)
|
||||||
{
|
{
|
||||||
int res = -1;
|
int res = -1;
|
||||||
|
NTSTATUS status;
|
||||||
|
IO_STATUS_BLOCK io;
|
||||||
|
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
case FIONBIO:
|
case FIONBIO:
|
||||||
{
|
{
|
||||||
DWORD timeout = buf ? 0 : MAILSLOT_WAIT_FOREVER;
|
FILE_MAILSLOT_SET_INFORMATION fmsi;
|
||||||
if (!SetMailslotInfo (get_handle (), timeout))
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -745,6 +745,11 @@ typedef struct _FILE_FULL_EA_INFORMATION
|
||||||
CHAR EaName[1];
|
CHAR EaName[1];
|
||||||
} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
|
} 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);
|
typedef VOID NTAPI (*PIO_APC_ROUTINE)(PVOID, PIO_STATUS_BLOCK, ULONG);
|
||||||
|
|
||||||
/* Function declarations for ntdll.dll. These don't appear in any
|
/* 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,
|
NTSTATUS NTAPI NtCreateFile (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
|
||||||
PIO_STATUS_BLOCK, PLARGE_INTEGER, ULONG, ULONG,
|
PIO_STATUS_BLOCK, PLARGE_INTEGER, ULONG, ULONG,
|
||||||
ULONG, ULONG, PVOID, 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,
|
NTSTATUS NTAPI NtCreateSection (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
|
||||||
PLARGE_INTEGER, ULONG, ULONG, HANDLE);
|
PLARGE_INTEGER, ULONG, ULONG, HANDLE);
|
||||||
NTSTATUS NTAPI NtCreateToken (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
|
NTSTATUS NTAPI NtCreateToken (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
|
||||||
|
|
|
@ -536,7 +536,6 @@ path_conv::set_normalized_path (const char *path_copy, bool strip_tail)
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy (normalized_path, path_copy, n);
|
memcpy (normalized_path, path_copy, n);
|
||||||
wide_path = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PUNICODE_STRING
|
PUNICODE_STRING
|
||||||
|
@ -1178,15 +1177,6 @@ out:
|
||||||
#endif
|
#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 ()
|
path_conv::~path_conv ()
|
||||||
{
|
{
|
||||||
if (!normalized_path_size && normalized_path)
|
if (!normalized_path_size && normalized_path)
|
||||||
|
|
|
@ -245,7 +245,6 @@ class path_conv
|
||||||
{path[0] = '\0';}
|
{path[0] = '\0';}
|
||||||
|
|
||||||
~path_conv ();
|
~path_conv ();
|
||||||
void set_name (const char *win32, const char *posix);
|
|
||||||
inline char *get_win32 () { return path; }
|
inline char *get_win32 () { return path; }
|
||||||
PUNICODE_STRING get_nt_native_path ();
|
PUNICODE_STRING get_nt_native_path ();
|
||||||
POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr,
|
POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr,
|
||||||
|
@ -256,6 +255,13 @@ class path_conv
|
||||||
operator DWORD &() {return fileattr;}
|
operator DWORD &() {return fileattr;}
|
||||||
operator int () {return fileattr; }
|
operator int () {return fileattr; }
|
||||||
char operator [](int i) const {return path[i];}
|
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;}
|
DWORD get_devn () const {return dev.devn;}
|
||||||
short get_unitn () const {return dev.minor;}
|
short get_unitn () const {return dev.minor;}
|
||||||
DWORD file_attributes () const {return fileattr;}
|
DWORD file_attributes () const {return fileattr;}
|
||||||
|
|
Loading…
Reference in New Issue