Hi,

I ran into a problem when running parted on Ubuntu Breezy with an sx8
device; it would SIGFPE upon startup.  The culprit, it turns out, is the
HDIO_GETGEO ioctl; when asking for geometry information about a
partition (the name-based probing wasn't working well for devices
like /dev/sx8/0p1, etc), sectors and/or heads was 0.  This patch makes
parted to not only check if the ioctl didn't fail, but also make sure it
returned sane results (both are unsigned, so we don't have to worry
about <0).

------------------------------------------------------------
revno: 2
committer: Andres Salomon <[EMAIL PROTECTED]>
timestamp: Mon 2005-11-07 17:03:09 -0500
message:
  A kernel block driver may return a block geometry of 0 for sectors or heads,
  from HDIO_GETGEO.  Whether or not this is a kernel bug, parted should not
  assume that these values will always be non-zero (and then proceed to blow
  up by dividing by 0).  This patch fixes that bug by explicitly ensuring
  those values are not 0.
  
  FYI, the driver in question that was returning 0 was sx8, and it while
  probing /dev/sx8/0p1.
  
=== modified file 'libparted/linux.c'
--- libparted/linux.c
+++ libparted/linux.c
@@ -452,7 +452,8 @@
 	       		/ (dev->sector_size / PED_SECTOR_SIZE);
 
 	/* FIXME: what should we put here?  (TODO: discuss on linux-kernel) */
-	if (!ioctl (arch_specific->fd, HDIO_GETGEO, &geometry)) {
+	if (!ioctl (arch_specific->fd, HDIO_GETGEO, &geometry)
+	    && geometry.sectors && geometry.heads) {
 		dev->hw_geom.sectors = geometry.sectors;
 		dev->hw_geom.heads = geometry.heads;
 		dev->hw_geom.cylinders

_______________________________________________
Bug-parted mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-parted

Reply via email to