summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/lib/pen.c
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-10-08 07:48:21 +0000
committercharnier <charnier@FreeBSD.org>1997-10-08 07:48:21 +0000
commit1c390186cd64897d9b1b87cb01152be10cc44005 (patch)
treefafe85eadca3db5f2091738324c5253d4072cf3e /usr.sbin/pkg_install/lib/pen.c
parentad57db7eefbd5760a834879d200ce1043f86046d (diff)
downloadFreeBSD-src-1c390186cd64897d9b1b87cb01152be10cc44005.zip
FreeBSD-src-1c390186cd64897d9b1b87cb01152be10cc44005.tar.gz
Use err(3). Cosmetics in usage string and man page.
Diffstat (limited to 'usr.sbin/pkg_install/lib/pen.c')
-rw-r--r--usr.sbin/pkg_install/lib/pen.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/usr.sbin/pkg_install/lib/pen.c b/usr.sbin/pkg_install/lib/pen.c
index 4b636de..36ece65 100644
--- a/usr.sbin/pkg_install/lib/pen.c
+++ b/usr.sbin/pkg_install/lib/pen.c
@@ -1,5 +1,6 @@
#ifndef lint
-static const char *rcsid = "$Id$";
+static const char rcsid[] =
+ "$Id: pen.c,v 1.24 1997/02/22 16:09:50 peter Exp $";
#endif
/*
@@ -22,6 +23,7 @@ static const char *rcsid = "$Id$";
*
*/
+#include <err.h>
#include "lib.h"
#include <sys/signal.h>
#include <sys/param.h>
@@ -57,9 +59,11 @@ find_play_pen(char *pen, size_t sz)
else if ((stat("/usr/tmp", &sb) == SUCCESS || mkdir("/usr/tmp", 01777) == SUCCESS) && min_free("/usr/tmp") >= sz)
strcpy(pen, "/usr/tmp/instmp.XXXXXX");
else {
- barf("Can't find enough temporary space to extract the files, please set\n"
- "your PKG_TMPDIR environment variable to a location with at least %d bytes\n"
- "free.", sz);
+ cleanup(0);
+ errx(2,
+"can't find enough temporary space to extract the files, please set your\n"
+"PKG_TMPDIR environment variable to a location with at least %d bytes\n"
+"free", sz);
return NULL;
}
return pen;
@@ -76,12 +80,12 @@ make_playpen(char *pen, size_t sz)
return NULL;
if (!mktemp(pen)) {
- barf("Can't mktemp '%s'.", pen);
- return NULL;
+ cleanup(0);
+ errx(2, "can't mktemp '%s'", pen);
}
if (mkdir(pen, 0755) == FAIL) {
- barf("Can't mkdir '%s'.", pen);
- return NULL;
+ cleanup(0);
+ errx(2, "can't mkdir '%s'", pen);
}
if (Verbose) {
if (sz)
@@ -89,10 +93,10 @@ make_playpen(char *pen, size_t sz)
}
if (min_free(pen) < sz) {
rmdir(pen);
- barf("Not enough free space to create: `%s'\n"
+ cleanup(0);
+ errx(2, "not enough free space to create '%s'.\n"
"Please set your PKG_TMPDIR environment variable to a location\n"
- "with more space and\ntry the command again.", pen);
- return NULL;
+ "with more space and\ntry the command again", pen);
}
if (Current[0])
strcpy(Previous, Current);
@@ -101,7 +105,7 @@ make_playpen(char *pen, size_t sz)
return NULL;
}
if (chdir(pen) == FAIL)
- barf("Can't chdir to '%s'.", pen);
+ cleanup(0), errx(2, "can't chdir to '%s'", pen);
strcpy(Current, pen);
return Previous;
}
@@ -115,10 +119,10 @@ leave_playpen(char *save)
/* Don't interrupt while we're cleaning up */
oldsig = signal(SIGINT, SIG_IGN);
if (Previous[0] && chdir(Previous) == FAIL)
- barf("Can't chdir back to '%s'.", Previous);
+ cleanup(0), errx(2, "can't chdir back to '%s'", Previous);
else if (Current[0] && strcmp(Current, Previous)) {
if (vsystem("rm -rf %s", Current))
- whinge("Couldn't remove temporary dir '%s'", Current);
+ warnx("couldn't remove temporary dir '%s'", Current);
strcpy(Current, Previous);
}
if (save)
@@ -134,7 +138,7 @@ min_free(char *tmpdir)
struct statfs buf;
if (statfs(tmpdir, &buf) != 0) {
- perror("Error in statfs");
+ warn("statfs");
return -1;
}
return (off_t)buf.f_bavail * (off_t)buf.f_bsize;
OpenPOWER on IntegriCloud