[parted-devel] [PATCH 11/11] Remove HDIO_GETGEO and hw_geom

Phillip Susi psusi at ubuntu.com
Mon Jan 7 04:44:36 UTC 2013


Geometry is vestigial nonsense from when disks actually had
cylinders, sectors, and heads.  The Linux ioctl HDIO_GETGEO
has been depreciated for years, and returned bogus geometry
anyhow.  This geometry was being stored in the hw_geom field
of PedDevice.  This patch removes the calls to HDIO_GETGEO
and the hw_geom field, and replaces references to it with the
bios_geom field instead.
---
 include/parted/device.in.h |    1 -
 libparted/arch/beos.c      |   14 ++-----
 libparted/arch/gnu.c       |    2 -
 libparted/arch/linux.c     |   91 ++++++++++----------------------------------
 libparted/labels/dasd.c    |   22 +++++------
 libparted/labels/fdasd.c   |   14 ++-----
 libparted/labels/pc98.c    |   22 +++++------
 libparted/labels/rdb.c     |   33 ++++++++--------
 libparted/labels/sun.c     |    6 +--
 9 files changed, 67 insertions(+), 138 deletions(-)

diff --git a/include/parted/device.in.h b/include/parted/device.in.h
index 7c06a66..5dafe70 100644
--- a/include/parted/device.in.h
+++ b/include/parted/device.in.h
@@ -87,7 +87,6 @@ struct _PedDevice {
         int             dirty;
         int             boot_dirty;
 
-        PedCHSGeometry  hw_geom;
         PedCHSGeometry  bios_geom;
         short           host, did;
 
diff --git a/libparted/arch/beos.c b/libparted/arch/beos.c
index 6a8a5ae..a77f081 100644
--- a/libparted/arch/beos.c
+++ b/libparted/arch/beos.c
@@ -124,11 +124,6 @@ _device_init_ata(PedDevice* dev)
 	dev->bios_geom.heads = ide_info.heads;
 	dev->bios_geom.sectors = ide_info.sectors;
 
-	/* Copy used dimensions */
-	dev->hw_geom.cylinders = ide_info.current_cylinders;
-	dev->hw_geom.heads = ide_info.current_heads;
-	dev->hw_geom.sectors = ide_info.current_sectors;
-
 	/* Copy total number of sectors */
 	if (ide_info._48_bit_addresses_supported)
 		dev->length = ide_info.LBA48_total_sectors;
@@ -186,9 +181,9 @@ _device_init_generic_blkdev(PedDevice* dev)
 
 	close(fd);
 
-	dev->hw_geom.cylinders = os.cylinder_count;
-	dev->hw_geom.heads = os.head_count;
-	dev->hw_geom.sectors = os.sectors_per_track;
+	dev->bios_geom.cylinders = os.cylinder_count;
+	dev->bios_geom.heads = os.head_count;
+	dev->bios_geom.sectors = os.sectors_per_track;
 
 	dev->sector_size =
 	dev->phys_sector_size = os.bytes_per_sector;
@@ -199,8 +194,6 @@ _device_init_generic_blkdev(PedDevice* dev)
 		dev->bios_geom.heads = bios.head_count;
 		dev->bios_geom.sectors = bios.sectors_per_track;
 	}
-	else
-		dev->bios_geom = dev->hw_geom;
 
 	dev->model = strdup("");
 
@@ -240,7 +233,6 @@ _device_init_file(PedDevice* dev, struct stat* dev_statp)
 	dev->bios_geom.cylinders = dev->length / (4 * 32);
 	dev->bios_geom.heads = 4;
 	dev->bios_geom.sectors = 32;
-	dev->hw_geom = dev->bios_geom;
 
 	dev->model = strdup(_("Disk Image"));
 
diff --git a/libparted/arch/gnu.c b/libparted/arch/gnu.c
index 21d1f35..f5721f1 100644
--- a/libparted/arch/gnu.c
+++ b/libparted/arch/gnu.c
@@ -92,8 +92,6 @@ _device_probe_geometry (PedDevice* dev)
 	cyl_size = dev->bios_geom.sectors * dev->bios_geom.heads;
 	dev->bios_geom.cylinders = dev->length / cyl_size
 					* (dev->sector_size / PED_SECTOR_SIZE_DEFAULT);
