[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Device names too long for df
From: |
Thomas Stewart |
Subject: |
Device names too long for df |
Date: |
Sun, 22 Feb 2004 04:34:40 +0000 |
User-agent: |
KMail/1.6 |
Hi,
I recently started using udev and have used devfs in the past. When these are
used the long internal kernel names for the block devices are shown, e.g.
"/dev/ide/host0/bus0/target0/lun0/part1" instead of "/dev/hda1". These long
names show up in df as well.
Once more than half a dozen devices are in the system, the readout is less easy
to read, e.g.
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/ide/host0/bus0/target0/lun0/part5
19G 6.8G 12G 38% /
/dev/ide/host0/bus0/target0/lun0/part6
82G 60G 22G 74% /mnt/store
I have made a patch to add a --wide (-w) option to df, so that the
"Filesystem" column has more space.
Here is an example of its output:-
(use fixed width font to see columns line up).
$ ./df -w -h
Filesystem Size Used Avail Use% Mounted on
/dev/ide/host0/bus0/target0/lun0/part5 19G 6.8G 12G 38% /
/dev/ide/host0/bus0/target0/lun0/part6 82G 60G 22G 74% /mnt/store
It has enough space for scsi and part > 9, and does not break the other options.
Patch as follows:-
--- coreutils-5.2.0/src/df.c.orig 2004-02-22 02:29:02.000000000 +0000
+++ coreutils-5.2.0/src/df.c 2004-02-22 03:48:30.000000000 +0000
@@ -111,6 +111,9 @@
/* If nonzero, print filesystem type as well. */
static int print_type;
+/* Print in wide mode, usefull for long device entries, eg devfs or udev */
+static int wide;
+
/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
enum
@@ -135,6 +138,7 @@
{"no-sync", no_argument, NULL, NO_SYNC_OPTION},
{"type", required_argument, NULL, 't'},
{"exclude-type", required_argument, NULL, 'x'},
+ {"wide", no_argument, NULL, 'w'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0}
@@ -145,11 +149,13 @@
{
char buf[MAX (LONGEST_HUMAN_READABLE + 1, INT_BUFSIZE_BOUND (uintmax_t))];
- if (print_type)
+ if (print_type) {
fputs (_("Filesystem Type"), stdout);
- else
+ } else {
fputs (_("Filesystem "), stdout);
-
+ if (wide == true)
+ fputs (_(" "), stdout);
+ }
if (inode_format)
printf (_(" Inodes IUsed IFree IUse%%"));
else if (human_output_opts & human_autoscale)
@@ -325,8 +331,10 @@
}
else
{
- if ((int) strlen (disk) > 20 && !posix_format)
+ if ((int) strlen (disk) > 20 && !posix_format && !wide)
printf ("%s\n%20s", disk, "");
+ else if (wide && !posix_format)
+ printf ("%-40s", disk);
else
printf ("%-20s", disk);
}
@@ -752,6 +760,7 @@
-T, --print-type print filesystem type\n\
-x, --exclude-type=TYPE limit listing to filesystems not of type TYPE\n\
-v (ignored)\n\
+ -w, --wide print in wide format, for long device entries\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
@@ -784,6 +793,7 @@
inode_format = 0;
show_all_fs = 0;
show_listed_fs = 0;
+ wide = false;
human_output_opts = human_options (getenv ("DF_BLOCK_SIZE"), false,
&output_block_size);
@@ -792,7 +802,7 @@
posix_format = 0;
exit_status = 0;
- while ((c = getopt_long (argc, argv, "aB:iF:hHklmPTt:vx:", long_options,
NULL))
+ while ((c = getopt_long (argc, argv, "aB:iF:hHklmPTt:vx:w", long_options,
NULL))
!= -1)
{
switch (c)
@@ -852,6 +862,9 @@
case 'x':
add_excluded_fs_type (optarg);
break;
+ case 'w':
+ wide = true;
+ break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
Regards
--
Tom
PGP Fingerprint [DCCD 7DCB A74A 3E3B 60D5 DF4C FC1D 1ECA 68A7 0C48]
PGP Publickey [http://www.stewarts.org.uk/public-key.asc]
PGP ID [0x68A70C48]
- Device names too long for df,
Thomas Stewart <=