aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_install/lib
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pkg_install/lib')
-rw-r--r--usr.sbin/pkg_install/lib/lib.h4
-rw-r--r--usr.sbin/pkg_install/lib/pen.c30
2 files changed, 16 insertions, 18 deletions
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index 5d16f5625f97..a0de2a459bc9 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -1,4 +1,4 @@
-/* $Id: lib.h,v 1.24 1997/02/22 16:09:49 peter Exp $ */
+/* $Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp $ */
/*
* FreeBSD install - a package for the installation and maintainance
@@ -108,7 +108,7 @@ int vsystem(const char *, ...);
void cleanup(int);
char *make_playpen(char *, size_t);
char *where_playpen(void);
-void leave_playpen(char *);
+void leave_playpen(void);
off_t min_free(char *);
/* String */
diff --git a/usr.sbin/pkg_install/lib/pen.c b/usr.sbin/pkg_install/lib/pen.c
index e34e6286efbf..0549f27fe950 100644
--- a/usr.sbin/pkg_install/lib/pen.c
+++ b/usr.sbin/pkg_install/lib/pen.c
@@ -1,6 +1,6 @@
#ifndef lint
static const char rcsid[] =
- "$Id: pen.c,v 1.25 1997/10/08 07:48:12 charnier Exp $";
+ "$Id: pen.c,v 1.26 1998/01/09 14:52:18 jkh Exp $";
#endif
/*
@@ -30,13 +30,13 @@ static const char rcsid[] =
#include <sys/mount.h>
/* For keeping track of where we are */
-static char Current[FILENAME_MAX];
+static char PenLocation[FILENAME_MAX];
static char Previous[FILENAME_MAX];
char *
where_playpen(void)
{
- return Current;
+ return PenLocation;
}
/* Find a good place to play. */
@@ -76,6 +76,10 @@ find_play_pen(char *pen, size_t sz)
char *
make_playpen(char *pen, size_t sz)
{
+ if (PenLocation[0]) {
+ errx(2, "make_playpen() called before closing previous pen: %s", pen);
+ return NULL;
+ }
if (!find_play_pen(pen, sz))
return NULL;
@@ -98,21 +102,19 @@ make_playpen(char *pen, size_t sz)
"Please set your PKG_TMPDIR environment variable to a location\n"
"with more space and\ntry the command again", pen);
}
- if (Current[0])
- strcpy(Previous, Current);
- else if (!getcwd(Previous, FILENAME_MAX)) {
+ if (!getcwd(Previous, FILENAME_MAX)) {
upchuck("getcwd");
return NULL;
}
if (chdir(pen) == FAIL)
cleanup(0), errx(2, "can't chdir to '%s'", pen);
- strcpy(Current, pen);
+ strcpy(PenLocation, pen);
return Previous;
}
/* Convenience routine for getting out of playpen */
void
-leave_playpen(char *save)
+leave_playpen()
{
void (*oldsig)(int);
@@ -120,15 +122,11 @@ leave_playpen(char *save)
oldsig = signal(SIGINT, SIG_IGN);
if (Previous[0] && chdir(Previous) == FAIL)
cleanup(0), errx(2, "can't chdir back to '%s'", Previous);
- else if (Current[0] && strcmp(Current, Previous)) {
- if (Current[0] == '/' && vsystem("rm -rf %s", Current))
- warnx("couldn't remove temporary dir '%s'", Current);
- strcpy(Current, Previous);
+ else if (PenLocation[0]) {
+ if (PenLocation[0] == '/' && vsystem("rm -rf %s", PenLocation))
+ warnx("couldn't remove temporary dir '%s'", PenLocation);
}
- if (save)
- strcpy(Previous, save);
- else
- Previous[0] = '\0';
+ Previous[0] = PenLocation[0] = '\0';
signal(SIGINT, oldsig);
}