diff options
author | bde <bde@FreeBSD.org> | 1996-01-14 18:55:09 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1996-01-14 18:55:09 +0000 |
commit | d1eb245b0ad962a7359d05c2bae5afe05ec72e85 (patch) | |
tree | f11ca3d29cbe8bf42a1caf7f3972f80fb2adbe64 /sys/ufs | |
parent | 167b5f5854e2142bcbd74d1a418f45a8907b6fcd (diff) | |
download | FreeBSD-src-d1eb245b0ad962a7359d05c2bae5afe05ec72e85.zip FreeBSD-src-d1eb245b0ad962a7359d05c2bae5afe05ec72e85.tar.gz |
Partially fixed negative and truncated "Avail" counts in df output.
This fixes PR943.
ffs/ffs_vfsops.c:
ffs_statfs() multiplied by (100 - minfree) as part of calculating the
minfree percentage (complemented in 100%), so with the standard minfree
of 8, it was broken for file systems of size >= 1TB/92 = 11GB. Use the
standard freespace() macro instead. This also fixes a rounding bug (the
"Avail" count was sometimes 1 too small).
ffs/* (not fixed):
The freespace() macro multiplies by minfree, so with the standard
minfree of 8, it is broken for file systems of size >= 1TB/8 = 128GB.
This bug is more serious since it affects block allocation.
ffs/ffs_alloc.c (not fixed):
Ordinary users are sometimes allowed to allocate 1 (partial) block
too many so that the "Avail" count goes negative. E.g., if there is
1 fragment available and the file is fairly large, one more full
block is allocated.
df/df.c:
ufs_df() used/uses essentially the same code as ffs_statfs(), so it
had/has the same bugs.
ufs_df() gratuitously replaced "Avail" counts of < 0 by 0, so it
gave different results for non-mounted file systems in this case.
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ffs/ffs_vfsops.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 203a535..e310708 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_vfsops.c 8.8 (Berkeley) 4/18/94 - * $Id: ffs_vfsops.c,v 1.32 1995/12/17 21:09:35 phk Exp $ + * $Id: ffs_vfsops.c,v 1.33 1996/01/05 18:31:49 wollman Exp $ */ #include "opt_quota.h" @@ -728,8 +728,7 @@ ffs_statfs(mp, sbp, p) sbp->f_blocks = fs->fs_dsize; sbp->f_bfree = fs->fs_cstotal.cs_nbfree * fs->fs_frag + fs->fs_cstotal.cs_nffree; - sbp->f_bavail = (fs->fs_dsize * (100 - fs->fs_minfree) / 100) - - (fs->fs_dsize - sbp->f_bfree); + sbp->f_bavail = freespace(fs, fs->fs_minfree); sbp->f_files = fs->fs_ncg * fs->fs_ipg - ROOTINO; sbp->f_ffree = fs->fs_cstotal.cs_nifree; if (sbp != &mp->mnt_stat) { |