1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-15 15:06:42 +00:00

Use humanize_number to report pen-sizes so people don't have to count

the digits when trying to install openoffice.
This commit is contained in:
Poul-Henning Kamp 2008-08-07 14:48:35 +00:00
parent bda750b404
commit 419859bd08
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=181376
2 changed files with 18 additions and 4 deletions

View File

@ -4,6 +4,9 @@
LIBINSTALL= ${.OBJDIR}/../lib/libinstall.a
DPADD+= ${LIBUTIL}
LDADD+= -lutil
.if ${MK_OPENSSL} != "no" && \
defined(LDADD) && ${LDADD:M-lfetch} != ""
DPADD+= ${LIBSSL} ${LIBCRYPTO}

View File

@ -23,6 +23,7 @@ __FBSDID("$FreeBSD$");
#include "lib.h"
#include <err.h>
#include <libutil.h>
#include <libgen.h>
#include <sys/signal.h>
#include <sys/param.h>
@ -44,6 +45,7 @@ find_play_pen(char *pen, off_t sz)
{
char *cp;
struct stat sb;
char humbuf[6];
if (pen[0] && isdir(dirname(pen)) == TRUE && (min_free(dirname(pen)) >= sz))
return pen;
@ -59,10 +61,12 @@ find_play_pen(char *pen, off_t sz)
strcpy(pen, "/usr/tmp/instmp.XXXXXX");
else {
cleanup(0);
humanize_number(humbuf, sizeof humbuf, sz, "", HN_AUTOSCALE,
HN_NOSPACE);
errx(2,
"%s: can't find enough temporary space to extract the files, please set your\n"
"PKG_TMPDIR environment variable to a location with at least %ld bytes\n"
"free", __func__, (long)sz);
"PKG_TMPDIR environment variable to a location with at least %s bytes\n"
"free", __func__, humbuf);
return NULL;
}
return pen;
@ -98,6 +102,8 @@ popPen(char *pen)
char *
make_playpen(char *pen, off_t sz)
{
char humbuf1[6], humbuf2[6];
if (!find_play_pen(pen, sz))
return NULL;
@ -111,8 +117,13 @@ make_playpen(char *pen, off_t sz)
}
if (Verbose) {
if (sz)
fprintf(stderr, "Requested space: %d bytes, free space: %lld bytes in %s\n", (int)sz, (long long)min_free(pen), pen);
if (sz) {
humanize_number(humbuf1, sizeof humbuf1, sz, "", HN_AUTOSCALE,
HN_NOSPACE);
humanize_number(humbuf2, sizeof humbuf2, min_free(pen),
"", HN_AUTOSCALE, HN_NOSPACE);
fprintf(stderr, "Requested space: %s bytes, free space: %s bytes in %s\n", humbuf1, humbuf2, pen);
}
}
if (min_free(pen) < sz) {