I guess this is a better address to send patches to instead of
[EMAIL PROTECTED] My apologies to whomever reads that account...
Wil
--
W. Reilly Cooley [EMAIL PROTECTED]
The LNX System: Linux/GNU for a 2U case. http://lnxs.org
---------- Forwarded message ----------
Date: Mon, 31 Jan 2000 12:38:00 -0800 (PST)
From: Wil Cooley <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: fileutils - df --histogram patch
I made this little patch because I get df output in my cron reports, and I
get lots of cron reports, so having a visual report is helpful. Anyway,
it adds an '--histogram' option to df. I'm not sure if it's unnecessary
bells & whistles or a genuinely useful feature. Anyway, I thought I'd
offer it and let you decide.
Wil
--
W. Reilly Cooley [EMAIL PROTECTED]
The LNX System: Linux for a 2U case. http://lnxs.org
diff -urN fileutils-4.0/doc/fileutils.texi fileutils-4.0-work/doc/fileutils.texi
--- fileutils-4.0/doc/fileutils.texi Sun Nov 8 08:12:07 1998
+++ fileutils-4.0-work/doc/fileutils.texi Mon Jan 31 11:55:57 2000
@@ -2597,6 +2597,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
diff -urN fileutils-4.0/src/df.c fileutils-4.0-work/src/df.c
--- fileutils-4.0/src/df.c Sat Sep 19 10:09:23 1998
+++ fileutils-4.0-work/src/df.c Mon Jan 31 11:19:33 2000
@@ -17,7 +17,8 @@
/* Written by David MacKenzie <[EMAIL PROTECTED]>.
--human-readable and --megabyte options added by [EMAIL PROTECTED]
- --si and large file support added by [EMAIL PROTECTED] */
+ --si and large file support added by [EMAIL PROTECTED]
+ --histogram added by [EMAIL PROTECTED] */
#include <config.h>
#if HAVE_INTTYPES_H
@@ -71,6 +72,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;
@@ -128,6 +132,7 @@
{"no-sync", no_argument, NULL, CHAR_MAX + 2},
{"type", required_argument, NULL, 't'},
{"exclude-type", required_argument, NULL, 'x'},
+ {"histogram", no_argument, NULL, CHAR_MAX + 4},
{"help", no_argument, &show_help, 1},
{"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
@@ -218,6 +223,8 @@
{
struct fs_usage fsu;
const char *stat_file;
+ double blocks_percent_used; /* Needs to be available outside of previous scope */
+
if (me_remote && show_local_fs)
return;
@@ -306,7 +313,7 @@
char buf[2][LONGEST_HUMAN_READABLE + 1];
char availbuf[LONGEST_HUMAN_READABLE + 2];
char *avail;
- double blocks_percent_used;
+
uintmax_t blocks_used;
if (fsu.fsu_blocks == -1 || fsu.fsu_blocks < fsu.fsu_bfree)
@@ -363,6 +370,22 @@
printf (" %s", mount_point);
}
putchar ('\n');
+
+ if (show_histogram)
+ {
+ int i;
+ printf ("0%% |") ;
+ /* Use 20 chars */
+ for ( i = 1 ; i <= 50 ; i++)
+ {
+ if (blocks_percent_used - (i*2) >= 0)
+ putchar ('#') ;
+ else
+ putchar (' ') ;
+ }
+ printf ("| 100%%\n") ;
+ }
+
}
/* Identify the directory, if any, that device
@@ -589,6 +612,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\
@@ -679,6 +703,9 @@
human_block_size (optarg, 1, &output_block_size);
break;
+ case CHAR_MAX + 4:
+ show_histogram = 1 ;
+ break;
case 'F':
/* Accept -F as a synonym for -t for compatibility with Solaris. */
case 't':