bug-hurd
[Top][All Lists]
Advanced

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

Fix statfs


From: Mark Kettenis
Subject: Fix statfs
Date: Sat, 9 Jun 2001 13:33:01 +0200

The way the ext2fs and ufs file system calculate the number of
available blocks can yield a negative number.  Since fsblkcont_t is an
unsigned type this causes some interesting output from df, when your
filesystem is clogging up.

Roland, OK to check thus in?

Mark


Index: ext2fs/ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

        * inode.c (diskfs_set_statfs): If number of free blocks is less
        than the number of reserved blocks, set the number of available
        blocks to 0.

Index: ufs/ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

        * inode.c (diskfs_set_statfs): If number of free blocks is less
        than the number of reserved blocks, set the number of available
        blocks to 0.

Index: ext2fs/inode.c
===================================================================
RCS file: /home/cvs/hurd/ext2fs/inode.c,v
retrieving revision 1.54
diff -u -p -r1.54 inode.c
--- ext2fs/inode.c 2001/01/07 17:03:55 1.54
+++ ext2fs/inode.c 2001/06/09 11:28:05
@@ -1,6 +1,6 @@
 /* Inode management routines
 
-   Copyright (C) 1994,95,96,97,98,99,2000 Free Software Foundation, Inc.
+   Copyright (C) 1994,95,96,97,98,99,2000,01 Free Software Foundation, Inc.
 
    Converted for ext2fs by Miles Bader <miles@gnu.org>
 
@@ -618,6 +618,8 @@ diskfs_set_statfs (struct statfs *st)
   st->f_blocks = sblock->s_blocks_count;
   st->f_bfree = sblock->s_free_blocks_count;
   st->f_bavail = st->f_bfree - sblock->s_r_blocks_count;
+  if (st->f_bfree < sblock->s_r_blocks_count)
+    st->f_bavail = 0;
   st->f_files = sblock->s_inodes_count;
   st->f_ffree = sblock->s_free_inodes_count;
   st->f_fsid = getpid ();

Index: ufs/inode.c
===================================================================
RCS file: /home/cvs/hurd/ufs/inode.c,v
retrieving revision 1.54
diff -u -p -r1.54 inode.c
--- ufs/inode.c 2001/01/08 22:33:11 1.54
+++ ufs/inode.c 2001/06/09 11:28:07
@@ -1,5 +1,5 @@
 /* Inode management routines
-   Copyright (C) 1994,95,96,97,98,2000 Free Software Foundation, Inc.
+   Copyright (C) 1994,95,96,97,98,2000,01 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
@@ -519,6 +519,8 @@ diskfs_set_statfs (struct statfs *st)
                 + sblock->fs_cstotal.cs_nffree);
   st->f_bavail = ((sblock->fs_dsize * (100 - sblock->fs_minfree) / 100)
                  - (sblock->fs_dsize - st->f_bfree));
+  if (st->f_bfree < ((sblock->fs_dsize * (100 - sblock->fs_minfree) / 100)))
+    st->f_bavail = 0;
   st->f_files = sblock->fs_ncg * sblock->fs_ipg - 2; /* not 0 or 1 */
   st->f_ffree = sblock->fs_cstotal.cs_nifree;
   st->f_fsid = getpid ();



reply via email to

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