diff options
author | jlam <jlam> | 2004-08-21 03:28:49 +0000 |
---|---|---|
committer | jlam <jlam> | 2004-08-21 03:28:49 +0000 |
commit | cfe8e7f827cee5b55ad2dc65f51f602212425a55 (patch) | |
tree | 5a31626ba82d66abe9e0eb31a61d5759fa1813fa /archivers | |
parent | 691facbe1cffd6ef8832e699611aee6cc1b5b96d (diff) | |
download | pkgsrc-cfe8e7f827cee5b55ad2dc65f51f602212425a55.tar.gz |
Update archivers/pax to 20040802 (latest version on src HEAD). Changes
from previous include:
- include a pax2nbcompat script to ease importing from src HEAD
into pkgsrc.
* for copy mode, show more meaningful information on SIGINFO.
Diffstat (limited to 'archivers')
30 files changed, 759 insertions, 170 deletions
diff --git a/archivers/pax/Makefile b/archivers/pax/Makefile index 6ac416e770b..458d3d2e521 100644 --- a/archivers/pax/Makefile +++ b/archivers/pax/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.16 2004/08/14 02:33:32 jlam Exp $ +# $NetBSD: Makefile,v 1.17 2004/08/21 03:28:56 jlam Exp $ # -DISTNAME= pax-20040703 +DISTNAME= pax-20040802 CATEGORIES= archivers pkgtools MASTER_SITES= # empty DISTFILES= # empty diff --git a/archivers/pax/files/ar_io.c b/archivers/pax/files/ar_io.c index 5fb14032fd4..c1f7d3ed359 100644 --- a/archivers/pax/files/ar_io.c +++ b/archivers/pax/files/ar_io.c @@ -1,4 +1,4 @@ -/* $NetBSD: ar_io.c,v 1.7 2004/06/20 10:11:02 grant Exp $ */ +/* $NetBSD: ar_io.c,v 1.8 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,15 +36,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)ar_io.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: ar_io.c,v 1.7 2004/06/20 10:11:02 grant Exp $"); +__RCSID("$NetBSD: ar_io.c,v 1.8 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ @@ -140,7 +144,7 @@ static int get_phys(void); #endif /* SUPPORT_TAPE */ extern sigset_t s_mask; static void ar_start_gzip(int, const char *, int); -static const char *timefmt(char *, size_t, off_t, time_t); +static const char *timefmt(char *, size_t, off_t, time_t, const char *); static const char *sizefmt(char *, size_t, off_t); #ifdef SUPPORT_RMT @@ -234,8 +238,10 @@ ar_open(const char *name) return(-1); if (chdname != NULL) - if (chdir(chdname) != 0) + if (chdir(chdname) != 0) { syswarn(1, errno, "Failed chdir to %s", chdname); + return(-1); + } /* * set up is based on device type */ @@ -818,7 +824,7 @@ ar_read(char *buf, int cnt) return(res); } break; -#endif +#endif /* SUPPORT_TAPE */ case ISREG: case ISBLK: case ISCHR: @@ -908,8 +914,12 @@ ar_write(char *buf, int bsz) /* * if file is out of space, handle it like a return of 0 */ - if ((errno == ENOSPC) || (errno == EFBIG) || (errno == EDQUOT)) + if ((errno == ENOSPC) || (errno == EFBIG)) + res = lstrval = 0; +#ifdef EDQUOT + if (errno == EDQUOT) res = lstrval = 0; +#endif break; #ifdef SUPPORT_TAPE case ISTAPE: @@ -1661,14 +1671,15 @@ ar_start_gzip(int fd, const char *gzp, int wr) } static const char * -timefmt(buf, size, sz, tm) +timefmt(buf, size, sz, tm, unitstr) char *buf; size_t size; off_t sz; time_t tm; + const char *unitstr; { - (void)snprintf(buf, size, "%lu secs (" OFFT_F " bytes/sec)", - (unsigned long)tm, (OFFT_T)(sz / tm)); + (void)snprintf(buf, size, "%lu secs (" OFFT_F " %s/sec)", + (unsigned long)tm, (OFFT_T)(sz / tm), unitstr); return buf; } @@ -1711,11 +1722,11 @@ ar_summary(int n) * we have skipped over looking for a header to id. there is no way we * could have written anything yet. */ - if (frmt == NULL) { + if (frmt == NULL && act != COPY) { len = snprintf(buf, sizeof(buf), "unknown format, %s skipped in %s\n", sizefmt(s1buf, sizeof(s1buf), rdcnt), - timefmt(tbuf, sizeof(tbuf), rdcnt, secs)); + timefmt(tbuf, sizeof(tbuf), rdcnt, secs, "bytes")); if (n == 0) (void)fprintf(outf, "%s: %s", argv0, buf); else @@ -1731,12 +1742,19 @@ ar_summary(int n) } - len = snprintf(buf, sizeof(buf), - "%s vol %d, %lu files, %s read, %s written in %s\n", - frmt->name, arvol-1, (unsigned long)flcnt, - sizefmt(s1buf, sizeof(s1buf), rdcnt), - sizefmt(s2buf, sizeof(s2buf), wrcnt), - timefmt(tbuf, sizeof(tbuf), rdcnt + wrcnt, secs)); + if (act == COPY) { + len = snprintf(buf, sizeof(buf), + "%lu files in %s\n", + (unsigned long)flcnt, + timefmt(tbuf, sizeof(tbuf), flcnt, secs, "files")); + } else { + len = snprintf(buf, sizeof(buf), + "%s vol %d, %lu files, %s read, %s written in %s\n", + frmt->name, arvol-1, (unsigned long)flcnt, + sizefmt(s1buf, sizeof(s1buf), rdcnt), + sizefmt(s2buf, sizeof(s2buf), wrcnt), + timefmt(tbuf, sizeof(tbuf), rdcnt + wrcnt, secs, "bytes")); + } if (n == 0) (void)fprintf(outf, "%s: %s", argv0, buf); else diff --git a/archivers/pax/files/ar_subs.c b/archivers/pax/files/ar_subs.c index b9071577b1a..e068eeff4b5 100644 --- a/archivers/pax/files/ar_subs.c +++ b/archivers/pax/files/ar_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: ar_subs.c,v 1.6 2004/06/20 10:11:02 grant Exp $ */ +/* $NetBSD: ar_subs.c,v 1.7 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,15 +36,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: ar_subs.c,v 1.6 2004/06/20 10:11:02 grant Exp $"); +__RCSID("$NetBSD: ar_subs.c,v 1.7 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ diff --git a/archivers/pax/files/buf_subs.c b/archivers/pax/files/buf_subs.c index 9351637a036..39be14e91c7 100644 --- a/archivers/pax/files/buf_subs.c +++ b/archivers/pax/files/buf_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: buf_subs.c,v 1.4 2004/06/20 10:11:02 grant Exp $ */ +/* $NetBSD: buf_subs.c,v 1.5 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,15 +36,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)buf_subs.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: buf_subs.c,v 1.4 2004/06/20 10:11:02 grant Exp $"); +__RCSID("$NetBSD: buf_subs.c,v 1.5 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ diff --git a/archivers/pax/files/config.h.in b/archivers/pax/files/config.h.in index 4a066d84f4c..a03d8efd307 100644 --- a/archivers/pax/files/config.h.in +++ b/archivers/pax/files/config.h.in @@ -33,6 +33,9 @@ /* Define to 1 if you have the <limits.h> header file. */ #undef HAVE_LIMITS_H +/* Define to 1 if you have the `lutimes' function. */ +#undef HAVE_LUTIMES + /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H @@ -81,6 +84,9 @@ /* Define to 1 if you have the <string.h> header file. */ #undef HAVE_STRING_H +/* Define to 1 if `st_flags' is member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_FLAGS + /* Define to 1 if you have the <sys/cdefs.h> header file. */ #undef HAVE_SYS_CDEFS_H diff --git a/archivers/pax/files/configure b/archivers/pax/files/configure index 52837000a9d..4b1da1b2eff 100755 --- a/archivers/pax/files/configure +++ b/archivers/pax/files/configure @@ -3256,9 +3256,223 @@ fi done +echo "$as_me:$LINENO: checking for struct stat.st_flags" >&5 +echo $ECHO_N "checking for struct stat.st_flags... $ECHO_C" >&6 +if test "${ac_cv_member_struct_stat_st_flags+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/stat.h> + +int +main () +{ +static struct stat ac_aggr; +if (ac_aggr.st_flags) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_stat_st_flags=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <sys/stat.h> + +int +main () +{ +static struct stat ac_aggr; +if (sizeof ac_aggr.st_flags) +return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_member_struct_stat_st_flags=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_member_struct_stat_st_flags=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_member_struct_stat_st_flags" >&5 +echo "${ECHO_T}$ac_cv_member_struct_stat_st_flags" >&6 +if test $ac_cv_member_struct_stat_st_flags = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_FLAGS 1 +_ACEOF + + +fi + # Checks for library functions. +for ac_func in lutimes +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + +#undef $ac_func + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + for ac_func in getrlimit setrlimit do diff --git a/archivers/pax/files/configure.ac b/archivers/pax/files/configure.ac index e5c535a7da6..0a8b70bbd06 100644 --- a/archivers/pax/files/configure.ac +++ b/archivers/pax/files/configure.ac @@ -21,8 +21,10 @@ AC_CHECK_HEADERS([ctype.h errno.h err.h fnctl.h fts.h getopt.h grp.h \ AC_CHECK_HEADERS([sys/cdefs.h sys/ioctl.h sys/mtio.h sys/param.h \ sys/resource.h sys/stat.h sys/tape.h sys/time.h sys/types.h sys/uio.h \ sys/wait.h]) +AC_CHECK_MEMBERS([struct stat.st_flags],,, [#include <sys/stat.h>]) # Checks for library functions. +AC_CHECK_FUNCS([lutimes]) AC_CHECK_FUNCS([getrlimit setrlimit]) AC_CONFIG_FILES([Makefile]) diff --git a/archivers/pax/files/cpio.c b/archivers/pax/files/cpio.c index 4e591bcf44f..014f74d48da 100644 --- a/archivers/pax/files/cpio.c +++ b/archivers/pax/files/cpio.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpio.c,v 1.3 2003/12/20 04:45:04 grant Exp $ */ +/* $NetBSD: cpio.c,v 1.4 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,15 +36,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)cpio.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: cpio.c,v 1.3 2003/12/20 04:45:04 grant Exp $"); +__RCSID("$NetBSD: cpio.c,v 1.4 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ diff --git a/archivers/pax/files/dumptar.c b/archivers/pax/files/dumptar.c new file mode 100644 index 00000000000..77e8500c0b1 --- /dev/null +++ b/archivers/pax/files/dumptar.c @@ -0,0 +1,143 @@ +/* $NetBSD: dumptar.c,v 1.1 2004/08/21 03:28:56 jlam Exp $ */ + +/*- + * Copyright (c) 2004 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif +#include <nbcompat.h> +#if HAVE_STDIO_H +#include <stdio.h> +#endif +#if HAVE_ERR_H +#include <err.h> +#endif +#if HAVE_FCNTL_H +#include <fcntl.h> +#endif +#if HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif +#if HAVE_SYS_MMAN_H +#include <sys/mman.h> +#endif + +#include "tar.h" + +#define ussum(a) 1 + +static char * +buf(const char *p, size_t s) +{ + static char buf[1024]; + (void)snprintf(buf, sizeof(buf), "%s", p); + buf[s] = '\0'; + return buf; +} + +int +intarg(const char *p, size_t s) +{ + char *ep, *b = buf(p, s); + int r = (int)strtol(p, &ep, 8); + return r; +} + +static int +usdump(void *p) +{ + HD_USTAR *t = p; + int size = intarg(t->size, sizeof(t->size)); + size = ((size + 511) / 512) * 512 + 512; + + (void)fprintf(stdout, "*****\n"); +#define PR(a) \ + (void)fprintf(stdout, #a "=%s\n", buf(t->a, sizeof(t->a))); +#define IPR(a) \ + (void)fprintf(stdout, #a "=%d\n", intarg(t->a, sizeof(t->a))); +#define OPR(a) \ + (void)fprintf(stdout, #a "=%o\n", intarg(t->a, sizeof(t->a))); + PR(name); + OPR(mode); + IPR(uid); + IPR(gid); + IPR(size); + OPR(mtime); + OPR(chksum); + (void)fprintf(stdout, "typeflag=%c\n", t->typeflag); + PR(linkname); + PR(magic); + PR(version); + PR(uname); + PR(gname); + OPR(devmajor); + OPR(devminor); + PR(prefix); + return size; +} + +int +main(int argc, char *argv[]) +{ + int fd; + struct stat st; + char *p, *ep; + + if (argc != 2) { + (void)fprintf(stderr, "Usage: %s <filename>\n", getprogname()); + return 1; + } + + if ((fd = open(argv[1], O_RDONLY)) == -1) + err(1, "Cannot open `%s'", argv[1]); + + if (fstat(fd, &st) == -1) + err(1, "Cannot fstat `%s'", argv[1]); + + if ((p = mmap(NULL, (size_t)st.st_size, PROT_READ, + MAP_FILE|MAP_PRIVATE, fd, (off_t)0)) == MAP_FAILED) + err(1, "Cannot mmap `%s'", argv[1]); + (void)close(fd); + + ep = (char *)p + (size_t)st.st_size; + + for (; p < ep + sizeof(HD_USTAR);) { + if (ussum(p)) + p += usdump(p); + } + return 0; +} diff --git a/archivers/pax/files/file_subs.c b/archivers/pax/files/file_subs.c index cf6fd7d2fb0..b3648b85b3c 100644 --- a/archivers/pax/files/file_subs.c +++ b/archivers/pax/files/file_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: file_subs.c,v 1.8 2004/07/03 02:50:21 grant Exp $ */ +/* $NetBSD: file_subs.c,v 1.9 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,15 +36,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: file_subs.c,v 1.8 2004/07/03 02:50:21 grant Exp $"); +__RCSID("$NetBSD: file_subs.c,v 1.9 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ @@ -774,7 +778,7 @@ set_ftime(char *fnm, time_t mtime, time_t atime, int frc) * set. We get the current values of the times if we need them. */ if (lstat(fnm, &sb) == 0) { -#ifdef BSD4_4 +#if BSD4_4 && !HAVE_NBTOOL_CONFIG_H if (!patime) TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atimespec); if (!pmtime) diff --git a/archivers/pax/files/ftree.c b/archivers/pax/files/ftree.c index 4ebb0232507..2a35a95b878 100644 --- a/archivers/pax/files/ftree.c +++ b/archivers/pax/files/ftree.c @@ -1,4 +1,4 @@ -/* $NetBSD: ftree.c,v 1.6 2004/06/20 10:11:02 grant Exp $ */ +/* $NetBSD: ftree.c,v 1.7 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -72,15 +72,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)ftree.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: ftree.c,v 1.6 2004/06/20 10:11:02 grant Exp $"); +__RCSID("$NetBSD: ftree.c,v 1.7 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ @@ -398,7 +402,6 @@ ftree_arg(void) if (i == 0) return -1; farray[0][i] = '\0'; - fprintf(stderr, ">%s<\n", farray[0]); } else { /* * the user supplied the file args as arguements to pax @@ -546,7 +549,7 @@ next_file(ARCHD *arcn) statbuf.st_flags = ftnode->st_flags; #endif if (ftnode->flags & F_TIME) -#ifdef BSD4_4 +#if BSD4_4 && !HAVE_NBTOOL_CONFIG_H statbuf.st_mtimespec = ftnode->st_mtimespec; #else statbuf.st_mtime = ftnode->st_mtimespec.tv_sec; @@ -750,6 +753,7 @@ next_file(ARCHD *arcn) arcn->ln_name[cnt] = '\0'; arcn->ln_nlen = cnt; break; +#ifdef S_IFSOCK case S_IFSOCK: /* * under BSD storing a socket is senseless but we will @@ -758,6 +762,7 @@ next_file(ARCHD *arcn) */ arcn->type = PAX_SCK; break; +#endif case S_IFIFO: arcn->type = PAX_FIF; break; diff --git a/archivers/pax/files/gen_subs.c b/archivers/pax/files/gen_subs.c index 4a82ea5ebd2..6d7720f4d9a 100644 --- a/archivers/pax/files/gen_subs.c +++ b/archivers/pax/files/gen_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: gen_subs.c,v 1.6 2003/12/20 04:45:04 grant Exp $ */ +/* $NetBSD: gen_subs.c,v 1.7 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,15 +36,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)gen_subs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: gen_subs.c,v 1.6 2003/12/20 04:45:04 grant Exp $"); +__RCSID("$NetBSD: gen_subs.c,v 1.7 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ diff --git a/archivers/pax/files/getid.c b/archivers/pax/files/getid.c index 2911dddfdf6..b5e51c9aa98 100644 --- a/archivers/pax/files/getid.c +++ b/archivers/pax/files/getid.c @@ -1,4 +1,4 @@ -/* $NetBSD: getid.c,v 1.1 2003/09/05 18:40:51 jlam Exp $ */ +/* $NetBSD: getid.c,v 1.2 2004/08/21 03:28:56 jlam Exp $ */ /* from: NetBSD: getpwent.c,v 1.48 2000/10/03 03:22:26 enami Exp */ /* from: NetBSD: getgrent.c,v 1.41 2002/01/12 23:51:30 lukem Exp */ @@ -70,6 +70,10 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_PARAM_H #include <sys/param.h> diff --git a/archivers/pax/files/getoldopt.c b/archivers/pax/files/getoldopt.c index df1e7b97c87..0468ae919db 100644 --- a/archivers/pax/files/getoldopt.c +++ b/archivers/pax/files/getoldopt.c @@ -1,4 +1,4 @@ -/* $NetBSD: getoldopt.c,v 1.4 2003/09/05 18:40:52 jlam Exp $ */ +/* $NetBSD: getoldopt.c,v 1.5 2004/08/21 03:28:56 jlam Exp $ */ /* * Plug-compatible replacement for getopt() for parsing tar-like @@ -12,17 +12,25 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: getoldopt.c,v 1.4 2003/09/05 18:40:52 jlam Exp $"); +#if !defined(lint) +__RCSID("$NetBSD: getoldopt.c,v 1.5 2004/08/21 03:28:56 jlam Exp $"); #endif /* not lint */ +#if HAVE_NBTOOL_CONFIG_H +#include "compat_getopt.h" +#else #if HAVE_GETOPT_H #include <getopt.h> #endif +#endif #if HAVE_STDIO_H #include <stdio.h> #endif diff --git a/archivers/pax/files/misc.c b/archivers/pax/files/misc.c index d6861a01ec7..8bb27411100 100644 --- a/archivers/pax/files/misc.c +++ b/archivers/pax/files/misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.1 2003/09/05 18:40:52 jlam Exp $ */ +/* $NetBSD: misc.c,v 1.2 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -34,12 +34,16 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: misc.c,v 1.1 2003/09/05 18:40:52 jlam Exp $"); +__RCSID("$NetBSD: misc.c,v 1.2 2004/08/21 03:28:56 jlam Exp $"); #endif /* not lint */ #if HAVE_SYS_TYPES_H @@ -262,8 +266,10 @@ nodetoino(u_int type) return S_IFREG; case F_LINK: return S_IFLNK; +#ifdef S_IFSOCK case F_SOCK: return S_IFSOCK; +#endif default: printf("unknown type %d", type); abort(); @@ -296,8 +302,10 @@ inotype(u_int type) return ("file"); case S_IFLNK: return ("link"); +#ifdef S_IFSOCK case S_IFSOCK: return ("socket"); +#endif default: return ("unknown"); } diff --git a/archivers/pax/files/mtree.h b/archivers/pax/files/mtree.h index ee2f4a44254..021aea44d35 100644 --- a/archivers/pax/files/mtree.h +++ b/archivers/pax/files/mtree.h @@ -1,4 +1,4 @@ -/* $NetBSD: mtree.h,v 1.1 2003/09/05 18:40:52 jlam Exp $ */ +/* $NetBSD: mtree.h,v 1.2 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -111,6 +111,7 @@ const char *inotype(u_int); u_int nodetoino(u_int); int setup_getid(const char *); NODE *spec(FILE *); +void free_nodes(NODE *); char *vispath(const char *); diff --git a/archivers/pax/files/mtree_extern.h b/archivers/pax/files/mtree_extern.h index 7dc02cd9a27..3c64cf7a40c 100644 --- a/archivers/pax/files/mtree_extern.h +++ b/archivers/pax/files/mtree_extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: mtree_extern.h,v 1.1 2003/09/05 18:40:52 jlam Exp $ */ +/* $NetBSD: mtree_extern.h,v 1.2 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -31,12 +31,13 @@ * @(#)extern.h 8.1 (Berkeley) 6/6/93 */ +#if HAVE_CONFIG_H +#include "config.h" +#endif #include "mtree.h" -#if HAVE_CONFIG_H -#include "config.h" -#else -#define HAVE_STRUCT_STAT_ST_FLAGS 1 +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" #endif #include <nbcompat.h> @@ -77,7 +78,7 @@ const char *rlink(const char *); int verify(void); extern int dflag, eflag, iflag, lflag, mflag, rflag, sflag, tflag, uflag; -extern int Wflag; +extern int mtree_Mflag, mtree_Wflag; extern size_t mtree_lineno; extern u_int32_t crc_total; extern int ftsoptions, keys; diff --git a/archivers/pax/files/options.c b/archivers/pax/files/options.c index aa39a4ca8a3..6f63150eaeb 100644 --- a/archivers/pax/files/options.c +++ b/archivers/pax/files/options.c @@ -1,4 +1,4 @@ -/* $NetBSD: options.c,v 1.6 2004/06/20 10:11:02 grant Exp $ */ +/* $NetBSD: options.c,v 1.7 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,15 +36,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: options.c,v 1.6 2004/06/20 10:11:02 grant Exp $"); +__RCSID("$NetBSD: options.c,v 1.7 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ @@ -69,9 +73,13 @@ __RCSID("$NetBSD: options.c,v 1.6 2004/06/20 10:11:02 grant Exp $"); #if HAVE_ERRNO_H #include <errno.h> #endif +#if HAVE_NBTOOL_CONFIG_H +#include "compat_getopt.h" +#else #if HAVE_GETOPT_H #include <getopt.h> #endif +#endif #if HAVE_LIMITS_H #include <limits.h> #endif diff --git a/archivers/pax/files/pack_dev.c b/archivers/pax/files/pack_dev.c index 8403382e2fb..2473a4ccce4 100644 --- a/archivers/pax/files/pack_dev.c +++ b/archivers/pax/files/pack_dev.c @@ -1,4 +1,4 @@ -/* $NetBSD: pack_dev.c,v 1.1 2003/09/05 18:40:53 jlam Exp $ */ +/* $NetBSD: pack_dev.c,v 1.2 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -39,12 +39,16 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: pack_dev.c,v 1.1 2003/09/05 18:40:53 jlam Exp $"); +#if !defined(lint) +__RCSID("$NetBSD: pack_dev.c,v 1.2 2004/08/21 03:28:56 jlam Exp $"); #endif /* not lint */ #if HAVE_SYS_TYPES_H @@ -54,9 +58,6 @@ __RCSID("$NetBSD: pack_dev.c,v 1.1 2003/09/05 18:40:53 jlam Exp $"); #include <sys/stat.h> #endif -#if HAVE_ERR_H -#include <err.h> -#endif #if HAVE_LIMITS_H #include <limits.h> #endif @@ -73,10 +74,6 @@ __RCSID("$NetBSD: pack_dev.c,v 1.1 2003/09/05 18:40:53 jlam Exp $"); #include <unistd.h> #endif -#if HAVE_CONFIG_H -#include "config.h" -#endif - #include "pack_dev.h" static pack_t pack_netbsd; @@ -88,38 +85,41 @@ static pack_t pack_8_24; static pack_t pack_bsdos; static int compare_format(const void *, const void *); +static const char iMajorError[] = "invalid major number"; +static const char iMinorError[] = "invalid minor number"; +static const char tooManyFields[] = "too many fields for format"; /* exported */ portdev_t -pack_native(int n, u_long numbers[]) +pack_native(int n, u_long numbers[], const char **error) { - portdev_t dev; + portdev_t dev = 0; if (n == 2) { dev = makedev(numbers[0], numbers[1]); if (major(dev) != numbers[0]) - errx(1, "invalid major number"); - if (minor(dev) != numbers[1]) - errx(1, "invalid minor number"); + *error = iMajorError; + else if (minor(dev) != numbers[1]) + *error = iMinorError; } else - errx(1, "too many fields for format"); + *error = tooManyFields; return (dev); } static portdev_t -pack_netbsd(int n, u_long numbers[]) +pack_netbsd(int n, u_long numbers[], const char **error) { - portdev_t dev; + portdev_t dev = 0; if (n == 2) { dev = makedev_netbsd(numbers[0], numbers[1]); if (major_netbsd(dev) != numbers[0]) - errx(1, "invalid major number"); - if (minor_netbsd(dev) != numbers[1]) - errx(1, "invalid minor number"); + *error = iMajorError; + else if (minor_netbsd(dev) != numbers[1]) + *error = iMinorError; } else - errx(1, "too many fields for format"); + *error = tooManyFields; return (dev); } @@ -130,18 +130,18 @@ pack_netbsd(int n, u_long numbers[]) (((y) << 0) & 0xffff00ff))) static portdev_t -pack_freebsd(int n, u_long numbers[]) +pack_freebsd(int n, u_long numbers[], const char **error) { - portdev_t dev; + portdev_t dev = 0; if (n == 2) { dev = makedev_freebsd(numbers[0], numbers[1]); if (major_freebsd(dev) != numbers[0]) - errx(1, "invalid major number"); + *error = iMajorError; if (minor_freebsd(dev) != numbers[1]) - errx(1, "invalid minor number"); + *error = iMinorError; } else - errx(1, "too many fields for format"); + *error = tooManyFields; return (dev); } @@ -152,18 +152,18 @@ pack_freebsd(int n, u_long numbers[]) (((y) << 0) & 0x000000ff))) static portdev_t -pack_8_8(int n, u_long numbers[]) +pack_8_8(int n, u_long numbers[], const char **error) { - portdev_t dev; + portdev_t dev = 0; if (n == 2) { dev = makedev_8_8(numbers[0], numbers[1]); if (major_8_8(dev) != numbers[0]) - errx(1, "invalid major number"); + *error = iMajorError; if (minor_8_8(dev) != numbers[1]) - errx(1, "invalid minor number"); + *error = iMinorError; } else - errx(1, "too many fields for format"); + *error = tooManyFields; return (dev); } @@ -174,18 +174,18 @@ pack_8_8(int n, u_long numbers[]) (((y) << 0) & 0x000fffff))) static portdev_t -pack_12_20(int n, u_long numbers[]) +pack_12_20(int n, u_long numbers[], const char **error) { - portdev_t dev; + portdev_t dev = 0; if (n == 2) { dev = makedev_12_20(numbers[0], numbers[1]); if (major_12_20(dev) != numbers[0]) - errx(1, "invalid major number"); + *error = iMajorError; if (minor_12_20(dev) != numbers[1]) - errx(1, "invalid minor number"); + *error = iMinorError; } else - errx(1, "too many fields for format"); + *error = tooManyFields; return (dev); } @@ -196,18 +196,18 @@ pack_12_20(int n, u_long numbers[]) (((y) << 0) & 0x0003ffff))) static portdev_t -pack_14_18(int n, u_long numbers[]) +pack_14_18(int n, u_long numbers[], const char **error) { - portdev_t dev; + portdev_t dev = 0; if (n == 2) { dev = makedev_14_18(numbers[0], numbers[1]); if (major_14_18(dev) != numbers[0]) - errx(1, "invalid major number"); + *error = iMajorError; if (minor_14_18(dev) != numbers[1]) - errx(1, "invalid minor number"); + *error = iMinorError; } else - errx(1, "too many fields for format"); + *error = tooManyFields; return (dev); } @@ -218,18 +218,18 @@ pack_14_18(int n, u_long numbers[]) (((y) << 0) & 0x00ffffff))) static portdev_t -pack_8_24(int n, u_long numbers[]) +pack_8_24(int n, u_long numbers[], const char **error) { - portdev_t dev; + portdev_t dev = 0; if (n == 2) { dev = makedev_8_24(numbers[0], numbers[1]); if (major_8_24(dev) != numbers[0]) - errx(1, "invalid major number"); + *error = iMajorError; if (minor_8_24(dev) != numbers[1]) - errx(1, "invalid minor number"); + *error = iMinorError; } else - errx(1, "too many fields for format"); + *error = tooManyFields; return (dev); } @@ -242,26 +242,26 @@ pack_8_24(int n, u_long numbers[]) (((z) << 0) & 0x000000ff))) static portdev_t -pack_bsdos(int n, u_long numbers[]) +pack_bsdos(int n, u_long numbers[], const char **error) { - portdev_t dev; + portdev_t dev = 0; if (n == 2) { dev = makedev_12_20(numbers[0], numbers[1]); if (major_12_20(dev) != numbers[0]) - errx(1, "invalid major number"); + *error = iMajorError; if (minor_12_20(dev) != numbers[1]) - errx(1, "invalid minor number"); + *error = iMinorError; } else if (n == 3) { dev = makedev_12_12_8(numbers[0], numbers[1], numbers[2]); if (major_12_12_8(dev) != numbers[0]) - errx(1, "invalid major number"); + *error = iMajorError; if (unit_12_12_8(dev) != numbers[1]) - errx(1, "invalid unit number"); + *error = "invalid unit number"; if (subunit_12_12_8(dev) != numbers[2]) - errx(1, "invalid subunit number"); + *error = "invalid subunit number"; } else - errx(1, "too many fields for format"); + *error = tooManyFields; return (dev); } diff --git a/archivers/pax/files/pack_dev.h b/archivers/pax/files/pack_dev.h index 99a5540dfb4..d07169ca099 100644 --- a/archivers/pax/files/pack_dev.h +++ b/archivers/pax/files/pack_dev.h @@ -1,4 +1,4 @@ -/* $NetBSD: pack_dev.h,v 1.1 2003/09/05 18:40:53 jlam Exp $ */ +/* $NetBSD: pack_dev.h,v 1.2 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. @@ -44,7 +44,7 @@ typedef __dev32_t portdev_t; #else typedef dev_t portdev_t; #endif -typedef portdev_t pack_t(int, u_long []); +typedef portdev_t pack_t(int, u_long [], const char **); pack_t *pack_find(const char *); pack_t pack_native; diff --git a/archivers/pax/files/pat_rep.c b/archivers/pax/files/pat_rep.c index 66a1c2b0327..2c208fcb458 100644 --- a/archivers/pax/files/pat_rep.c +++ b/archivers/pax/files/pat_rep.c @@ -1,4 +1,4 @@ -/* $NetBSD: pat_rep.c,v 1.3 2003/12/20 04:45:04 grant Exp $ */ +/* $NetBSD: pat_rep.c,v 1.4 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,15 +36,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)pat_rep.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: pat_rep.c,v 1.3 2003/12/20 04:45:04 grant Exp $"); +__RCSID("$NetBSD: pat_rep.c,v 1.4 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ diff --git a/archivers/pax/files/pax.c b/archivers/pax/files/pax.c index a9b141ed533..01da438a287 100644 --- a/archivers/pax/files/pax.c +++ b/archivers/pax/files/pax.c @@ -1,4 +1,4 @@ -/* $NetBSD: pax.c,v 1.6 2004/06/20 10:11:02 grant Exp $ */ +/* $NetBSD: pax.c,v 1.7 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,20 +36,21 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__COPYRIGHT) && !defined(lint) +#if !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\ The Regents of the University of California. All rights reserved.\n"); -#endif /* not lint */ - -#if defined(__RCSID) && !defined(lint) #if 0 static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: pax.c,v 1.6 2004/06/20 10:11:02 grant Exp $"); +__RCSID("$NetBSD: pax.c,v 1.7 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ @@ -368,9 +369,11 @@ sig_cleanup(int which_sig) * will clearly see the message on a line by itself. */ vflag = vfpart = 1; +#ifdef SIGXCPU if (which_sig == SIGXCPU) tty_warn(0, "CPU time limit reached, cleaning up."); else +#endif tty_warn(0, "Signal caught, cleaning up."); /* delete any open temporary file */ @@ -447,11 +450,23 @@ gen_init(void) */ if ((sigemptyset(&s_mask) < 0) || (sigaddset(&s_mask, SIGTERM) < 0) || (sigaddset(&s_mask,SIGINT) < 0)||(sigaddset(&s_mask,SIGHUP) < 0) || - (sigaddset(&s_mask,SIGPIPE) < 0)||(sigaddset(&s_mask,SIGQUIT)<0) || - (sigaddset(&s_mask,SIGXCPU) < 0)||(sigaddset(&s_mask,SIGXFSZ)<0)) { + (sigaddset(&s_mask,SIGPIPE) < 0)||(sigaddset(&s_mask,SIGQUIT)<0)){ + tty_warn(1, "Unable to set up signal mask"); + return(-1); + } +#ifdef SIGXCPU + if (sigaddset(&s_mask,SIGXCPU) < 0) { + tty_warn(1, "Unable to set up signal mask"); + return(-1); + } +#endif +#ifdef SIGXFSZ + if (sigaddset(&s_mask,SIGXFSZ) < 0) { tty_warn(1, "Unable to set up signal mask"); return(-1); } +#endif + memset(&n_hand, 0, sizeof n_hand); n_hand.sa_mask = s_mask; n_hand.sa_flags = 0; @@ -477,15 +492,19 @@ gen_init(void) (sigaction(SIGQUIT, &o_hand, &o_hand) < 0)) goto out; +#ifdef SIGXCPU if ((sigaction(SIGXCPU, &n_hand, &o_hand) < 0) && (o_hand.sa_handler == SIG_IGN) && (sigaction(SIGXCPU, &o_hand, &o_hand) < 0)) goto out; - +#endif n_hand.sa_handler = SIG_IGN; - if ((sigaction(SIGPIPE, &n_hand, &o_hand) < 0) || - (sigaction(SIGXFSZ, &n_hand, &o_hand) < 0)) + if (sigaction(SIGPIPE, &n_hand, &o_hand) < 0) goto out; +#ifdef SIGXFSZ + if (sigaction(SIGXFSZ, &n_hand, &o_hand) < 0) + goto out; +#endif return(0); out: diff --git a/archivers/pax/files/pax.h b/archivers/pax/files/pax.h index 843d91f066b..ce3b02333da 100644 --- a/archivers/pax/files/pax.h +++ b/archivers/pax/files/pax.h @@ -1,4 +1,4 @@ -/* $NetBSD: pax.h,v 1.7 2004/06/20 10:11:02 grant Exp $ */ +/* $NetBSD: pax.h,v 1.8 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -37,14 +37,10 @@ #if HAVE_CONFIG_H #include "config.h" -#else -#define HAVE_LUTIMES 1 -#define HAVE_STRUCT_STAT_ST_FLAGS 1 -#define HAVE_SYS_MTIO_H 1 #endif /* Tape support only available if one of the following is available. */ -#if (HAVE_SYS_MTIO_H || HAVE_SYS_TAPE_H) && ! defined(UNIXWARE) +#if (HAVE_SYS_MTIO_H || HAVE_SYS_TAPE_H) && !defined(UNIXWARE) #define SUPPORT_TAPE 1 #endif diff --git a/archivers/pax/files/pax2nbcompat b/archivers/pax/files/pax2nbcompat new file mode 100755 index 00000000000..97f3d6b3d28 --- /dev/null +++ b/archivers/pax/files/pax2nbcompat @@ -0,0 +1,62 @@ +#!/bin/sh +# +# $NetBSD: pax2nbcompat,v 1.1 2004/08/21 03:28:56 jlam Exp $ +# +# Copyright (c) 2004 The NetBSD Foundation, Inc. +# All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Johnny C. Lam. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +if [ $# -lt 1 ]; then echo "pax2nbcompat dest"; exit 1; fi + +: ${PKGSRCDIR:=/usr/pkgsrc} +: ${BSDSRCDIR:=/usr/src} + +if [ ! -d "${BSDSRCDIR}" ]; then + echo "${BSDSRCDIR} doesn't exist" + exit 1 +fi + +src2nbcompat="${PKGSRCDIR}/pkgtools/libnbcompat/files/src2nbcompat" +dest=$1 + +$src2nbcompat ${BSDSRCDIR}/bin/pax $dest +$src2nbcompat ${BSDSRCDIR}/bin/ls/stat_flags.c $dest/stat_flags.c +$src2nbcompat ${BSDSRCDIR}/bin/ls/stat_flags.h $dest/stat_flags.h +$src2nbcompat ${BSDSRCDIR}/sbin/mknod/pack_dev.c $dest/pack_dev.c +$src2nbcompat ${BSDSRCDIR}/sbin/mknod/pack_dev.h $dest/pack_dev.h +$src2nbcompat ${BSDSRCDIR}/usr.sbin/mtree/extern.h $dest/mtree_extern.h +$src2nbcompat ${BSDSRCDIR}/usr.sbin/mtree/mtree.h $dest/mtree.h +$src2nbcompat ${BSDSRCDIR}/usr.sbin/mtree/getid.c $dest/getid.c +$src2nbcompat ${BSDSRCDIR}/usr.sbin/mtree/misc.c $dest/misc.c +$src2nbcompat ${BSDSRCDIR}/usr.sbin/mtree/spec.c $dest/spec.c diff --git a/archivers/pax/files/sel_subs.c b/archivers/pax/files/sel_subs.c index b415f75f154..28070fa103c 100644 --- a/archivers/pax/files/sel_subs.c +++ b/archivers/pax/files/sel_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: sel_subs.c,v 1.3 2003/12/20 04:45:04 grant Exp $ */ +/* $NetBSD: sel_subs.c,v 1.4 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,15 +36,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)sel_subs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: sel_subs.c,v 1.3 2003/12/20 04:45:04 grant Exp $"); +__RCSID("$NetBSD: sel_subs.c,v 1.4 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ diff --git a/archivers/pax/files/spec.c b/archivers/pax/files/spec.c index 44285d8883d..9e0aa928541 100644 --- a/archivers/pax/files/spec.c +++ b/archivers/pax/files/spec.c @@ -1,4 +1,4 @@ -/* $NetBSD: spec.c,v 1.1 2003/09/05 18:40:55 jlam Exp $ */ +/* $NetBSD: spec.c,v 1.2 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -30,7 +30,7 @@ */ /*- - * Copyright (c) 2001-2002 The NetBSD Foundation, Inc. + * Copyright (c) 2001-2004 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -68,6 +68,10 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> @@ -76,7 +80,7 @@ #if 0 static char sccsid[] = "@(#)spec.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: spec.c,v 1.1 2003/09/05 18:40:55 jlam Exp $"); +__RCSID("$NetBSD: spec.c,v 1.2 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ @@ -114,25 +118,31 @@ __RCSID("$NetBSD: spec.c,v 1.1 2003/09/05 18:40:55 jlam Exp $"); #if HAVE_VIS_H #include <vis.h> #endif +#if HAVE_UTIL_H +#include <util.h> +#endif #include "mtree_extern.h" #include "pack_dev.h" size_t mtree_lineno; /* Current spec line number */ -int Wflag; /* Don't "whack" permissions */ +int mtree_Mflag; /* Merge duplicate entries */ +int mtree_Wflag; /* Don't "whack" permissions */ static dev_t parsedev(char *); static void replacenode(NODE *, NODE *); static void set(char *, NODE *); static void unset(char *, NODE *); +#define REPLACEPTR(x,v) do { if ((x)) free((x)); (x) = (v); } while (0) + NODE * spec(FILE *fp) { NODE *centry, *last, *pathparent, *cur; char *p, *e, *next; NODE ginfo, *root; - char *buf, *tname; + char *buf, *tname, *ntname; size_t tnamelen, plen; root = NULL; @@ -190,9 +200,10 @@ noparent: mtree_err("no parent node"); plen = strlen(p) + 1; if (plen > tnamelen) { - tnamelen = plen; - if ((tname = realloc(tname, tnamelen)) == NULL) + if ((ntname = realloc(tname, plen)) == NULL) mtree_err("realloc: %s", strerror(errno)); + tname = ntname; + tnamelen = plen; } if (strunvis(tname, p) == -1) mtree_err("strunvis failed on `%s'", p); @@ -296,6 +307,27 @@ noparent: mtree_err("no parent node"); return (root); } +void +free_nodes(NODE *root) +{ + NODE *cur, *next; + + if (root == NULL) + return; + + next = NULL; + for (cur = root; cur != NULL; cur = next) { + next = cur->next; + free_nodes(cur->child); + REPLACEPTR(cur->slink, NULL); + REPLACEPTR(cur->md5digest, NULL); + REPLACEPTR(cur->rmd160digest, NULL); + REPLACEPTR(cur->sha1digest, NULL); + REPLACEPTR(cur->tags, NULL); + REPLACEPTR(cur, NULL); + } +} + /* * dump_nodes -- * dump the NODEs from `cur', based in the directory `dir'. @@ -402,6 +434,7 @@ parsedev(char *arg) int argc; pack_t *pack; dev_t result; + const char *error = NULL; if ((dev = strchr(arg, ',')) != NULL) { *dev++='\0'; @@ -420,7 +453,9 @@ parsedev(char *arg) } if (argc < 2) mtree_err("not enough arguments"); - result = (*pack)(argc, numbers); + result = (*pack)(argc, numbers, &error); + if (error != NULL) + mtree_err(error); } else { result = (dev_t)strtoul(arg, &ep, 0); if (*ep != '\0') @@ -433,11 +468,26 @@ static void replacenode(NODE *cur, NODE *new) { - if (cur->type != new->type) - mtree_err("existing entry type `%s' does not match type `%s'", - nodetype(cur->type), nodetype(new->type)); #define REPLACE(x) cur->x = new->x -#define REPLACESTR(x) if (cur->x) free(cur->x); cur->x = new->x +#define REPLACESTR(x) REPLACEPTR(cur->x,new->x) + + if (cur->type != new->type) { + if (mtree_Mflag) { + /* + * merge entries with different types; we + * don't want children retained in this case. + */ + REPLACE(type); + free_nodes(cur->child); + cur->child = NULL; + } else { + mtree_err( + "existing entry for `%s', type `%s'" + " does not match type `%s'", + cur->name, nodetype(cur->type), + nodetype(new->type)); + } + } REPLACE(st_size); REPLACE(st_mtimespec); @@ -503,7 +553,7 @@ set(char *t, NODE *ip) mtree_err("invalid gid `%s'", val); break; case F_GNAME: - if (Wflag) /* don't parse if whacking */ + if (mtree_Wflag) /* don't parse if whacking */ break; if (gid_from_group(val, &gid) == -1) mtree_err("unknown group `%s'", val); @@ -584,7 +634,7 @@ set(char *t, NODE *ip) mtree_err("invalid uid `%s'", val); break; case F_UNAME: - if (Wflag) /* don't parse if whacking */ + if (mtree_Wflag) /* don't parse if whacking */ break; if (uid_from_user(val, &uid) == -1) mtree_err("unknown user `%s'", val); diff --git a/archivers/pax/files/stat_flags.c b/archivers/pax/files/stat_flags.c index 6500c349ced..3a9d4db510d 100644 --- a/archivers/pax/files/stat_flags.c +++ b/archivers/pax/files/stat_flags.c @@ -1,4 +1,4 @@ -/* $NetBSD: stat_flags.c,v 1.1 2003/09/05 18:40:55 jlam Exp $ */ +/* $NetBSD: stat_flags.c,v 1.2 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1993 @@ -32,24 +32,22 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)stat_flags.c 8.2 (Berkeley) 7/28/94"; #else -__RCSID("$NetBSD: stat_flags.c,v 1.1 2003/09/05 18:40:55 jlam Exp $"); +__RCSID("$NetBSD: stat_flags.c,v 1.2 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ -#if HAVE_CONFIG_H -#include "config.h" -#else -#define HAVE_STRUCT_STAT_ST_FLAGS 1 -#endif - #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif @@ -103,6 +101,10 @@ flags_to_string(u_long flags, const char *def) SAPPEND("arch"); if (flags & SF_IMMUTABLE) SAPPEND("schg"); +#ifdef SF_SNAPSHOT + if (flags & SF_SNAPSHOT) + SAPPEND("snap"); +#endif #endif if (prefix == NULL) strlcpy(string, def, sizeof(string)); diff --git a/archivers/pax/files/tables.c b/archivers/pax/files/tables.c index 070415b4a3c..4bbef99bdb5 100644 --- a/archivers/pax/files/tables.c +++ b/archivers/pax/files/tables.c @@ -1,4 +1,4 @@ -/* $NetBSD: tables.c,v 1.3 2003/12/20 04:45:04 grant Exp $ */ +/* $NetBSD: tables.c,v 1.4 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,15 +36,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: tables.c,v 1.3 2003/12/20 04:45:04 grant Exp $"); +__RCSID("$NetBSD: tables.c,v 1.4 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ diff --git a/archivers/pax/files/tar.c b/archivers/pax/files/tar.c index 75f18f3a3c8..14cbd7562d5 100644 --- a/archivers/pax/files/tar.c +++ b/archivers/pax/files/tar.c @@ -1,4 +1,4 @@ -/* $NetBSD: tar.c,v 1.8 2004/06/20 10:11:02 grant Exp $ */ +/* $NetBSD: tar.c,v 1.9 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,15 +36,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: tar.c,v 1.8 2004/06/20 10:11:02 grant Exp $"); +__RCSID("$NetBSD: tar.c,v 1.9 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ @@ -1328,10 +1332,12 @@ tar_gnutar_exclude_one(const char *line, size_t len) else if (line[i] == '?') { sbuf[j++] = '.'; continue; - } else if (!isalnum(line[i]) && !isblank(line[i])) + } else if (!isalnum((unsigned char)line[i]) && + !isblank((unsigned char)line[i])) sbuf[j++] = '\\'; sbuf[j++] = line[i]; } + sbuf[j] = '\0'; /* don't need the .*\/ ones if we start with /, i guess */ if (line[0] != '/') { (void)snprintf(rabuf, sizeof rabuf, "/.*\\/%s$//", sbuf); diff --git a/archivers/pax/files/tty_subs.c b/archivers/pax/files/tty_subs.c index 51b337ce49c..ee34a76696a 100644 --- a/archivers/pax/files/tty_subs.c +++ b/archivers/pax/files/tty_subs.c @@ -1,4 +1,4 @@ -/* $NetBSD: tty_subs.c,v 1.3 2003/12/20 04:45:04 grant Exp $ */ +/* $NetBSD: tty_subs.c,v 1.4 2004/08/21 03:28:56 jlam Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -36,15 +36,19 @@ #if HAVE_CONFIG_H #include "config.h" #endif +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include <nbcompat.h> #if HAVE_SYS_CDEFS_H #include <sys/cdefs.h> #endif -#if defined(__RCSID) && !defined(lint) +#if !defined(lint) #if 0 static char sccsid[] = "@(#)tty_subs.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: tty_subs.c,v 1.3 2003/12/20 04:45:04 grant Exp $"); +__RCSID("$NetBSD: tty_subs.c,v 1.4 2004/08/21 03:28:56 jlam Exp $"); #endif #endif /* not lint */ |