summaryrefslogtreecommitdiffstats
path: root/bin/pax/pax.c
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2001-05-08 06:19:06 +0000
committerkris <kris@FreeBSD.org>2001-05-08 06:19:06 +0000
commit6f2ea93cf4d39dc17b5fff4bc84a55d6562c8cd4 (patch)
tree63ec355a438835dcc12c39eb54e9e286c4f71426 /bin/pax/pax.c
parent7ecc59e45de1a67ed22b32856a18f28bb30d36e6 (diff)
downloadFreeBSD-src-6f2ea93cf4d39dc17b5fff4bc84a55d6562c8cd4.zip
FreeBSD-src-6f2ea93cf4d39dc17b5fff4bc84a55d6562c8cd4.tar.gz
Sync up with OpenBSD. Too many changes to note, but the major features
are: * Implement cpio compatibility mode when pax is invoked as cpio * Extend tar compatibility mode to cover many of the GNU tar single-letter options (bzip2 mode, aka -y/-j is not present in OpenBSD). When invoked as tar, pax is now full-featured enough for use by the ports collection to extract distfiles and create packages. * Many bug fixes to the operation of pax and the tar compatibility modes * Code fixes for things like correct string buffer termination. I tried to preserve existing FreeBSD fixes to this utility; please let me know if I have inadvertently spammed something.
Diffstat (limited to 'bin/pax/pax.c')
-rw-r--r--bin/pax/pax.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/bin/pax/pax.c b/bin/pax/pax.c
index a53ba80..bc97d7d 100644
--- a/bin/pax/pax.c
+++ b/bin/pax/pax.c
@@ -55,6 +55,7 @@ static const char rcsid[] =
#include <sys/resource.h>
#include <err.h>
#include <errno.h>
+#include <fcntl.h>
#include <locale.h>
#include <paths.h>
#include <signal.h>
@@ -75,6 +76,7 @@ static int gen_init __P((void));
int act = DEFOP; /* read/write/append/copy */
FSUB *frmt = NULL; /* archive format type */
int cflag; /* match all EXCEPT pattern/file */
+int cwdfd; /* starting cwd */
int dflag; /* directory member match only */
int iflag; /* interactive file/archive rename */
int kflag; /* do not overwrite existing files */
@@ -92,15 +94,18 @@ int Zflag; /* same as uflg except after name mode */
int vfpart; /* is partial verbose output in progress */
int patime = 1; /* preserve file access time */
int pmtime = 1; /* preserve file modification times */
+int nodirs; /* do not create directories as needed */
int pmode; /* preserve file mode bits */
int pids; /* preserve file uid/gid */
+int rmleadslash = 0; /* remove leading '/' from pathnames */
int exit_val; /* exit value */
int docrc; /* check/create file crc */
char *dirptr; /* destination dir in a copy */
char *argv0; /* root of argv[0] */
+sigset_t s_mask; /* signal mask for cleanup critical sect */
+FILE *listf = stderr; /* file pointer to print file list to */
char *tempfile; /* tempfile to use for mkstemp(3) */
char *tempbase; /* basename of tempfile to use for mkstemp(3) */
-sigset_t s_mask; /* signal mask for cleanup critical sect */
/*
* PAX - Portable Archive Interchange
@@ -236,6 +241,14 @@ main(argc, argv)
size_t tdlen;
(void) setlocale(LC_ALL, "");
+ /*
+ * Keep a reference to cwd, so we can always come back home.
+ */
+ cwdfd = open(".", O_RDONLY);
+ if (cwdfd < 0) {
+ syswarn(0, errno, "Can't open current working directory.");
+ return(exit_val);
+ }
/*
* Where should we put temporary files?
@@ -389,6 +402,7 @@ gen_init()
paxwarn(1, "Unable to set up signal mask");
return(-1);
}
+ memset(&n_hand, 0, sizeof n_hand);
n_hand.sa_mask = s_mask;
n_hand.sa_flags = 0;
n_hand.sa_handler = sig_cleanup;
OpenPOWER on IntegriCloud