-	dev->hw_geom = dev->bios_geom;
-
 	return 1;
 }
 
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 1e04d48..b53d5ad 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -78,7 +78,6 @@
 #endif
 
 /* from <linux/hdreg.h> */
-#define HDIO_GETGEO             0x0301  /* get device geometry */
 #define HDIO_GET_IDENTITY       0x030d  /* get IDE identification info */
 
 #define RD_MODE (O_RDONLY)
@@ -829,9 +828,7 @@ _device_get_length (PedDevice* dev)
 static int
 _device_probe_geometry (PedDevice* dev)
 {
-        LinuxSpecific*          arch_specific = LINUX_SPECIFIC (dev);
         struct stat             dev_stat;
-        struct hd_geometry      geometry;
 
         if (!_device_stat (dev, &dev_stat))
                 return 0;
@@ -843,26 +840,12 @@ _device_probe_geometry (PedDevice* dev)
         if (!dev->length)
                 return 0;
 
-        /* The GETGEO ioctl is no longer useful (as of linux 2.6.x).  We could
-         * still use it in 2.4.x, but this is contentious.  Perhaps we should
-         * move to EDD. */
+	/* Fake the bios geometry; it is nonsense anyway */
         dev->bios_geom.sectors = 63;
         dev->bios_geom.heads = 255;
         dev->bios_geom.cylinders
                 = dev->length / (63 * 255);
 
-        /* FIXME: what should we put here?  (TODO: discuss on linux-kernel) */
-        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
-                        = dev->length / (dev->hw_geom.heads
-                                         * dev->hw_geom.sectors);
-        } else {
-                dev->hw_geom = dev->bios_geom;
-        }
-
         return 1;
 }
 
@@ -1186,7 +1169,6 @@ init_file (PedDevice* dev)
         dev->bios_geom.cylinders = dev->length / 4 / 32;
         dev->bios_geom.heads = 4;
         dev->bios_geom.sectors = 32;
-        dev->hw_geom = dev->bios_geom;
         dev->model = strdup ("");
 
         return 1;
@@ -1223,21 +1205,12 @@ init_dasd (PedDevice* dev, const char* model_name)
         if (!dev->length)
                 goto error_close_dev;
 
