Subject: df reports negative number of total blocks
To: None <current-users@netbsd.org>
From: Henry G. Juengst <juengst@boss1.physik.uni-bonn.de>
List: current-users
Date: 09/20/1994 14:06:27
At the moment I have mounted a big disk (ok, never too big;-) on my system
(NetBSD-1.0 beta) via NFS. Df reports a negativ number of total and used
blocks:

Filesystem     512-blocks    Used   Avail Capacity  Mounted on
boss4:/data      -3154532 -3995528  840996    84%    /saphir/data

Because the total number of blocks and the used blocks can not become
negativ I would apply the following patch in df(function prtstat):
---------------------------------------------------------------------------
*** /usr/src/bin/df/df.c.orig   Mon Jun 13 12:00:19 1994
--- /usr/src/bin/df/df.c        Tue Sep 20 13:33:41 1994
***************
*** 192,198 ****
  {
        static int headerlen, timesthrough;
        static char *header;
!       long used, availblks, inodes;
  
        if (maxwidth < 11)
                maxwidth = 11;
--- 192,198 ----
  {
        static int headerlen, timesthrough;
        static char *header;
!       unsigned long used, availblks, inodes;
  
        if (maxwidth < 11)
                maxwidth = 11;
---------------------------------------------------------------------------

In /sys/sys/mount.h(struct statfs) f_bsize, f_blocks, f_bfree etc. are
long instead of unsigned long. That should also be changed to get positiv
numbers of blocks if the disk is large (>= 2^31 bytes capacity). Who needs
negative number of blocks ? It is enough that a statement of account can
be negative. :-|

The final result will be:
Filesystem     512-blocks    Used   Avail Capacity  Mounted on
boss4:/data       5234076 4393080  840996    84%    /saphir/data

Another problem in statfs: it could be very useful for the future to change
the short f_flags in struct statfs (copy of mount flags) into unsigned long
f_flags before the final release of NetBSD 1.0 will be published. There are
already 16 bits which are copied into this short f_flags. At the moment it
is impossible to add another bit.

Henry

-- 
juengst@saph2.physik.uni-bonn.de   [131.220.221.12]  (internet)
juengst@boss1.physik.uni-bonn.de   [131.220.221.30]
saph2::juengst                     [13.259]          (decnet)

Any opinions in this mail are my own.