From 1b557b4333fab9dae7bbe9c28798731bc6558dec Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Tue, 20 Apr 2004 11:01:22 +0000 Subject: [PATCH] * fhandler.cc (fhandler_base::open): Remove special DEV_FLOPPY_MAJOR treatment. * fhandler_raw.cc (fhandler_dev_raw::open): Simplify write-only case. * fhandler_tape.cc (fhandler_dev_tape::raw_write): Add accidentally dropped condition. --- winsup/cygwin/ChangeLog | 8 ++++++++ winsup/cygwin/fhandler.cc | 6 +----- winsup/cygwin/fhandler_raw.cc | 7 +++---- winsup/cygwin/fhandler_tape.cc | 1 + 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 13748329a..37220ff56 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2004-04-20 Corinna Vinschen + + * fhandler.cc (fhandler_base::open): Remove special DEV_FLOPPY_MAJOR + treatment. + * fhandler_raw.cc (fhandler_dev_raw::open): Simplify write-only case. + * fhandler_tape.cc (fhandler_dev_tape::raw_write): Add accidentally + dropped condition. + 2004-04-20 Corinna Vinschen * fhandler.cc (fhandler_base::open): Add FILE_READ_ATTRIBUTES when diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index e02d4e507..9aa3c0d4a 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -607,11 +607,7 @@ fhandler_base::open (int flags, mode_t mode) access = GENERIC_WRITE | FILE_READ_ATTRIBUTES; else access = GENERIC_READ | GENERIC_WRITE; - /* Allow reliable lseek on disk devices. */ - if (get_major () == DEV_FLOPPY_MAJOR) - access |= GENERIC_READ; - else if (get_major () != DEV_SERIAL_MAJOR - && get_major () != DEV_TAPE_MAJOR) + if (get_major () != DEV_SERIAL_MAJOR && get_major () != DEV_TAPE_MAJOR) { create_options |= FILE_SYNCHRONOUS_IO_NONALERT; access |= SYNCHRONIZE; diff --git a/winsup/cygwin/fhandler_raw.cc b/winsup/cygwin/fhandler_raw.cc index 4fafe20cf..84f657f76 100644 --- a/winsup/cygwin/fhandler_raw.cc +++ b/winsup/cygwin/fhandler_raw.cc @@ -144,10 +144,9 @@ fhandler_dev_raw::open (int flags, mode_t) flags &= ~(O_CREAT | O_TRUNC); flags |= O_BINARY; - if (get_major () == DEV_TAPE_MAJOR - || (flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY - || (flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDWR) - flags = ((flags & ~(O_WRONLY | O_RDWR)) | O_RDWR); + /* Write-only doesn't work well with raw devices */ + if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_WRONLY) + flags = ((flags & ~O_WRONLY) | O_RDWR); int res = fhandler_base::open (flags, 0); if (res && devbufsiz > 1L) diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc index 2296d59fa..1309b3ba8 100644 --- a/winsup/cygwin/fhandler_tape.cc +++ b/winsup/cygwin/fhandler_tape.cc @@ -1364,6 +1364,7 @@ fhandler_dev_tape::raw_write (const void *ptr, size_t len) if (!mt_evt && !(mt_evt = CreateEvent (&sec_none, TRUE, FALSE, NULL))) debug_printf ("Creating event failed: %E"); int ret = mt->drive (driveno ())->write (get_handle (), mt_evt, ptr, len); + if (ret) __seterrno_from_win_error (ret); return unlock (len); }