bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Device names too long for df


From: Thomas Stewart
Subject: Re: Device names too long for df
Date: Sun, 22 Feb 2004 23:37:25 +0000
User-agent: KMail/1.6

On Sunday 22 February 2004 20:44, Bob Proulx wrote:
> I don't have a system to test this on but I am curious what the -P
> output looks like in your case.

Just a thought, if you "mkdir -p /dev/ide/host0/bus0/target0/lun0/part1",
and "mount --bind /dev/ide/host0/bus0/target0/lun0/part1 /mnt/point", it 
could emulate the effect.

I just spotted a mistake I made. My patch affected the -P option, tho I think
you saw it before me.

Now with my new patch, the -P output looks as follows:-

$ unalias df
$ /bin/df -P | head -3 # system df from debian
Filesystem         1024-blocks      Used Available Capacity Mounted on
/dev/ide/host0/bus0/target0/lun0/part5  19686804   7107944  11578816      39% /
/dev/ide/host0/bus0/target0/lun0/part6  85610300  63209432  21531112      75% 
/mnt/store

$ ./df -P | head -3 # my new df with patch (same as ^)
Filesystem         1024-blocks      Used Available Capacity Mounted on
/dev/ide/host0/bus0/target0/lun0/part5  19686804   7107944  11578816      39% /
/dev/ide/host0/bus0/target0/lun0/part6  85610300  63209436  21531108      75% 
/mnt/store

$ ./df -P -w | head -3 # my new df with patch (same as ^)
Filesystem         1024-blocks      Used Available Capacity Mounted on
/dev/ide/host0/bus0/target0/lun0/part5  19686804   7107944  11578816      39% /
/dev/ide/host0/bus0/target0/lun0/part6  85610300  63209436  21531108      75% 
/mnt/store


$ ./df -w | head -3 # my new df with patch (showing just -w)
Filesystem                               1K-blocks      Used Available Use% 
Mounted on
/dev/ide/host0/bus0/target0/lun0/part5    19686804   7107952  11578808  39% /
/dev/ide/host0/bus0/target0/lun0/part6    85610300  63209432  21531112  75% 
/mnt/store

Again, use fixed width font to actually see differences, but in short the
patch does not effect -P. If -w and -P are both used then the output
looks like -P.

As a side note, -w has no effect if the -T is used to print the fs type.

> `-P'
> `--portability'
>      Use the POSIX output format.  This is like the default format
>      except for the following:
>
>        1. The information about each filesystem is always printed on
>           exactly one line; a mount device is never put on a line by
>           itself.  This means that if the mount device name is more
>           than 20 characters long (e.g., for some network mounts), the
>           columns are misaligned.

-w is like this, one filesystem to one line, but it aligns all the
columns and headings.

Here is the new patch:-

--- 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 23:09:03.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 && !posix_format)
+       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]







reply via email to

[Prev in Thread] Current Thread [Next in Thread]