From 3e1a18606d886d71c06157a70949e4ec1e27e4b2 Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Sat, 22 Apr 1995 13:58:44 +0000 Subject: [PATCH] Export the min_free() function. --- usr.sbin/pkg_install/lib/file.c | 17 +++++++++++++++-- usr.sbin/pkg_install/lib/lib.h | 4 +++- usr.sbin/pkg_install/lib/pen.c | 9 +++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c index e2c26688a0f5..19470be639a9 100644 --- a/usr.sbin/pkg_install/lib/file.c +++ b/usr.sbin/pkg_install/lib/file.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: file.c,v 1.5 1993/09/18 03:39:48 jkh Exp $"; +static const char *rcsid = "$Id: file.c,v 1.6 1994/12/06 00:51:48 jkh Exp $"; #endif /* @@ -132,6 +132,19 @@ copy_file(char *dir, char *fname, char *to) barf("Couldn't perform '%s'", cmd); } +void +move_file(char *dir, char *fname, char *to) +{ + char cmd[FILENAME_MAX]; + + if (fname[0] == '/') + sprintf(cmd, "mv %s %s", fname, to); + else + sprintf(cmd, "mv %s/%s %s", dir, fname, to); + if (vsystem(cmd)) + barf("Couldn't perform '%s'", cmd); +} + /* * Copy a hierarchy (possibly from dir) to the current directory, or * if "to" is TRUE, from the current directory to a location someplace @@ -174,7 +187,7 @@ unpack(char *pkg, char *flist) if (cp) { strcpy(suffix, cp + 1); if (index(suffix, 'z') || index(suffix, 'Z')) - strcpy(args, "z"); + strcpy(args, "-z"); } strcat(args, "xpf"); if (vsystem("tar %s %s %s", args, pkg, flist ? flist : "")) { diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h index c1614fa847ab..a6cc77bb9786 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.13 1995/04/19 14:02:01 jkh Exp $ */ +/* $Id: lib.h,v 1.14 1995/04/22 07:41:01 jkh Exp $ */ /* * FreeBSD install - a package for the installation and maintainance @@ -109,6 +109,7 @@ void cleanup(int); char *make_playpen(char *, size_t); void leave_playpen(void); char *where_playpen(void); +long min_free(char *); /* String */ char *get_dash_string(char **); @@ -125,6 +126,7 @@ Boolean isempty(char *); char *get_file_contents(char *); void write_file(char *, char *); void copy_file(char *, char *, char *); +void move_file(char *, char *, char *); void copy_hierarchy(char *, char *, Boolean); int delete_hierarchy(char *, Boolean, Boolean); int unpack(char *, char *); diff --git a/usr.sbin/pkg_install/lib/pen.c b/usr.sbin/pkg_install/lib/pen.c index fe1468a4f521..07ba4aa1c9cb 100644 --- a/usr.sbin/pkg_install/lib/pen.c +++ b/usr.sbin/pkg_install/lib/pen.c @@ -1,5 +1,5 @@ #ifndef lint -static const char *rcsid = "$Id: pen.c,v 1.10 1995/04/18 13:04:34 jkh Exp $"; +static const char *rcsid = "$Id: pen.c,v 1.11 1995/04/21 06:30:41 jkh Exp $"; #endif /* @@ -30,8 +30,6 @@ static const char *rcsid = "$Id: pen.c,v 1.10 1995/04/18 13:04:34 jkh Exp $"; static char Cwd[FILENAME_MAX]; static char Pen[FILENAME_MAX]; -static long min_free(char *); - /* * Make a temporary directory to play in and chdir() to it, returning * pathname of previous working directory. @@ -93,10 +91,13 @@ where_playpen(void) return NULL; } -static long min_free(char *tmpdir) +long +min_free(char *tmpdir) { struct statfs buf; + if (!tmpdir) + tmpdir = Pen; if (statfs(tmpdir, &buf) != 0) { perror("Error in statfs"); return -1;