-        if (!ioctl (arch_specific->fd, HDIO_GETGEO, &geo)) {
-                dev->hw_geom.sectors = geo.sectors;
-                dev->hw_geom.heads = geo.heads;
-                dev->hw_geom.cylinders = dev->length
-                        / (dev->hw_geom.heads * dev->hw_geom.sectors)
-                        / (dev->sector_size / PED_SECTOR_SIZE_DEFAULT);
-                dev->bios_geom = dev->hw_geom;
-        } else {
-                dev->bios_geom.sectors = 12;
-                dev->bios_geom.heads = 15;
-                dev->bios_geom.cylinders = dev->length
-                        / (dev->hw_geom.heads * dev->hw_geom.sectors)
-                        / (dev->sector_size / PED_SECTOR_SIZE_DEFAULT);
-                dev->hw_geom = dev->bios_geom;
-        }
+	/* Fake the bios geometry; it is nonsense anyway */
+	dev->bios_geom.sectors = 63;
+	dev->bios_geom.heads = 255;
+	dev->bios_geom.cylinders = dev->length
+		/ (dev->bios_geom.heads * dev->bios_geom.sectors)
+		/ (dev->sector_size / PED_SECTOR_SIZE_DEFAULT);
 
         if (!ioctl(arch_specific->fd, BIODASDINFO, &dasd_info)) {
                 arch_specific->devno = dasd_info.devno;
@@ -2546,9 +2519,7 @@ _sysfs_ull_entry_from_part(PedPartition const* part, const char *entry,
 
 
 /* Get the starting sector and length of a partition PART within a block device
-   Use blkpg if available, then check sysfs and then use HDIO_GETGEO and
-   BLKGETSIZE64 ioctls as fallback.  Upon success, return true.  Otherwise,
-   return false. */
+   from sysfs */
 static bool
 _kernel_get_partition_start_and_length(PedPartition const *part,
                                        unsigned long long *start,
@@ -2563,41 +2534,13 @@ _kernel_get_partition_start_and_length(PedPartition const *part,
                 return false;
 
         int ok = _sysfs_ull_entry_from_part (part, "start", start);
-        if (!ok) {
-                struct hd_geometry geom;
-                int dev_fd = open (dev_name, O_RDONLY);
-                if (dev_fd != -1 && ioctl (dev_fd, HDIO_GETGEO, &geom)) {
-                        *start = geom.start;
-                        ok = true;
-                } else {
-                        if (dev_fd != -1)
-                                close(dev_fd);
-                        free (dev_name);
-                        return false;
-                }
-        }
+        if (!ok)
+                return false;
         *start = (*start * 512) / part->disk->dev->sector_size;
         ok = _sysfs_ull_entry_from_part (part, "size", length);
-
-        int fd;
-        if (!ok) {
-                fd = open (dev_name, O_RDONLY);
-                if (fd != -1 && ioctl (fd, BLKGETSIZE64, length))
-                        ok = true;
-        } else {
-                fd = -1;
-                *length *= 512;
-        }
-        *length /= part->disk->dev->sector_size;
-        if (fd != -1)
-                close (fd);
-
         if (!ok)
-                ped_exception_throw (
-                        PED_EXCEPTION_BUG,
-                        PED_EXCEPTION_CANCEL,
-                        _("Unable to determine the start and length of %s."),
-                        dev_name);
+                return false;
+        *length = (*length * 512) / part->disk->dev->sector_size;
         free (dev_name);
         return ok;
 }
@@ -2840,8 +2783,16 @@ _disk_sync_part_table (PedDisk* disk)
                                 unsigned long long start;
                                 /* get start and length of existing partition */
                                 if (!get_partition_start_and_length(part,
-                                                                    &start, &length))
+                                                                    &start, &length)) {
+                                        ped_exception_throw (
+                                                PED_EXCEPTION_BUG,
+                                                PED_EXCEPTION_CANCEL,
+                                                _("Unable to determine the start and length of "
+                                                  "partition %d on %s."),
+                                                i,
+                                                disk->dev->path);
                                         goto cleanup;
+                                }
                                 if (start == part->geom.start
 				    && length == part->geom.length)
                                         ok[i - 1] = 1;
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
index a769866..ecf8690 100644
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -384,11 +384,11 @@ dasd_read (PedDisk* disk)
         PDEBUG;
 
 		start = (long long)(long long) p->start_trk
-				* (long long) disk->dev->hw_geom.sectors
+				* (long long) disk->dev->bios_geom.sectors
 				* (long long) arch_specific->real_sector_size
 				/ (long long) disk->dev->sector_size;
 		end   = (long long)((long long) p->end_trk + 1)
-				* (long long) disk->dev->hw_geom.sectors
+				* (long long) disk->dev->bios_geom.sectors
 				* (long long) arch_specific->real_sector_size
 				/ (long long) disk->dev->sector_size - 1;
 		part = ped_partition_new(disk, PED_PARTITION_NORMAL, NULL,
@@ -448,11 +448,11 @@ dasd_read (PedDisk* disk)
 
 		if (p->fspace_trk > 0) {
 			start = (long long)((long long) p->end_trk + 1)
-					* (long long) disk->dev->hw_geom.sectors
+					* (long long) disk->dev->bios_geom.sectors
 					* (long long) arch_specific->real_sector_size
 					/ (long long) disk->dev->sector_size;
 			end   = (long long)((long long) p->end_trk + 1 + p->fspace_trk)
-					* (long long) disk->dev->hw_geom.sectors
+					* (long long) disk->dev->bios_geom.sectors
 					* (long long) arch_specific->real_sector_size
 					/ (long long) disk->dev->sector_size - 1;
 			part = ped_partition_new (disk, PED_PARTITION_NORMAL,
@@ -610,10 +610,10 @@ dasd_write (const PedDisk* disk)
 		PDEBUG;
 
 		start = part->geom.start * disk->dev->sector_size
-				/ arch_specific->real_sector_size / disk->dev->hw_geom.sectors;
+				/ arch_specific->real_sector_size / disk->dev->bios_geom.sectors;
 		stop = (part->geom.end + 1)
 			   * disk->dev->sector_size / arch_specific->real_sector_size
-			   / disk->dev->hw_geom.sectors - 1;
+			   / disk->dev->bios_geom.sectors - 1;
 
 		PDEBUG;
 		dasd_data = part->disk_specific;
@@ -778,7 +778,7 @@ dasd_get_partition_alignment(const PedDisk *disk)
         PedSector sector_size =
                 arch_specific->real_sector_size / disk->dev->sector_size;
 
-        return ped_alignment_new(0, disk->dev->hw_geom.sectors * sector_size);
+        return ped_alignment_new(0, disk->dev->bios_geom.sectors * sector_size);
 }
 
 static PedConstraint*
@@ -798,10 +798,10 @@ _primary_constraint (PedDisk* disk)
 	sector_size = arch_specific->real_sector_size / disk->dev->sector_size;
 
 	if (!ped_alignment_init (&start_align, 0,
-							 disk->dev->hw_geom.sectors * sector_size))
+							 disk->dev->bios_geom.sectors * sector_size))
 		return NULL;
 	if (!ped_alignment_init (&end_align, -1,
-						     disk->dev->hw_geom.sectors * sector_size))
+						     disk->dev->bios_geom.sectors * sector_size))
 		return NULL;
 	if (!ped_geometry_init (&max_geom, disk->dev, 0, disk->dev->length))
 		return NULL;
