diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2014-05-20 10:25:32 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2014-05-20 10:25:32 +0000 |
commit | 3da259f729948e75aacd972ac2200499b2311117 (patch) | |
tree | 25a8c2d8f84e353c5b0583e2479044a789bea2d2 /winsup/cygwin/fhandler_floppy.cc | |
parent | 51a895f86d7185185d60be507494c03dd3c4342a (diff) | |
download | cygnal-3da259f729948e75aacd972ac2200499b2311117.tar.gz cygnal-3da259f729948e75aacd972ac2200499b2311117.tar.bz2 cygnal-3da259f729948e75aacd972ac2200499b2311117.zip |
* fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Fix floppy
drive handling broken with 1.7.19.
Diffstat (limited to 'winsup/cygwin/fhandler_floppy.cc')
-rw-r--r-- | winsup/cygwin/fhandler_floppy.cc | 30 |
1 files changed, 22 insertions, 8 deletions
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; |