From: Karel Zak Date: Thu, 2 May 2013 09:49:28 +0000 (+0200) Subject: fdisk: (sun) consolidate 'p'rint output X-Git-Tag: v2.24-rc1~262 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1b1a7b7e25bc33ddebd210ec0571f9326862228;p=thirdparty%2Futil-linux.git fdisk: (sun) consolidate 'p'rint output * use label operation list() * use generic fdisk geometry output for sun * don't duplicate geometry information Signed-off-by: Karel Zak --- diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index 570d61defb..0149d59f0a 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -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; diff --git a/fdisks/fdisksunlabel.c b/fdisks/fdisksunlabel.c index 085ca691c7..39380960d9 100644 --- a/fdisks/fdisksunlabel.c +++ b/fdisks/fdisksunlabel.c @@ -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 : _("")); 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,