]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(show_dev): If the file system claims to have more available than total
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 24 Jan 2006 23:30:46 +0000 (23:30 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 24 Jan 2006 23:30:46 +0000 (23:30 +0000)
blocks, report the number of used blocks as being total - available
(a negative number) rather than as garbage.

ChangeLog
src/df.c

index f6f2936871b7fcd1aa03fd61e00af9b2241d3b0e..69c5ba3e19783da9af8c2e5ed9a0335e2f15f2d7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,14 @@
-2006-01-24  Jim Meyering  <jim@meyering.net>
+2006-01-24  Paul Eggert  <eggert@cs.ucla.edu>
 
        * Version 6.0-cvs.
 
+       * src/df.c (show_dev): If the file system claims to have
+       more available than total blocks, report the number of used
+       blocks as being total - available (a negative number) rather
+       than as garbage.  Problem reported by Toralf Foerster.
+
+2006-01-24  Jim Meyering  <jim@meyering.net>
+
        * src/tail.c (tail_forever): Don't exit-nonzero when an attempt
        to put a regular file in O_NONBLOCK mode fails with EPERM.
        That happens on Linux when using tail -f on a file with the
index 0286f8a2d0ec8a924bf36a12c4fdc47b3816bbcf..2eece1b46f59f18721a300f29b4212b39602fca7 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -1,5 +1,5 @@
 /* df - summarize free disk space
-   Copyright (C) 91, 1995-2005 Free Software Foundation, Inc.
+   Copyright (C) 91, 1995-2006 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -231,15 +231,15 @@ excluded_fstype (const char *fstype)
 /* Like human_readable (N, BUF, human_output_opts, INPUT_UNITS, OUTPUT_UNITS),
    except:
 
-    - Return "-" if N is -1,
-    - If NEGATIVE is 1 then N represents a negative number,
-      expressed in two's complement.  */
+    - If NEGATIVE, then N represents a negative number,
+      expressed in two's complement.
+    - Otherwise, return "-" if N is UINTMAX_MAX.  */
 
 static char const *
 df_readable (bool negative, uintmax_t n, char *buf,
             uintmax_t input_units, uintmax_t output_units)
 {
-  if (n == UINTMAX_MAX)
+  if (n == UINTMAX_MAX && !negative)
     return "-";
   else
     {
@@ -357,20 +357,17 @@ show_dev (char const *disk, char const *mount_point,
       output_units = output_block_size;
       total = fsu.fsu_blocks;
       available = fsu.fsu_bavail;
-      negate_available = fsu.fsu_bavail_top_bit_set;
+      negate_available = (fsu.fsu_bavail_top_bit_set
+                         & (available != UINTMAX_MAX));
       available_to_root = fsu.fsu_bfree;
     }
 
-  used = -1;
+  used = UINTMAX_MAX;
   negate_used = false;
   if (total != UINTMAX_MAX && available_to_root != UINTMAX_MAX)
     {
       used = total - available_to_root;
-      if (total < available_to_root)
-       {
-         negate_used = true;
-         used = - used;
-       }
+      negate_used = (total < available_to_root);
     }
 
   printf (" %*s %*s %*s ",