OSDN Git Service

* fhandler_raw.cc (fhandler_dev_raw::open): Eliminate compatibility
authorcorinna <corinna>
Tue, 16 Oct 2001 20:17:21 +0000 (20:17 +0000)
committercorinna <corinna>
Tue, 16 Oct 2001 20:17:21 +0000 (20:17 +0000)
        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.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler_raw.cc
winsup/cygwin/fhandler_tape.cc
winsup/cygwin/path.cc

index 5bfab9f..93e70ce 100644 (file)
@@ -1,5 +1,16 @@
 2001-10-16  Corinna Vinschen  <corinna@vinschen.de>
 
+       * 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.
+
+2001-10-16  Corinna Vinschen  <corinna@vinschen.de>
+
        * fhandler_tape.cc (fhandler_dev_tape::tape_status): Report
        EOTWarningZoneSize in get->mt_eotwarningzonesize.
        * include/cygwin/mtio.h: Define DEFTAPE.
index 3e73850..18d2a61 100644 (file)
@@ -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);
 
index 1963137..cb0ebf9 100644 (file)
@@ -692,7 +692,7 @@ fhandler_dev_tape::tape_set_blocksize (long count)
   if (lasterr)
     return lasterr;
 
-  if (count < min || count > max)
+  if (count != 0 && (count < min || count > max))
     return tape_error (ERROR_INVALID_PARAMETER, "tape_set_blocksize");
 
   mp.BlockSize = count;
index e0d39b8..317b3a6 100644 (file)
@@ -1010,18 +1010,18 @@ win32_device_name (const char *src_path, char *win32_path,
        __small_sprintf (win32_path, devfmt, unit == 8 ? "" : "u");
         break;
       case FH_TAPE:
-        __small_sprintf (win32_path, "\\device\\tape%d", unit % 128);
+        __small_sprintf (win32_path, "\\Device\\Tape%d", unit % 128);
         break;
       case FH_FLOPPY:
         if (unit < 16)
-         __small_sprintf (win32_path, "\\device\\floppy%d", unit);
+         __small_sprintf (win32_path, "\\Device\\Floppy%d", unit);
        else if (unit < 32)
-         __small_sprintf (win32_path, "\\device\\cdrom%d", unit - 16);
+         __small_sprintf (win32_path, "\\Device\\CdRom%d", unit - 16);
        else if (unit < 224)
-         __small_sprintf (win32_path, "\\device\\harddisk%d\\partition%d",
+         __small_sprintf (win32_path, "\\Device\\Harddisk%d\\Partition%d",
                                       (unit - 32) / 16, unit % 16);
        else
-         __small_sprintf (win32_path, "\\\\.\\%c:", unit - 224 + 'A');
+         __small_sprintf (win32_path, "\\DosDevices\\%c:", unit - 224 + 'A');
         break;
       default:
        __small_sprintf (win32_path, devfmt, unit);