#56844 [patch] Add --histogram switch to df.c (documented also)

Package:
coreutils
Source:
coreutils
Description:
GNU core utilities
Submitter:
Date:
2010-05-08 06:27:03 UTC
Severity:
wishlist
#56844#5
Date:
2000-02-02 00:13:17 UTC
From:
To:
 A guy I know wrote a patch to `df' that gives it a histogram switch.
 Here's the tested diff against `fileutils-4.0l-5'.


2000-02-01  W. Reilly Cooley, Esq.  <wcooley@nakedape.cc>

	* doc/fileutils.texi: Document `--histogram' switch.

	* src/df.c (enum): Add HISTOGRAM_OPTION.
	(long_options): Add `histogram'.
	(show_dev): Support `show_histogram'.
	(usage): Display `--histogram' option.
	(main): Add HISTOGRAM_OPTION to switch.
--- doc/fileutils.texi.orig	Wed Dec 15 00:56:55 1999
+++ doc/fileutils.texi	Tue Feb  1 15:22:25 2000
@@ -2924,6 +2924,11 @@
 type ``ignore'' or ``auto'', supported by some operating systems, are
 only included if this option is specified.

+@itemx --histogram
+@opindex --histogram
+@cindex draw a histogram
+Draw a histogram for each filesystem.
+
 @item -h
 @itemx --human-readable
 @opindex -h
--- src/df.c.orig	Thu Dec  9 07:42:04 1999
+++ src/df.c	Tue Feb  1 16:07:11 2000
@@ -17,7 +17,8 @@

 /* Written by David MacKenzie <djm@gnu.ai.mit.edu>.
    --human-readable and --megabyte options added by lm@sgi.com.
-   --si and large file support added by eggert@twinsun.com.  */
+   --si and large file support added by eggert@twinsun.com.
+   --histogram added by wcooley@nakedape.cc. */

 #include <config.h>
 #if HAVE_INTTYPES_H
@@ -75,6 +76,9 @@
    SunOs4.1.3, for one.  It is *not* necessary on Linux.  */
 static int require_sync = 0;

+/* If nonzero, print a histogram for each filesystem. */
+static int show_histogram;
+
 /* Nonzero if errors have occurred. */
 static int exit_status;

@@ -116,7 +120,8 @@
 {
   SYNC_OPTION = CHAR_MAX + 1,
   NO_SYNC_OPTION,
-  BLOCK_SIZE_OPTION
+  BLOCK_SIZE_OPTION,
+  HISTOGRAM_OPTION
 };

 static struct option const long_options[] =
@@ -135,6 +140,7 @@
   {"no-sync", no_argument, NULL, NO_SYNC_OPTION},
   {"type", required_argument, NULL, 't'},
   {"exclude-type", required_argument, NULL, 'x'},
+  {"histogram", no_argument, NULL, HISTOGRAM_OPTION},
   {GETOPT_HELP_OPTION_DECL},
   {GETOPT_VERSION_OPTION_DECL},
   {NULL, 0, NULL, 0}
@@ -397,6 +403,25 @@
       printf (" %s", mount_point);
     }
   putchar ('\n');
+
+  if (show_histogram)
+    {
+      int i;
+      printf ("0%% |") ;
+      /* Use 20 chars */
+      for ( i = 1 ; i <= 50 ; i++)
+	{
+	  double blocks_percent_used = posix_format
+	    ? ceil_percent (used, nonroot_total)
+	    : used * 100.0 / nonroot_total;
+	  if (blocks_percent_used - (i*2) >= 0)
+	    putchar ('#') ;
+	  else
+	    putchar (' ') ;
+	}
+      printf ("| 100%%\n") ;
+    }
+
 }

 /* Identify the directory, if any, that device
@@ -638,6 +663,7 @@
 \n\
   -a, --all             include filesystems having 0 blocks\n\
       --block-size=SIZE use SIZE-byte blocks\n\
+      --histogram       show histogram of percentage\n\
   -h, --human-readable  print sizes in human readable format (e.g., 1K 234M 2G)\n\
   -H, --si              likewise, but use powers of 1000 not 1024\n\
   -i, --inodes          list inode information instead of block usage\n\
@@ -726,6 +752,10 @@

 	case BLOCK_SIZE_OPTION:
 	  human_block_size (optarg, 1, &output_block_size);
+	  break;
+
+	case HISTOGRAM_OPTION:
+	  show_histogram = 1 ;
 	  break;

 	case 'F':

#56844#14
Date:
2010-05-08 06:02:51 UTC
From:
To:
You filed the bug http://bugs.debian.org/56844 in Debian BTS
against the package fileutils. I'm closing it at *unstable*, but it will
remain open for older distributions.

I was unable to find a bug that explains the reason for its removal,
but it appears to have been superceded by coreutils (which is an
essential package) on Mon, 30 Sep 2002 12:24:37 -0400.
  I have decided not forward these bugs to coreutils, since a lot
could have been changed in these 8 years. If your issue is still
reproducible or still valid, do not hesitate to reopen and reassign
it or reply to this email.

Don't hesitate to reply to this mail if you have any question.

Thank you for your contribution to Debian.