Skip to contentSkip to conversation

cciss update for 2.6

PATCH [email protected] 3 participants 3 messages Mar 25, 2004 – Mar 26, 2004 Block layer

lore
Share & tools
lore
#0 lore raw

Please consider this patch for inclusion in the 2.6 kernel.

If no device is attached we now return -ENXIO instead of some bogus numbers. Prevents applications from trying to access non-existent disks. Also adds HDIO_GETGEO_BIG IOCTL that fdisk uses.

 cciss.c |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

------------------------------------------------------------------------------

drivers/block/cciss.c +18 -6
diff -burpN lx265-rc2.orig/drivers/block/cciss.c lx265-rc2-test2/drivers/block/cciss.c
@@ -469,18 +469,30 @@ static int cciss_ioctl(struct inode *ino
                         driver_geo.heads = drv->heads;
                         driver_geo.sectors = drv->sectors;
                         driver_geo.cylinders = drv->cylinders;
-                } else {
-                        driver_geo.heads = 0xff;
-                        driver_geo.sectors = 0x3f;
-                        driver_geo.cylinders = (int)drv->nr_blocks / (0xff*0x3f);
-                }
+                } else 
+			return -ENXIO;
                 driver_geo.start= get_start_sect(inode->i_bdev);
                 if (copy_to_user((void *) arg, &driver_geo,
                                 sizeof( struct hd_geometry)))
                         return  -EFAULT;
                 return(0);
 	}
-
+        case HDIO_GETGEO_BIG:
+	{
+		struct hd_big_geometry driver_geo;
+		if (hba[ctlr]->drv[dsk].cylinders) {
+			driver_geo.heads = hba[ctlr]->drv[dsk].heads;
+			driver_geo.sectors = hba[ctlr]->drv[dsk].sectors;
+			driver_geo.cylinders = hba[ctlr]->drv[dsk].cylinders;
+			} else
+				return -ENXIO;
+			driver_geo.start=
+			hba[ctlr]->hd[MINOR(inode->i_rdev)].start_sect;
+			if (copy_to_user((void *) arg, &driver_geo,
+					sizeof( struct hd_big_geometry)))
+				return  -EFAULT;
+			return 0;
+	}
 	case CCISS_GETPCIINFO:
 	{
 		cciss_pci_info_struct pciinfo;
#1 lore raw
Quoted 3 lines · [email protected] wrote:

Please consider this patch for inclusion in the 2.6 kernel.

I think this was a 2.4 patch?

Quoted 4 lines

If no device is attached we now return -ENXIO instead of some bogus numbers. Prevents applications from trying to access non-existent disks. Also adds HDIO_GETGEO_BIG IOCTL that fdisk uses.

drivers/block/cciss.c: In function `cciss_ioctl':
drivers/block/cciss.c:480: `HDIO_GETGEO_BIG' undeclared (first use in this function) drivers/block/cciss.c:480: (Each undeclared identifier is reported only once drivers/block/cciss.c:480: for each function it appears in.) drivers/block/cciss.c:482: storage size of driver_geo' isn't known drivers/block/cciss.c:483: dsk' undeclared (first use in this function) drivers/block/cciss.c:490: structure has no member named hd' drivers/block/cciss.c:492: sizeof applied to an incomplete type drivers/block/cciss.c:482: warning: unused variable driver_geo'

#2 lore raw
In reply to [email protected]
Quoted 5 lines · On Thu, Mar 25, 2004 at 04:46:41PM -0600, [email protected] wrote:

Please consider this patch for inclusion in the 2.6 kernel.

If no device is attached we now return -ENXIO instead of some bogus numbers. Prevents applications from trying to access non-existent disks. Also adds HDIO_GETGEO_BIG IOCTL that fdisk uses.

HDIO_GETGEO_BIG was only used by some horribly patched vendor fdisks. It's not declared in the kernel, and thus no driver should implement it.