@@ -867,7 +867,7 @@ dasd_partition_set_system (PedPartition* part,
 	DasdPartitionData* dasd_data = part->disk_specific;
 	PedSector cyl_size;
 
-	cyl_size=part->disk->dev->hw_geom.sectors * part->disk->dev->hw_geom.heads;
+	cyl_size=part->disk->dev->bios_geom.sectors * part->disk->dev->bios_geom.heads;
 	PDEBUG;
 
 	part->fs_type = fs_type;
@@ -929,7 +929,7 @@ dasd_alloc_metadata (PedDisk* disk)
                 if (disk->dev->type == PED_DEVICE_FILE)
                         arch_specific->real_sector_size = disk->dev->sector_size;
         /* Mark the start of the disk as metadata. */
-		vtoc_end = (FIRST_USABLE_TRK * (long long) disk->dev->hw_geom.sectors
+		vtoc_end = (FIRST_USABLE_TRK * (long long) disk->dev->bios_geom.sectors
 				   * (long long) arch_specific->real_sector_size
 				   / (long long) disk->dev->sector_size) - 1;
         }
diff --git a/libparted/labels/fdasd.c b/libparted/labels/fdasd.c
index e235dd3..b58fc8a 100644
--- a/libparted/labels/fdasd.c
+++ b/libparted/labels/fdasd.c
@@ -781,7 +781,6 @@ void
 fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
 {
 	PDEBUG
-	int blksize = 0;
 	dasd_information_t dasd_info;
 
 	/* We can't get geometry from a regular file,
@@ -801,14 +800,6 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
 	    dasd_info.label_block = 2;
 	    dasd_info.devno = 513;
 	} else {
-		if (ioctl(f, HDIO_GETGEO, &anc->geo) != 0)
-			fdasd_error(anc, unable_to_ioctl,
-			    _("Could not retrieve disk geometry information."));
-
-		if (ioctl(f, BLKSSZGET, &blksize) != 0)
-			fdasd_error(anc, unable_to_ioctl,
-			    _("Could not retrieve blocksize information."));
-
 		/* get disk type */
 		if (ioctl(f, BIODASDINFO, &dasd_info) != 0)
 			fdasd_error(anc, unable_to_ioctl,
@@ -816,9 +807,12 @@ fdasd_get_geometry (const PedDevice *dev, fdasd_anchor_t *anc, int f)
 	}
 
 	anc->dev_type   = dasd_info.dev_type;
-	anc->blksize    = blksize;
+	anc->blksize    = dev->sector_size;
 	anc->label_pos  = dasd_info.label_block * blksize;
 	anc->devno      = dasd_info.devno;
+	anc->geo.heads  = dev->bios_geom.heads;
+	anc->geo.sectors = dev->bios_geom.sectors;
+	anc->geo.cylinders = dev->bios_geom.cylinders;
 	anc->fspace_trk = anc->geo.cylinders * anc->geo.heads - FIRST_USABLE_TRK;
 }
 
diff --git a/libparted/labels/pc98.c b/libparted/labels/pc98.c
index ad13c0d..97de81a 100644
--- a/libparted/labels/pc98.c
+++ b/libparted/labels/pc98.c
@@ -197,7 +197,7 @@ static PedSector _GL_ATTRIBUTE_PURE
 chs_to_sector (const PedDevice* dev, int c, int h, int s)
 {
 	PED_ASSERT (dev != NULL);
-	return (c * dev->hw_geom.heads + h) * dev->hw_geom.sectors + s;
+	return (c * dev->bios_geom.heads + h) * dev->bios_geom.sectors + s;
 }
 
 static void
@@ -210,11 +210,11 @@ sector_to_chs (const PedDevice* dev, PedSector sector, int* c, int* h, int* s)
 	PED_ASSERT (h != NULL);
 	PED_ASSERT (s != NULL);
 
-	cyl_size = dev->hw_geom.heads * dev->hw_geom.sectors;
+	cyl_size = dev->bios_geom.heads * dev->bios_geom.sectors;
 
 	*c = sector / cyl_size;
-	*h = (sector) % cyl_size / dev->hw_geom.sectors;
-	*s = (sector) % cyl_size % dev->hw_geom.sectors;
+	*h = (sector) % cyl_size / dev->bios_geom.sectors;
+	*s = (sector) % cyl_size % dev->bios_geom.sectors;
 }
 
 static PedSector _GL_ATTRIBUTE_PURE
