Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 104351

Summary: sys-apps/coreutils - df shows negative numbers for cifs mounted dirs
Product: Gentoo Linux Reporter: Toralf Förster <toralf>
Component: Current packagesAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED UPSTREAM    
Severity: normal    
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 65644, 105368    
Bug Blocks:    

Description Toralf Förster gentoo-dev 2005-08-31 00:48:58 UTC
And in addition the reported numbers of used blocks are different.

Here the results for a file system mounted as smbfs:

tfoerste@n22 ~/workspace/misc $ df /mnt/GSA/
Filesystem           1K-blocks      Used Available Use% Mounted on
//foo.bar/    660653296 -73786976293836709276 1662150484 101% /mnt/GSA
tfoerste@n22 ~/workspace/misc $ df -m /mnt/GSA/
Filesystem           1M-blocks      Used Available Use% Mounted on
//foo.bar/       645170 -72057594036949912   1623194 101% /mnt/GSA

And now the same - remounted ans cifs:

tfoerste@n22 ~/workspace/misc $ df /mnt/GSA/
Filesystem           1K-blocks      Used Available Use% Mounted on
//foo.bar/    660733952 -18446744072707932160 1662353408 101% /mnt/GSA
tfoerste@n22 ~/workspace/misc $ df -m /mnt/GSA/
Filesystem           1M-blocks      Used Available Use% Mounted on
//foo.bar/       645248 -18014398508503872   1623360 101% /mnt/GSA

Both have wrong negative results, but they differs, too !


Reproducible: Always
Steps to Reproduce:
1.
2.
3.




Portage 2.0.51.22-r2 (default-linux/x86/2005.0, gcc-3.3.5-20050130,
glibc-2.3.5-r1, 2.6.12-gentoo-r9 i686)
=================================================================
System uname: 2.6.12-gentoo-r9 i686 Intel(R) Pentium(R) M processor 1700MHz
Gentoo Base System version 1.6.13
ccache version 2.3 [enabled]
dev-lang/python:     2.3.5
sys-apps/sandbox:    1.2.12
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6
sys-devel/binutils:  2.15.92.0.2-r10
sys-devel/libtool:   1.5.18-r1
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=pentium3 -fomit-frame-pointer -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.4/env
/usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3/share/config
/usr/lib/X11/xkb /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-O2 -march=pentium3 -fomit-frame-pointer -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig ccache distlocks sandbox sfperms strict"
GENTOO_MIRRORS="ftp://pandemonium.tiscali.de/pub/gentoo/
http://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/
http://mir.zyrianes.net/gentoo/
http://mirrors.sec.informatik.tu-darmstadt.de/gentoo/ www.ibiblio.org/"
LINGUAS="de en"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.de.gentoo.org/gentoo-portage"
USE="x86 X acpi aim alsa apache2 arts avi berkdb bitmap-fonts browserplugin
cardbus cddb cdparanoia crypt cups curl dvd dvdr dvdread eds emboss encode
ethereal fam font-server foomaticdb fortran gd gdbm gif gpm gstreamer gtk gtk2
imagemagick imlib innodb ipv6 jai java javascript jimi jpeg junit kde libg++
libwww live mad mbox mikmod mmx mmxext mng motif mp3 mpeg mysql nagios-dns
nagios-ntp nagios-ping nagios-s ncurses network nls no-old-linux ogg oggvorbis
opengl oss pam pcmcia pdflib perl png python qt quicktime readline real samba
sdl slp smime snmp spell sse sse2 ssl subversion svg tcltk tcpd tiff truetype
truetype-fonts type1-fonts usb userlocales vorbis webdav wifi xanim xfs xine
xml2 xmms xv zlib linguas_de linguas_en userland_GNU kernel_linux elibc_glibc"
Unset:  ASFLAGS, CTARGET, LANG, LC_ALL, LDFLAGS, PORTDIR_OVERLAY
Comment 1 SpanKY gentoo-dev 2005-08-31 10:24:27 UTC
df works for me with smbfs/cifs ...

you didnt say what the filesizes are *supposed* to report ... also, what version
of coreutils do you have exactly ?
Comment 2 Toralf Förster gentoo-dev 2005-09-01 03:43:32 UTC
windows says: "1.685.674.000.384 bytes free" (1,5 TB )

cygwin under windows reports with df -m:

$ df -m /cygdrive/g/
Filesystem           1M-blocks      Used Available Use% Mounted on
g:                      645248 -18014398508519648   1607584 101% /cygdrive/g
Comment 3 SpanKY gentoo-dev 2005-09-01 06:13:49 UTC
this has come up before ... i'll see if i can make a patch for you to test
Comment 4 Toralf Förster gentoo-dev 2005-10-11 01:47:56 UTC
See https://bugs.gentoo.org/show_bug.cgi?id=105368#c4
Comment 5 Jakub Moc (RETIRED) gentoo-dev 2005-10-11 01:52:05 UTC
Please, don't reassign bugs back to bug-wranglers. 
Comment 6 Toralf Förster gentoo-dev 2006-01-06 04:59:38 UTC
>this has come up before ... i'll see if i can make a patch for you to test

Hi,
anything ready for testing ?
Comment 7 Toralf Förster gentoo-dev 2006-01-25 01:03:08 UTC
Got this from Paul Eggert <eggert@cs.ucla.edu> today regarding wrong numbers from df showing disk usage of a cifs mounted dir under kernel 2.6.15-gentoo-r1:

Toralf F
Comment 8 Toralf Förster gentoo-dev 2006-01-25 01:03:08 UTC
Got this from Paul Eggert <eggert@cs.ucla.edu> today regarding wrong numbers from df showing disk usage of a cifs mounted dir under kernel 2.6.15-gentoo-r1:

Toralf Förster <toralf.foerster@gmx.de> writes:

> $ strace df -m /mnt/GSA/
> ...
> statfs64("/mnt/GSA", 84, {f_type=0xff534d42, f_bsize=1024, 
> f_blocks=2245328896, f_bfree=2737373184, f_bavail=2737373184, f_files=0, 
> f_ffree=0, f_fsid={0, 0}, f_namelen=4096, f_frsize=1024}) = 0
> ...
> Filesystem           1M-blocks      Used Available Use% Mounted on
> //ehngsa.ibm.com/      2192704 -18014398509001472   2673216 101% /mnt/GSA

Thanks for reporting that.  statfs64 is claiming that your file system
has more available than total blocks.  Clearly this is a bug in your
file system or kernel or something like that, but 'df' should output
more-useful information even when there's a bug elsewhere.

I think the output should look like this:

Filesystem           1M-blocks      Used Available Use% Mounted on
//ehngsa.ibm.com/      2192704   -480512   2673216   -  /mnt/GSA

I've installed the following patch to CVS coreutils, so that it
generates this output.

2006-01-24  Paul Eggert  <eggert@cs.ucla.edu>

        * 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.

--- src/df.c.~1.171.~   2005-12-28 02:22:41.000000000 -0800
+++ src/df.c    2006-01-24 15:22:59.000000000 -0800
@@ -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 *
       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 ",
Comment 9 SpanKY gentoo-dev 2006-01-25 18:02:12 UTC
then i'm gonna consider this fixed as the issue will be in the next release of coreutils

thanks for doing the hard work and making me look like a slacker :)