Source-Changes-HG archive

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

[src/trunk]: src/sbin/newfs various calcipg() fixes:



details:   https://anonhg.NetBSD.org/src/rev/5002ba6ddf39
branches:  trunk
changeset: 514166:5002ba6ddf39
user:      lukem <lukem%NetBSD.org@localhost>
date:      Sat Aug 25 01:42:46 2001 +0000

description:
various calcipg() fixes:
- fix round-off errors when determining the number of inodes per group,
  which often resulted in the total number of inodes in the file system
  being less than what the density asked for.
  now you might get more inodes than requested for a given density,
  rather than less.
- if the new inodes/group is <= 0, ensure that it's at least 1, preventing
  a possible division by zero or other wacky problems
- use long long instead of quad_t

diffstat:

 sbin/newfs/mkfs.c |  15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diffs (50 lines):

diff -r b3e12188db70 -r 5002ba6ddf39 sbin/newfs/mkfs.c
--- a/sbin/newfs/mkfs.c Sat Aug 25 01:41:17 2001 +0000
+++ b/sbin/newfs/mkfs.c Sat Aug 25 01:42:46 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkfs.c,v 1.51 2001/08/17 02:18:48 lukem Exp $  */
+/*     $NetBSD: mkfs.c,v 1.52 2001/08/25 01:42:46 lukem Exp $  */
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c     8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.51 2001/08/17 02:18:48 lukem Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.52 2001/08/25 01:42:46 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -124,7 +124,7 @@
        int32_t mapcramped, inodecramped;
        int32_t postblsize, rotblsize, totalsbsize;
        time_t utime;
-       quad_t sizepb;
+       long long sizepb;
        char *writebuf2;                /* dynamic buffer */
        int nprintcols, printcolwidth;
 
@@ -989,9 +989,6 @@
        int i;
        int32_t ipg, new_ipg, ncg, ncyl;
        off_t usedb;
-#if __GNUC__ /* XXX work around gcc 2.7.2 initialization bug */
-       (void)&usedb;
-#endif
 
        /*
         * Prepare to scale by fssize / (number of sectors in cylinder groups).
@@ -1006,8 +1003,10 @@
        for (i = 0; i < 10; i++) {
                usedb = (sblock.fs_iblkno + ipg / INOPF(&sblock))
                        * NSPF(&sblock) * (off_t)sectorsize;
-               new_ipg = (cylpg * (quad_t)bpcg - usedb) / density * fssize
-                         / ncg / secpercyl / cylpg;
+               new_ipg = (cylpg * (long long)bpcg - usedb) /
+                   ((long long)density * fssize / (ncg * secpercyl * cylpg));
+               if (new_ipg <= 0)
+                       new_ipg = 1;            /* ensure ipg > 0 */
                new_ipg = roundup(new_ipg, INOPB(&sblock));
                if (new_ipg == ipg)
                        break;



Home | Main Index | Thread Index | Old Index