@@ -236,8 +236,8 @@ legacy_end (const PedDisk* disk, const PC98RawPartition* raw_part)
 	if (raw_part->end_head == 0 && raw_part->end_sector == 0) {
 		return chs_to_sector (disk->dev,
 				      PED_LE16_TO_CPU(raw_part->end_cyl),
-				      disk->dev->hw_geom.heads - 1,
-				      disk->dev->hw_geom.sectors - 1);
+				      disk->dev->bios_geom.heads - 1,
+				      disk->dev->bios_geom.sectors - 1);
 	} else {
 		return chs_to_sector (disk->dev,
 				      PED_LE16_TO_CPU(raw_part->end_cyl),
@@ -407,8 +407,8 @@ fill_raw_part (PC98RawPartition* raw_part, const PedPartition* part)
 	}
 
 	sector_to_chs (part->disk->dev, part->geom.end, &c, &h, &s);
-	if (h != part->disk->dev->hw_geom.heads - 1
-	    || s != part->disk->dev->hw_geom.sectors - 1) {
+	if (h != part->disk->dev->bios_geom.heads - 1
+	    || s != part->disk->dev->bios_geom.sectors - 1) {
 		ped_exception_throw (
 		    PED_EXCEPTION_NO_FEATURE,
 		    PED_EXCEPTION_CANCEL,
@@ -657,7 +657,7 @@ static PedAlignment*
 pc98_get_partition_alignment(const PedDisk *disk)
 {
 	PedSector cylinder_size =
-		disk->dev->hw_geom.sectors * disk->dev->hw_geom.heads;
+		disk->dev->bios_geom.sectors * disk->dev->bios_geom.heads;
 
         return ped_alignment_new(0, cylinder_size);
 }
@@ -671,7 +671,7 @@ _primary_constraint (PedDisk* disk)
 	PedGeometry	max_geom;
 	PedSector	cylinder_size;
 
-	cylinder_size = dev->hw_geom.sectors * dev->hw_geom.heads;
+	cylinder_size = dev->bios_geom.sectors * dev->bios_geom.heads;
 
 	if (!ped_alignment_init (&start_align, 0, cylinder_size))
 		return NULL;
@@ -749,7 +749,7 @@ pc98_alloc_metadata (PedDisk* disk)
 
 	constraint_any = ped_constraint_any (disk->dev);
 
-	cyl_size = disk->dev->hw_geom.sectors * disk->dev->hw_geom.heads;
+	cyl_size = disk->dev->bios_geom.sectors * disk->dev->bios_geom.heads;
 	new_part = ped_partition_new (disk, PED_PARTITION_METADATA, NULL,
 				      0, cyl_size - 1);
 	if (!new_part)
diff --git a/libparted/labels/rdb.c b/libparted/labels/rdb.c
index 4cf1463..3e5f971 100644
--- a/libparted/labels/rdb.c
+++ b/libparted/labels/rdb.c
@@ -351,7 +351,7 @@ amiga_alloc (const PedDevice* dev)
 	int highest_cylinder, highest_block;
 
 	PED_ASSERT(dev != NULL);
-	cyl_size = dev->hw_geom.sectors * dev->hw_geom.heads;
+	cyl_size = dev->bios_geom.sectors * dev->bios_geom.heads;
 
 	if (!(disk = _ped_disk_alloc (dev, &amiga_disk_type)))
 		return NULL;
@@ -382,13 +382,13 @@ amiga_alloc (const PedDevice* dev)
 	rdb->rdb_BootBlockList = PED_CPU_TO_BE32 (LINK_END);
 
 	/* Physical drive characteristics */
-	rdb->rdb_Cylinders = PED_CPU_TO_BE32 (dev->hw_geom.cylinders);
-	rdb->rdb_Sectors = PED_CPU_TO_BE32 (dev->hw_geom.sectors);
-	rdb->rdb_Heads = PED_CPU_TO_BE32 (dev->hw_geom.heads);
+	rdb->rdb_Cylinders = PED_CPU_TO_BE32 (dev->bios_geom.cylinders);
+	rdb->rdb_Sectors = PED_CPU_TO_BE32 (dev->bios_geom.sectors);
+	rdb->rdb_Heads = PED_CPU_TO_BE32 (dev->bios_geom.heads);
 	rdb->rdb_Interleave = PED_CPU_TO_BE32 (0);
-	rdb->rdb_Park = PED_CPU_TO_BE32 (dev->hw_geom.cylinders);
-	rdb->rdb_WritePreComp = PED_CPU_TO_BE32 (dev->hw_geom.cylinders);
-	rdb->rdb_ReducedWrite = PED_CPU_TO_BE32 (dev->hw_geom.cylinders);
+	rdb->rdb_Park = PED_CPU_TO_BE32 (dev->bios_geom.cylinders);
+	rdb->rdb_WritePreComp = PED_CPU_TO_BE32 (dev->bios_geom.cylinders);
+	rdb->rdb_ReducedWrite = PED_CPU_TO_BE32 (dev->bios_geom.cylinders);
 	rdb->rdb_StepRate = PED_CPU_TO_BE32 (0);
 
 	highest_cylinder = 1 + MAX_RDB_BLOCK / cyl_size;
@@ -398,7 +398,7 @@ amiga_alloc (const PedDevice* dev)
 	rdb->rdb_RDBBlocksLo = PED_CPU_TO_BE32 (0);
 	rdb->rdb_RDBBlocksHi = PED_CPU_TO_BE32 (highest_block);
 	rdb->rdb_LoCylinder = PED_CPU_TO_BE32 (highest_cylinder);
-	rdb->rdb_HiCylinder = PED_CPU_TO_BE32 (dev->hw_geom.cylinders -1);
+	rdb->rdb_HiCylinder = PED_CPU_TO_BE32 (dev->bios_geom.cylinders -1);
 	rdb->rdb_CylBlocks = PED_CPU_TO_BE32 (cyl_size);
 	rdb->rdb_AutoParkSeconds = PED_CPU_TO_BE32 (0);
 	/* rdb_HighRDSKBlock will only be set when writing */
@@ -486,10 +486,9 @@ amiga_read (PedDisk* disk)
 	}
 
 	/* Let's copy the rdb read geometry to the dev */
-	/* FIXME: should this go into disk->dev->bios_geom instead? */
-	disk->dev->hw_geom.cylinders = PED_BE32_TO_CPU (rdb->rdb_Cylinders);
-	disk->dev->hw_geom.heads = PED_BE32_TO_CPU (rdb->rdb_Heads);
-	disk->dev->hw_geom.sectors = PED_BE32_TO_CPU (rdb->rdb_Sectors);
+	disk->dev->bios_geom.cylinders = PED_BE32_TO_CPU (rdb->rdb_Cylinders);
+	disk->dev->bios_geom.heads = PED_BE32_TO_CPU (rdb->rdb_Heads);
+	disk->dev->bios_geom.sectors = PED_BE32_TO_CPU (rdb->rdb_Sectors);
 	cylblocks = (PedSector) PED_BE32_TO_CPU (rdb->rdb_Heads) *
 		(PedSector) PED_BE32_TO_CPU (rdb->rdb_Sectors);
 
@@ -784,7 +783,7 @@ amiga_partition_new (const PedDisk* disk, PedPartitionType part_type,
 	PED_ASSERT(disk->dev != NULL);
 	PED_ASSERT(disk->disk_specific != NULL);
 	dev = disk->dev;
-	cyl = (PedSector) (dev->hw_geom.sectors * dev->hw_geom.heads);
+	cyl = (PedSector) (dev->bios_geom.sectors * dev->bios_geom.heads);
 	rdb = RDSK(disk->disk_specific);
 
 	if (!(part = _ped_partition_alloc (disk, part_type, fs_type, start, end)))
@@ -809,10 +808,10 @@ amiga_partition_new (const PedDisk* disk, PedPartitionType part_type,
 		partition->de_TableSize = PED_CPU_TO_BE32(19);
 		partition->de_SizeBlock = PED_CPU_TO_BE32(128);
 		partition->de_SecOrg = PED_CPU_TO_BE32(0);
-		partition->de_Surfaces = PED_CPU_TO_BE32(dev->hw_geom.heads);
+		partition->de_Surfaces = PED_CPU_TO_BE32(dev->bios_geom.heads);
 		partition->de_SectorPerBlock = PED_CPU_TO_BE32(1);
 		partition->de_BlocksPerTrack
-			= PED_CPU_TO_BE32(dev->hw_geom.sectors);
+			= PED_CPU_TO_BE32(dev->bios_geom.sectors);
 		partition->de_Reserved = PED_CPU_TO_BE32(2);
 		partition->de_PreAlloc = PED_CPU_TO_BE32(0);
 		partition->de_Interleave = PED_CPU_TO_BE32(0);
@@ -1012,7 +1011,7 @@ static PedAlignment*
 amiga_get_partition_alignment(const PedDisk *disk)
 {
 	PedSector cylinder_size =
-		disk->dev->hw_geom.sectors * disk->dev->hw_geom.heads;
+		disk->dev->bios_geom.sectors * disk->dev->bios_geom.heads;
 
         return ped_alignment_new(0, cylinder_size);
 }
@@ -1023,7 +1022,7 @@ _amiga_get_constraint (const PedDisk *disk)
 	PedDevice *dev = disk->dev;
 	PedAlignment start_align, end_align;
 	PedGeometry max_geom;
-	PedSector cyl_size = dev->hw_geom.sectors * dev->hw_geom.heads;
+	PedSector cyl_size = dev->bios_geom.sectors * dev->bios_geom.heads;
 
 	if (!ped_alignment_init(&start_align, 0, cyl_size))
 		return NULL;
diff --git a/libparted/labels/sun.c b/libparted/labels/sun.c
index 245208e..e47a3c4 100644
--- a/libparted/labels/sun.c
+++ b/libparted/labels/sun.c
@@ -258,10 +258,6 @@ _check_geometry_sanity (PedDisk* disk, SunRawLabel* label)
 {
 	PedDevice*	dev = disk->dev;
 
-	if (PED_BE16_TO_CPU(label->nsect) == dev->hw_geom.sectors &&
-	    PED_BE16_TO_CPU(label->ntrks) == dev->hw_geom.heads)
-		dev->bios_geom = dev->hw_geom;
-
 	if (!!PED_BE16_TO_CPU(label->pcylcount)
 	    * !!PED_BE16_TO_CPU(label->ntrks)
 	    * !!PED_BE16_TO_CPU(label->nsect) == 0)
@@ -709,7 +705,7 @@ static PedAlignment*
 sun_get_partition_alignment(const PedDisk *disk)
 {
 	PedSector block =
-		disk->dev->hw_geom.sectors * disk->dev->hw_geom.heads;
+		disk->dev->bios_geom.sectors * disk->dev->bios_geom.heads;
 
         return ped_alignment_new(0, block);
 }
-- 
1.7.10.4




More information about the parted-devel mailing list