diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3e84f4e2e..5670bec98 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2014-05-20 Corinna Vinschen + + * fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Fix floppy + drive handling broken with 1.7.19. + 2014-05-20 Corinna Vinschen * scandir.cc (scandir): Assume namelist is always valid, per POSIX. diff --git a/winsup/cygwin/fhandler_floppy.cc b/winsup/cygwin/fhandler_floppy.cc index 9e4b1ce1d..8cf19bf82 100644 --- a/winsup/cygwin/fhandler_floppy.cc +++ b/winsup/cygwin/fhandler_floppy.cc @@ -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; diff --git a/winsup/cygwin/release/1.7.30 b/winsup/cygwin/release/1.7.30 index 521ca17e3..f0cc46dff 100644 --- a/winsup/cygwin/release/1.7.30 +++ b/winsup/cygwin/release/1.7.30 @@ -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