[parted-devel] [PATCH 1/2] parted: factor out disk geometry printing into separate function
Petr Uzel
petr.uzel at suse.cz
Fri Apr 16 07:58:12 UTC 2010
* parted/parted.c (_print_disk_geometry): New function.
(do_print): Use _print_disk_geometry.
---
parted/parted.c | 40 +++++++++++++++++++++++-----------------
1 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/parted/parted.c b/parted/parted.c
index ae6fd6f..1de502b 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1381,6 +1381,27 @@ partition_print (PedPartition* part)
return 1;
}
+static void
+_print_disk_geometry (PedDevice *dev)
+{
+ PED_ASSERT (dev != NULL, return);
+ PedCHSGeometry* chs = &dev->bios_geom;
+ char* cyl_size = ped_unit_format_custom (dev,
+ chs->heads * chs->sectors,
+ PED_UNIT_KILOBYTE);
+
+ if (opt_machine_mode) {
+ printf ("%d:%d:%d:%s;\n",
+ chs->cylinders, chs->heads, chs->sectors, cyl_size);
+ } else {
+ printf (_("BIOS cylinder,head,sector geometry: %d,%d,%d. "
+ "Each cylinder is %s.\n"),
+ chs->cylinders, chs->heads, chs->sectors, cyl_size);
+ }
+
+ free (cyl_size);
+}
+
static int
do_print (PedDevice** dev)
{
@@ -1510,23 +1531,8 @@ do_print (PedDevice** dev)
free (end);
if (ped_unit_get_default () == PED_UNIT_CHS
- || ped_unit_get_default () == PED_UNIT_CYLINDER) {
- PedCHSGeometry* chs = &(*dev)->bios_geom;
- char* cyl_size = ped_unit_format_custom (*dev,
- chs->heads * chs->sectors,
- PED_UNIT_KILOBYTE);
-
- if (opt_machine_mode) {
- printf ("%d:%d:%d:%s;\n",
- chs->cylinders, chs->heads, chs->sectors, cyl_size);
- } else {
- printf (_("BIOS cylinder,head,sector geometry: %d,%d,%d. "
- "Each cylinder is %s.\n"),
- chs->cylinders, chs->heads, chs->sectors, cyl_size);
- }
-
- free (cyl_size);
- }
+ || ped_unit_get_default () == PED_UNIT_CYLINDER)
+ _print_disk_geometry (*dev);
if (!opt_machine_mode) {
printf (_("Partition Table: %s\n"), disk->type->name);
--
1.6.4.2
More information about the parted-devel
mailing list