Index: cygwin/fhandler_floppy.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_floppy.cc,v
retrieving revision 1.22
diff -u -p -r1.22 fhandler_floppy.cc
--- cygwin/fhandler_floppy.cc	22 Sep 2002 03:38:57 -0000	1.22
+++ cygwin/fhandler_floppy.cc	24 Oct 2002 01:32:52 -0000
@@ -14,6 +14,9 @@ details. */
 #include <errno.h>
 #include <unistd.h>
 #include <winioctl.h>
+#include <asm/socket.h>
+#include <cygwin/hdreg.h>
+#include <cygwin/fs.h>
 #include "security.h"
 #include "fhandler.h"
 #include "cygerrno.h"
@@ -186,6 +189,124 @@ fhandler_dev_floppy::lseek (__off64_t of
 int
 fhandler_dev_floppy::ioctl (unsigned int cmd, void *buf)
 {
-  return fhandler_dev_raw::ioctl (cmd, buf);
+  DISK_GEOMETRY di;
+  PARTITION_INFORMATION pi;
+  DWORD bytes_read;
+  __off64_t drive_size = 0;
+  __off64_t start = 0;
+  switch (cmd)
+    {
+    case HDIO_GETGEO:
+      {
+        debug_printf ("HDIO_GETGEO");
+        if (!DeviceIoControl (get_handle (),
+                              IOCTL_DISK_GET_DRIVE_GEOMETRY,
+                              NULL, 0,
+                              &di, sizeof (di),
+                              &bytes_read, NULL))
+          {
+            __seterrno ();
+            return -1;
+          }
+        debug_printf ("disk geometry: (%ld cyl)*(%ld trk)*(%ld sec)*(%ld bps)",
+                      di.Cylinders.LowPart,
+                      di.TracksPerCylinder,
+                      di.SectorsPerTrack,
+                      di.BytesPerSector);
+        if (DeviceIoControl (get_handle (),
+                              IOCTL_DISK_GET_PARTITION_INFO,
+                              NULL, 0,
+                              &pi, sizeof (pi),
+                              &bytes_read, NULL))
+          {
+            debug_printf ("partition info: %ld (%ld)",
+                          pi.StartingOffset.LowPart,
+                          pi.PartitionLength.LowPart);
+            start = pi.StartingOffset.QuadPart >> 9ULL;
+          }
+        struct hd_geometry *geo = (struct hd_geometry *) buf;
+        geo->heads = di.TracksPerCylinder;
+        geo->sectors = di.SectorsPerTrack;
+        geo->cylinders = di.Cylinders.LowPart;
+        geo->start = start;
+        return 0;
+      }
+    case BLKGETSIZE:
+    case BLKGETSIZE64:
+      {
+        debug_printf ("BLKGETSIZE");
+        if (!DeviceIoControl (get_handle (),
+                              IOCTL_DISK_GET_DRIVE_GEOMETRY,
+                              NULL, 0,
+                              &di, sizeof (di),
+                              &bytes_read, NULL))
+          {
+            __seterrno ();
+            return -1;
+          }
+        debug_printf ("disk geometry: (%ld cyl)*(%ld trk)*(%ld sec)*(%ld bps)",
+                      di.Cylinders.LowPart,
+                      di.TracksPerCylinder,
+                      di.SectorsPerTrack,
+                      di.BytesPerSector);
+        if (DeviceIoControl (get_handle (),
+                             IOCTL_DISK_GET_PARTITION_INFO,
+                             NULL, 0,
+                             &pi, sizeof (pi),
+                             &bytes_read, NULL))
+          {
+            debug_printf ("partition info: %ld (%ld)",
+                          pi.StartingOffset.LowPart,
+                          pi.PartitionLength.LowPart);
+            drive_size = pi.PartitionLength.QuadPart;
+          }
+        else
+          {
+            drive_size = di.Cylinders.QuadPart * di.TracksPerCylinder *
+                         di.SectorsPerTrack * di.BytesPerSector;
+          }
+        if (cmd == BLKGETSIZE)
+          *(long *)buf = drive_size >> 9UL;
+        else
+          *(__off64_t *)buf = drive_size;
+        return 0;
+      }
+    case BLKRRPART:
+      {
+        debug_printf ("BLKRRPART");
+        if (!DeviceIoControl (get_handle (),
+                              IOCTL_DISK_UPDATE_DRIVE_SIZE,
+                              NULL, 0,
+                              &di, sizeof (di),
+                              &bytes_read, NULL))
+          {
+            __seterrno ();
+            return -1;
+          }
+        return 0;
+      }
+    case BLKSSZGET:
+      {
+        debug_printf ("BLKSSZGET");
+        if (!DeviceIoControl (get_handle (),
+                              IOCTL_DISK_GET_DRIVE_GEOMETRY,
+                              NULL, 0,
+                              &di, sizeof (di),
+                              &bytes_read, NULL))
+          {
+            __seterrno ();
+            return -1;
+          }
+        debug_printf ("disk geometry: (%ld cyl)*(%ld trk)*(%ld sec)*(%ld bps)",
+                      di.Cylinders.LowPart,
+                      di.TracksPerCylinder,
+                      di.SectorsPerTrack,
+                      di.BytesPerSector);
+        *(int *)buf = di.BytesPerSector;
+        return 0;
+      }
+    default:
+      return fhandler_dev_raw::ioctl (cmd, buf);
+    }
 }
 
Index: w32api/include/winioctl.h
===================================================================
RCS file: /cvs/src/src/winsup/w32api/include/winioctl.h,v
retrieving revision 1.7
diff -u -p -r1.7 winioctl.h
--- w32api/include/winioctl.h	25 Jun 2002 21:05:19 -0000	1.7
+++ w32api/include/winioctl.h	24 Oct 2002 01:33:01 -0000
@@ -56,6 +56,7 @@ extern "C" {
 #define IOCTL_DISK_FIND_NEW_DEVICES CTL_CODE(IOCTL_DISK_BASE,0x206,METHOD_BUFFERED,FILE_READ_ACCESS)
 #define IOCTL_DISK_REMOVE_DEVICE CTL_CODE(IOCTL_DISK_BASE,0x207,METHOD_BUFFERED,FILE_READ_ACCESS)
 #define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE,0x300,METHOD_BUFFERED,FILE_ANY_ACCESS)
+#define IOCTL_DISK_UPDATE_DRIVE_SIZE CTL_CODE(IOCTL_DISK_BASE, 0x0032, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
 #define IOCTL_SERIAL_LSRMST_INSERT	CTL_CODE(FILE_DEVICE_SERIAL_PORT,31,METHOD_BUFFERED,FILE_ANY_ACCESS)
 #define FSCTL_LOCK_VOLUME	CTL_CODE(FILE_DEVICE_FILE_SYSTEM,6,METHOD_BUFFERED,FILE_ANY_ACCESS)
 #define FSCTL_UNLOCK_VOLUME	CTL_CODE(FILE_DEVICE_FILE_SYSTEM,7,METHOD_BUFFERED,FILE_ANY_ACCESS)
