[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fwd: Bug#141873: parted: Size column in "parted print" desired
From: |
Timshel Knoll |
Subject: |
Fwd: Bug#141873: parted: Size column in "parted print" desired |
Date: |
Wed, 11 Sep 2002 02:06:41 +1000 |
User-agent: |
KMail/1.4.3 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi Andrew,
I should have sent you this _ages_ ago - it's another patch for a size
column in the "print" output. This one's better though since it makes
the display more human-readable by sticking a "M", "G" or "T" on to
specify mega, giga or terabytes, so takes up less screen real estate.
It might actually be better if it displayed stuff to 1 decimal place,
eg. in Branden's output there is:
6 1427.682 3474.997 1G logical ext2
That's actually just under 2 gigs, but shows up as 1 in the display due
to rounding. 1 decimal place would be nice, giving 1.9G ... if I have
some inspiration and time in the next couple of days I'll try to fix it
to do just that ...
Cheers,
Timshel
- ---------- Forwarded Message ----------
Subject: Bug#141873: parted: Size column in "parted print" desired
Date: Mon, 8 Apr 2002 18:00:23 -0500
From: Branden Robinson <address@hidden>
To: address@hidden, address@hidden
Cc: Branden Robinson <address@hidden>
Package: parted
Version: 1.4.24-3
Severity: wishlist
Tags: patch
Hi,
The pgi package creates installers with a text-mode interface
that uses parted for partitioning. We here at Progeny thought
would be nice if parted's "print" function would report the size
of each partition along with the other information it displays.
We thought it would be even nicer if the reported size was made
"human-readable" by reporting the size in the most appropriate
units: terabytes, gigabytes, megabytes, or kilobytes.
And we thought it would be nicest of all if we supplied you with
a patch to implement this.
This patch is tested and appears to work hunky-dory.
# parted /dev/hda print
Disk geometry for /dev/hda: 0.000-19092.937 megabytes
Disk label type: msdos
Minor Start End Size Type Filesystem Flags
1 0.031 274.548 274M primary ext2 boot
2 274.548 400.056 125M primary linux-swap
3 400.056 19092.875 18G extended lba
5 400.087 1427.651 1G logical ext2
6 1427.682 3474.997 1G logical ext2
7 3475.028 16088.532 12G logical ext2
8 16088.563 19092.875 2G logical ext2
diff -urN parted-1.4.24/parted/parted.c
parted-1.4.24.print_size/parted/parted.c ---
parted-1.4.24/parted/parted.c Sun Sep 30 02:45:38 2001
+++ parted-1.4.24.print_size/parted/parted.c Mon Apr 8 17:40:27 2002
@@ -744,6 +744,8 @@
int first_flag;
int has_extended;
int has_name;
+ int sect_size, unit_size;
+ char unit;
disk = ped_disk_open (*dev);
if (!disk)
@@ -759,7 +761,7 @@
has_name = ped_disk_type_check_feature (disk->type,
PED_DISK_TYPE_PARTITION_NAME);
- - printf (_("Minor Start End "));
+ printf (_("Minor Start End Size "));
if (has_extended)
printf (_("Type "));
printf (_("Filesystem "));
@@ -781,6 +783,24 @@
printf ("%10.3f %10.3f ",
(int) part->geom.start * 1.0 / MEGABYTE_SECTORS,
(int) part->geom.end * 1.0 / MEGABYTE_SECTORS);
+
+ sect_size = (part->geom.end - part->geom.start) * 1.0 /
MEGABYTE_SECTORS; +
+ if (sect_size > (1024.0 * 1024.0)) {
+ unit_size = (int) sect_size / (1024.0 * 1024.0);
+ unit = 'T';
+ } else if (sect_size > 1024.0) {
+ unit_size = (int) sect_size / 1024.0;
+ unit = 'G';
+ } else if (sect_size > 1.0) {
+ unit_size = (int) sect_size;
+ unit = 'M';
+ } else {
+ unit_size = (int) sect_size * 1024.0;
+ unit = 'k';
+ }
+
+ printf ("%4d%c ", unit_size, unit);
if (has_extended)
printf ("%-9s ",
- --
Branden Robinson | GPG signed/encrypted mail welcome
address@hidden | 1024D/9C0BCBFB
Consultant | D5F6 D4C9 E25B 3D37 068C
Progeny Linux Systems | 72E8 0F42 191A 9C0B CBFB
- -------------------------------------------------------
- --
Timshel Knoll <address@hidden>, Debian email: <address@hidden>
Debian GNU/Linux developer: http://people.debian.org/~timshel/
GnuPG public key: finger address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE9fhiRXfqTkd4+iqcRAmzIAJ40p5eKDqBq65pVAKDEYIwrIZoAcwCfSGUh
sq0KChzMGjUEAJuOEXxYlFU=
=3Jj7
-----END PGP SIGNATURE-----
- Fwd: Bug#141873: parted: Size column in "parted print" desired,
Timshel Knoll <=