Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/pkg_install/add Fix a minor bug in the estimation o...



details:   https://anonhg.NetBSD.org/src/rev/9e48fc292508
branches:  trunk
changeset: 580029:9e48fc292508
user:      dmcmahill <dmcmahill%NetBSD.org@localhost>
date:      Tue Apr 05 16:37:50 2005 +0000

description:
Fix a minor bug in the estimation of required disk space.  In particular
make sure we use a data type which is big enough.  This fixes a problem
where pkg_add-ing of a binary package which is between 512 Mb and 1 Gb
failes because the estimated required disk space is negative due to over
flowing in the calculation

diffstat:

 usr.sbin/pkg_install/add/perform.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (41 lines):

diff -r c45544127cc2 -r 9e48fc292508 usr.sbin/pkg_install/add/perform.c
--- a/usr.sbin/pkg_install/add/perform.c        Tue Apr 05 16:29:28 2005 +0000
+++ b/usr.sbin/pkg_install/add/perform.c        Tue Apr 05 16:37:50 2005 +0000
@@ -1,11 +1,11 @@
-/*     $NetBSD: perform.c,v 1.107 2005/03/06 23:40:41 agc Exp $        */
+/*     $NetBSD: perform.c,v 1.108 2005/04/05 16:37:50 dmcmahill Exp $  */
 
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp";
 #else
-__RCSID("$NetBSD: perform.c,v 1.107 2005/03/06 23:40:41 agc Exp $");
+__RCSID("$NetBSD: perform.c,v 1.108 2005/04/05 16:37:50 dmcmahill Exp $");
 #endif
 #endif
 
@@ -182,6 +182,7 @@
        struct utsname host_uname;
        int     inPlace;
        int     rc;
+       uint64_t needed;
        Boolean is_depoted_pkg = FALSE;
 
        errc = 0;
@@ -302,11 +303,12 @@
                         * compress an average of 75%, so multiply by 4 for good measure.
                         */
 
-                       if (!inPlace && min_free(playpen) < sb.st_size * 4) {
-                               warnx("projected size of %ld bytes exceeds available free space\n"
+                       needed = 4 * (uint64_t) sb.st_size;
+                       if (!inPlace && min_free(playpen) < needed) {
+                               warnx("projected size of %lld bytes exceeds available free space\n"
                                    "in %s. Please set your PKG_TMPDIR variable to point\n"
                                    "to a location with more free space and try again.",
-                                       (long) (sb.st_size * 4), playpen);
+                                       needed, playpen);
                                goto bomb;
                        }
 



Home | Main Index | Thread Index | Old Index