summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1997-09-19 11:13:16 +0000
committerphk <phk@FreeBSD.org>1997-09-19 11:13:16 +0000
commitf6da000c05feb73d9ea67e2f4d2b2f12ca9d7581 (patch)
tree9e2bdf1aff9b377d62fd72283bf97e34adb8d85f
parent45d7b03c300add9741176c7a284d60fd355b6ade (diff)
downloadFreeBSD-src-f6da000c05feb73d9ea67e2f4d2b2f12ca9d7581.zip
FreeBSD-src-f6da000c05feb73d9ea67e2f4d2b2f12ca9d7581.tar.gz
[Regarding the previous patch] This is completely wrong.
1. ffs_alloc() actually allowed writing one block less one frag (normally 7 frags or 7/8 blocks) beyond the limit. 2. freebufspace() gives the free space in frags, but `size' is in bytes, so the change results in approximately `size' fragments too many being reserved. 3. ffs_realloccg() has the same bug but wasn't changed. PR: 3398 Submitted by: bde Eyeballed by: phk
-rw-r--r--sys/ufs/ffs/ffs_alloc.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index 7bb60a5..a4c1173 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ffs_alloc.c 8.18 (Berkeley) 5/26/95
- * $Id: ffs_alloc.c,v 1.35 1997/09/02 20:06:44 bde Exp $
+ * $Id: ffs_alloc.c,v 1.36 1997/09/18 18:07:45 phk Exp $
*/
#include "opt_quota.h"
@@ -117,7 +117,8 @@ ffs_alloc(ip, lbn, bpref, size, cred, bnp)
#endif /* DIAGNOSTIC */
if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0)
goto nospace;
- if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) - size < 0)
+ if (cred->cr_uid != 0 &&
+ freespace(fs, fs->fs_minfree) - numfrags(fs, size) < 0)
goto nospace;
#ifdef QUOTA
error = chkdq(ip, (long)btodb(size), cred, 0);
@@ -187,7 +188,8 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp)
if (cred == NOCRED)
panic("ffs_realloccg: missing credential");
#endif /* DIAGNOSTIC */
- if (cred->cr_uid != 0 && freespace(fs, fs->fs_minfree) <= 0)
+ if (cred->cr_uid != 0 &&
+ freespace(fs, fs->fs_minfree) - numfrags(fs, nsize - osize) < 0)
goto nospace;
if ((bprev = ip->i_db[lbprev]) == 0) {
printf("dev = 0x%lx, bsize = %ld, bprev = %ld, fs = %s\n",
OpenPOWER on IntegriCloud