diff options
author | Karel Zak | 2013-08-30 15:47:50 +0200 |
---|---|---|
committer | Karel Zak | 2013-09-16 16:47:09 +0200 |
commit | 9af73f84d0c76511785ba3af68d336498cee5877 (patch) | |
tree | 3b0e046f70b3018b3a3b76f522af207dd40e2779 | |
parent | fdisk: -l refactoring (diff) | |
download | kernel-qcow2-util-linux-9af73f84d0c76511785ba3af68d336498cee5877.tar.gz kernel-qcow2-util-linux-9af73f84d0c76511785ba3af68d336498cee5877.tar.xz kernel-qcow2-util-linux-9af73f84d0c76511785ba3af68d336498cee5877.zip |
fdisk: use fdisk_info() to print geometry
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | fdisks/fdisk.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index dfa249852..3fe7d1906 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -197,41 +197,36 @@ void change_partition_type(struct fdisk_context *cxt) void list_disk_geometry(struct fdisk_context *cxt) { char *id = NULL; - unsigned long long bytes = cxt->total_sectors * cxt->sector_size; - long megabytes = bytes/1000000; - - if (megabytes < 10000) - printf(_("\nDisk %s: %ld MB, %lld bytes"), - cxt->dev_path, megabytes, bytes); - else { - long hectomega = (megabytes + 50) / 100; - printf(_("\nDisk %s: %ld.%ld GB, %llu bytes"), - cxt->dev_path, hectomega / 10, hectomega % 10, bytes); - } - printf(_(", %llu sectors\n"), cxt->total_sectors); + uint64_t bytes = cxt->total_sectors * cxt->sector_size; + char *strsz = size_to_human_string(SIZE_SUFFIX_SPACE + | SIZE_SUFFIX_3LETTER, bytes); + + fdisk_info(cxt, _("\nDisk %s: %s, %llu bytes, %llu sectors"), + cxt->dev_path, strsz, bytes, cxt->total_sectors); + free(strsz); if (fdisk_require_geometry(cxt)) - printf(_("Geometry: %d heads, %llu sectors/track, %llu cylinders\n"), - cxt->geom.heads, cxt->geom.sectors, cxt->geom.cylinders); + fdisk_info(cxt, _("Geometry: %d heads, %llu sectors/track, %llu cylinders"), + cxt->geom.heads, cxt->geom.sectors, cxt->geom.cylinders); - printf(_("Units = %s of %d * %ld = %ld bytes\n"), + fdisk_info(cxt, _("Units: %s of %d * %ld = %ld bytes"), fdisk_context_get_unit(cxt, PLURAL), fdisk_context_get_units_per_sector(cxt), cxt->sector_size, fdisk_context_get_units_per_sector(cxt) * cxt->sector_size); - printf(_("Sector size (logical/physical): %lu bytes / %lu bytes\n"), + fdisk_info(cxt, _("Sector size (logical/physical): %lu bytes / %lu bytes"), cxt->sector_size, cxt->phy_sector_size); - printf(_("I/O size (minimum/optimal): %lu bytes / %lu bytes\n"), + fdisk_info(cxt, _("I/O size (minimum/optimal): %lu bytes / %lu bytes"), cxt->min_io_size, cxt->io_size); if (cxt->alignment_offset) - printf(_("Alignment offset: %lu bytes\n"), cxt->alignment_offset); + fdisk_info(cxt, _("Alignment offset: %lu bytes"), + cxt->alignment_offset); if (fdisk_dev_has_disklabel(cxt)) - printf(_("Disk label type: %s\n"), cxt->label->name); + fdisk_info(cxt, _("Disk label type: %s"), cxt->label->name); if (fdisk_get_disklabel_id(cxt, &id) == 0 && id) - printf(_("Disk identifier: %s\n"), id); - printf("\n"); + fdisk_info(cxt, _("Disk identifier: %s"), id); } |