[parted-devel] [PATCH 2/2] parted: print disk geometry even if the disk does not have partition table

Petr Uzel petr.uzel at suse.cz
Fri Apr 16 07:58:13 UTC 2010


Disk geometry is independent on the presence of valid partition table.
So parted could print geometry information if called with chs or cyl
as default unit.

* parted/parted.c (do_print): print disk geometry if the disk
does not contain valid partition table and default unit is cyl
or chs.
---
 parted/parted.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/parted/parted.c b/parted/parted.c
index 1de502b..5a6f379 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1427,8 +1427,12 @@ do_print (PedDevice** dev)
         wchar_t*        table_rendered;
 
         disk = ped_disk_new (*dev);
-        if (!disk)
-                goto error;
+        if (!disk) {
+            if (ped_unit_get_default () == PED_UNIT_CHS
+                || ped_unit_get_default () == PED_UNIT_CYLINDER)
+                    _print_disk_geometry (*dev);
+            goto error;
+        }
 
         if (ped_disk_is_flag_available(disk, PED_DISK_CYLINDER_ALIGNMENT))
                 if (!ped_disk_set_flag(disk, PED_DISK_CYLINDER_ALIGNMENT,
-- 
1.6.4.2




More information about the parted-devel mailing list