diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2001-10-16 20:17:23 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2001-10-16 20:17:23 +0000 |
commit | 081be67e75e5bb721606cbaff9a4b77e9489dba3 (patch) | |
tree | fce8c1154fb0f1c61df0cb6715992956c2220d67 /winsup/cygwin/fhandler_raw.cc | |
parent | 2de2be2235c402d7b527de29e7b74185e8028cf3 (diff) | |
download | newlib-081be67e75e5bb721606cbaff9a4b77e9489dba3.zip newlib-081be67e75e5bb721606cbaff9a4b77e9489dba3.tar.gz newlib-081be67e75e5bb721606cbaff9a4b77e9489dba3.tar.bz2 |
* fhandler_raw.cc (fhandler_dev_raw::open): Eliminate compatibility
code since no Win32 device names are used anymore.
* fhandler_tape.cc (fhandler_dev_tape::tape_set_blocksize): Allow
0 as blocksize to indicate variable blocksize.
* path.cc (win32_device_name): Generate NT internal device names
using upper/lower case names for readability.
Generate \DosDevices\<letter>: device name for mount table
compatibility devices.
Diffstat (limited to 'winsup/cygwin/fhandler_raw.cc')
-rw-r--r-- | winsup/cygwin/fhandler_raw.cc | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index 3e73850..18d2a61 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -154,42 +154,32 @@ fhandler_dev_raw::open (path_conv *real_path, int flags, mode_t) flags &= ~(O_CREAT | O_TRUNC); flags |= O_BINARY; - if (get_device () == FH_FLOPPY && get_unit () >= 224) + DWORD access = GENERIC_READ | SYNCHRONIZE; + if (get_device () == FH_TAPE + || (flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY + || (flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDWR) + access |= GENERIC_WRITE; + + extern void str2buf2uni (UNICODE_STRING &, WCHAR *, const char *); + UNICODE_STRING dev; + WCHAR devname[MAX_PATH + 1]; + str2buf2uni (dev, devname, real_path->get_win32 ()); + OBJECT_ATTRIBUTES attr; + InitializeObjectAttributes (&attr, &dev, OBJ_CASE_INSENSITIVE, NULL, NULL); + + HANDLE h; + IO_STATUS_BLOCK io; + NTSTATUS status = NtOpenFile (&h, access, &attr, &io, wincap.shared (), + FILE_SYNCHRONOUS_IO_NONALERT); + if (!NT_SUCCESS (status)) { - /* Compatibility mode for old mount table device mapping. */ - if (!fhandler_base::open (real_path, flags)) - return 0; - } - else - { - DWORD access = GENERIC_READ | SYNCHRONIZE; - if (get_device () == FH_TAPE - || (flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY - || (flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDWR) - access |= GENERIC_WRITE; - - extern void str2buf2uni (UNICODE_STRING &, WCHAR *, const char *); - UNICODE_STRING dev; - WCHAR devname[MAX_PATH + 1]; - str2buf2uni (dev, devname, real_path->get_win32 ()); - OBJECT_ATTRIBUTES attr; - InitializeObjectAttributes(&attr, &dev, OBJ_CASE_INSENSITIVE, NULL, NULL); - - HANDLE h; - IO_STATUS_BLOCK io; - NTSTATUS status = NtOpenFile (&h, access, &attr, &io, wincap.shared (), - FILE_SYNCHRONOUS_IO_NONALERT); - if (!NT_SUCCESS (status)) - { - set_errno (RtlNtStatusToDosError (status)); - debug_printf ("NtOpenFile: NTSTATUS: %d, Win32: %E", status); - return 0; - } - - set_io_handle (h); - set_flags (flags); + set_errno (RtlNtStatusToDosError (status)); + debug_printf ("NtOpenFile: NTSTATUS: %d, Win32: %E", status); + return 0; } + set_io_handle (h); + set_flags (flags); set_r_binary (O_BINARY); set_w_binary (O_BINARY); |