]> sourceware.org Git - newlib-cygwin.git/commitdiff
* fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Fix floppy
authorCorinna Vinschen <corinna@vinschen.de>
Tue, 20 May 2014 10:25:32 +0000 (10:25 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 20 May 2014 10:25:32 +0000 (10:25 +0000)
drive handling broken with 1.7.19.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler_floppy.cc
winsup/cygwin/release/1.7.30

index 3e84f4e2ec53ec623fc11b8bd8bee08d59cbd73f..5670bec989cce3e9bf24c6f020c576c0de712183 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-20  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Fix floppy
+       drive handling broken with 1.7.19.
+
 2014-05-20  Corinna Vinschen  <corinna@vinschen.de>
 
        * scandir.cc (scandir): Assume namelist is always valid, per POSIX.
index 9e4b1ce1d4901b18256e8c9e502b0318e8402527..8cf19bf82b152d531eed142b524dc8f87bc22669 100644 (file)
@@ -2,7 +2,7 @@
    fhandler classes.
 
    Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2011, 2012, 2013 Red Hat, Inc.
+   2011, 2012, 2013, 2014 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -63,12 +63,6 @@ fhandler_dev_floppy::get_drive_info (struct hd_geometry *geo)
        {
          dix = (DISK_GEOMETRY_EX *) dbuf;
          di = &dix->Geometry;
-         if (!DeviceIoControl (get_handle (),
-                               IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0,
-                               pbuf, 256, &bytes_read, NULL))
-           __seterrno ();
-         else
-           pix = (PARTITION_INFORMATION_EX *) pbuf;
        }
     }
   if (!di)
@@ -81,6 +75,23 @@ fhandler_dev_floppy::get_drive_info (struct hd_geometry *geo)
          return -1;
        }
       di = (DISK_GEOMETRY *) dbuf;
+    }
+  if (dix) /* Don't try IOCTL_DISK_GET_PARTITION_INFO_EX if
+             IOCTL_DISK_GET_DRIVE_GEOMETRY_EX didn't work. 
+             Probably a floppy.*/
+    {
+      if (!DeviceIoControl (get_handle (),
+                           IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0,
+                           pbuf, 256, &bytes_read, NULL))
+       __seterrno ();
+      else
+       pix = (PARTITION_INFORMATION_EX *) pbuf;
+    }
+  if (!pix && get_major () != DEV_FLOPPY_MAJOR)
+    {
+      /* It's unlikely that this code path will be used at all.  Either the
+        _EX call already worked, or it's a floppy.  But it doesn't hurt to
+        keep the code in. */
       if (!DeviceIoControl (get_handle (),
                            IOCTL_DISK_GET_PARTITION_INFO, NULL, 0,
                            pbuf, 256, &bytes_read, NULL))
@@ -101,13 +112,16 @@ fhandler_dev_floppy::get_drive_info (struct hd_geometry *geo)
                    pix->PartitionLength.QuadPart);
       drive_size = pix->PartitionLength.QuadPart;
     }
-  else
+  else if (pi)
     {
       debug_printf ("partition info: offset %D  length %D",
                    pi->StartingOffset.QuadPart,
                    pi->PartitionLength.QuadPart);
       drive_size = pi->PartitionLength.QuadPart;
     }
+  else /* Floppy drive. */
+    drive_size = di->Cylinders.QuadPart * di->TracksPerCylinder
+                * di->SectorsPerTrack * di->BytesPerSector;
   if (geo)
     {
       geo->heads = di->TracksPerCylinder;
index 521ca17e308ca6364f8cb05e016e52fc30770eff..f0cc46dfff796cdcf0c4f094f19458b146d5f920 100644 (file)
@@ -36,3 +36,6 @@ Bug Fixes
 
 - Ignore trailing whitespace on #! scripts.
   Addresses: https://cygwin.com/ml/cygwin/2014-05/msg00022.html
+
+- Fix raw floppy drive handling broken since 1.7.19.
+  Addresses: https://cygwin.com/ml/cygwin/2014-05/msg00401.html
This page took 0.038723 seconds and 5 git commands to generate.