]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: (sun) consolidate 'p'rint output
authorKarel Zak <kzak@redhat.com>
Thu, 2 May 2013 09:49:28 +0000 (11:49 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 16 Sep 2013 14:46:53 +0000 (16:46 +0200)
 * use label operation list()
 * use generic fdisk geometry output for sun
 * don't duplicate geometry information

Signed-off-by: Karel Zak <kzak@redhat.com>
fdisks/fdisk.c
fdisks/fdisksunlabel.c

index 570d61defbf53ecb885137e656f453ee094b276b..0149d59f0a42a8327c67160edca3435475a913b3 100644 (file)
@@ -632,9 +632,11 @@ list_disk_geometry(struct fdisk_context *cxt) {
                       cxt->dev_path, hectomega / 10, hectomega % 10, bytes);
        }
        printf(_(", %llu sectors\n"), cxt->total_sectors);
-       if (is_dos_compatible(cxt))
-               printf(_("%d heads, %llu sectors/track, %llu cylinders\n"),
+
+       if (is_dos_compatible(cxt) || fdisk_is_disklabel(cxt, SUN))
+               printf(_("Geometry: %d heads, %llu sectors/track, %llu cylinders\n"),
                       cxt->geom.heads, cxt->geom.sectors, cxt->geom.cylinders);
+
        printf(_("Units = %s of %d * %ld = %ld bytes\n"),
               fdisk_context_get_unit(cxt, PLURAL),
               fdisk_context_get_units_per_sector(cxt),
@@ -656,11 +658,6 @@ list_disk_geometry(struct fdisk_context *cxt) {
 
 static void list_table(struct fdisk_context *cxt, int xtra)
 {
-       if (fdisk_is_disklabel(cxt, SUN)) {
-               sun_list_table(cxt, xtra);
-               return;
-       }
-
        if (fdisk_is_disklabel(cxt, SGI)) {
                sgi_list_table(cxt, xtra);
                return;
index 085ca691c7e7e44583748f0a9306f9b8f671590b..39380960d97da40a9825a5869fc190804dd0d50f 100644 (file)
@@ -673,7 +673,7 @@ static int sun_delete_partition(struct fdisk_context *cxt,
 }
 
 
-void sun_list_table(struct fdisk_context *cxt, int xtra)
+static int sun_list_disklabel(struct fdisk_context *cxt)
 {
        struct sun_disklabel *sunlabel;
        size_t i;
@@ -686,30 +686,20 @@ void sun_list_table(struct fdisk_context *cxt, int xtra)
        sunlabel = self_disklabel(cxt);
 
        w = strlen(cxt->dev_path);
-       if (xtra)
-               printf(
-               _("\nDisk %s (Sun disk label): %u heads, %llu sectors, %d rpm\n"
-               "%llu cylinders, %d alternate cylinders, %d physical cylinders\n"
-               "%d extra sects/cyl, interleave %d:1\n"
-               "Label ID: %s\n"
-               "Volume ID: %s\n"
-               "Units = %s of %d * 512 bytes\n\n"),
-                      cxt->dev_path, cxt->geom.heads, cxt->geom.sectors, be16_to_cpu(sunlabel->rpm),
-                      cxt->geom.cylinders, be16_to_cpu(sunlabel->acyl),
+
+       if (fdisk_context_display_details(cxt))
+               fdisk_info(cxt,
+               _("Label geometry: %d rpm, %d alternate and %d physical cylinders,\n"
+                 "                %d extra sects/cyl, interleave %d:1\n"
+                 "Label ID: %s\n"
+                 "Volume ID: %s"),
+                      be16_to_cpu(sunlabel->rpm),
+                      be16_to_cpu(sunlabel->acyl),
                       be16_to_cpu(sunlabel->pcyl),
                       be16_to_cpu(sunlabel->apc),
                       be16_to_cpu(sunlabel->intrlv),
                       sunlabel->label_id,
-                      sunlabel->vtoc.volume_id,
-                      fdisk_context_get_unit(cxt, PLURAL),
-                      fdisk_context_get_units_per_sector(cxt));
-       else
-               printf(
-       _("\nDisk %s (Sun disk label): %u heads, %llu sectors, %llu cylinders\n"
-       "Units = %s of %d * 512 bytes\n\n"),
-                      cxt->dev_path, cxt->geom.heads, cxt->geom.sectors, cxt->geom.cylinders,
-                      fdisk_context_get_unit(cxt, PLURAL),
-                      fdisk_context_get_units_per_sector(cxt));
+                      *sunlabel->vtoc.volume_id ? sunlabel->vtoc.volume_id : _("<none>"));
 
        printf(_("%*s Flag    Start       End    Blocks   Id  System\n"),
               w + 1, _("Device"));
@@ -736,6 +726,8 @@ void sun_list_table(struct fdisk_context *cxt, int xtra)
                        fdisk_free_parttype(t);
                }
        }
+
+       return 0;
 }
 
 
@@ -946,6 +938,7 @@ const struct fdisk_label_operations sun_operations =
        .write          = sun_write_disklabel,
        .verify         = sun_verify_disklabel,
        .create         = sun_create_disklabel,
+       .list           = sun_list_disklabel,
        .part_add       = sun_add_partition,
        .part_delete    = sun_delete_partition,
        .part_get_type  = sun_get_parttype,