[Parted-maintainers] Bug#141873: marked as done (parted: Size column in "parted print" desired)

Debian Bug Tracking System owner at bugs.debian.org
Sat Sep 17 20:33:20 BST 2005


Your message dated Sat, 17 Sep 2005 21:29:56 +0200
with message-id <20050917212956.1c87cf59.k_guillaume at libertysurf.fr>
and subject line Size column in partition list
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 8 Apr 2002 23:00:57 +0000
>From branden at progeny.com Mon Apr 08 18:00:57 2002
Return-path: <branden at progeny.com>
Received: from woodstock.progeny.com [216.37.46.131] 
	by master.debian.org with esmtp (Exim 3.12 1 (Debian))
	id 16ui89-0002dr-00; Mon, 08 Apr 2002 18:00:57 -0500
Received: from morimoto.progeny.com (morimoto.progeny.com [216.37.46.163])
	by woodstock.progeny.com (Postfix) with ESMTP
	id 88C1B4BF7E; Mon,  8 Apr 2002 17:56:34 -0500 (EST)
Received: by morimoto.progeny.com (Postfix, from userid 10001)
	id CFA4663983; Mon,  8 Apr 2002 18:00:23 -0500 (EST)
Date: Mon, 8 Apr 2002 18:00:23 -0500
From: Branden Robinson <branden at progeny.com>
To: submit at bugs.debian.org, bug-parted at gnu.org
Cc: Branden Robinson <branden at progeny.com>
Subject: parted: Size column in "parted print" desired
Message-ID: <20020408180023.A19455 at morimoto.progeny.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.2.5i
Delivered-To: submit at bugs.debian.org

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
branden at progeny.com       | 1024D/9C0BCBFB
Consultant                | D5F6 D4C9 E25B 3D37 068C
Progeny Linux Systems     | 72E8 0F42 191A 9C0B CBFB

---------------------------------------
Received: (at 141873-done) by bugs.debian.org; 17 Sep 2005 19:29:44 +0000
>From k_guillaume at libertysurf.fr Sat Sep 17 12:29:44 2005
Return-path: <k_guillaume at libertysurf.fr>
Received: from smtp3-g19.free.fr [212.27.42.29] 
	by spohr.debian.org with esmtp (Exim 3.36 1 (Debian))
	id 1EGiNc-0007vk-00; Sat, 17 Sep 2005 12:29:44 -0700
Received: from localhost.localdomain (unknown [81.56.234.180])
	by smtp3-g19.free.fr (Postfix) with SMTP id A090224386
	for <141873-done at bugs.debian.org>; Sat, 17 Sep 2005 21:29:42 +0200 (CEST)
Date: Sat, 17 Sep 2005 21:29:56 +0200
From: "K.G." <k_guillaume at libertysurf.fr>
To: 141873-done at bugs.debian.org
Subject: Size column in partition list
Message-Id: <20050917212956.1c87cf59.k_guillaume at libertysurf.fr>
X-Mailer: Sylpheed version 1.0.4 (GTK+ 1.2.10; i386-pc-linux-gnu)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Delivered-To: 141873-done at bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level: 
X-Spam-Status: No, hits=-8.0 required=4.0 tests=BAYES_00,HAS_PACKAGE 
	autolearn=no version=2.60-bugs.debian.org_2005_01_02

Package: parted
Version: 1.6.23-1

A size column in partition list is available since 1.6.23

Guillaume Knispel



More information about the Parted-maintainers mailing list