From b1ba6ab286193ffd014f6e9f67e93554ac27dd69 Mon Sep 17 00:00:00 2001 From: jkh Date: Fri, 14 Oct 1994 05:34:04 +0000 Subject: Fix bug in home directory calculation that I introduced with the free space checking code. Fix the free space checking code, while I'm at it! ;) Thanks to Garrett for spotting the home dir problem. --- usr.sbin/pkg_install/add/perform.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'usr.sbin/pkg_install/add/perform.c') diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c index 45b4c11..0d42b26 100644 --- a/usr.sbin/pkg_install/add/perform.c +++ b/usr.sbin/pkg_install/add/perform.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: perform.c,v 1.8 1994/05/25 17:59:54 asami Exp $"; +static const char *rcsid = "$Id: perform.c,v 1.9 1994/10/04 16:07:43 jkh Exp $"; #endif /* @@ -57,7 +57,6 @@ pkg_do(char *pkg) { char pkg_fullname[FILENAME_MAX]; FILE *cfile; - char *home; int code = 0; PackingList p; struct stat sb; @@ -78,6 +77,11 @@ pkg_do(char *pkg) read_plist(&Plist, stdin); } else { + char home[FILENAME_MAX]; + + if (!getcwd(home, FILENAME_MAX)) + upchuck("getcwd"); + if (pkg[0] == '/') /* full pathname? */ strcpy(pkg_fullname, pkg); else @@ -89,14 +93,14 @@ pkg_do(char *pkg) /* * Apply a crude heuristic to see how much space the package will * take up once it's unpacked. I've noticed that most packages - * compress an average of 65%. + * compress an average of 75%, so multiply by 4 for good measure. */ if (stat(pkg_fullname, &sb) == FAIL) { whinge("Can't stat package file '%s'.", pkg_fullname); return 1; } - sb.st_size *= 1.65; - home = make_playpen(PlayPen, sb.st_size); + sb.st_size *= 4; + (void)make_playpen(PlayPen, sb.st_size); if (unpack(pkg_fullname, NULL)) return 1; -- cgit v1.1