Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/bin/pax Pullup rev 1.40-1.73 (requested by rafal in tic...



details:   https://anonhg.NetBSD.org/src/rev/647464005231
branches:  netbsd-1-6
changeset: 531270:647464005231
user:      jmc <jmc%NetBSD.org@localhost>
date:      Wed Apr 07 06:58:00 2004 +0000

description:
Pullup rev 1.40-1.73 (requested by rafal in ticket #1021)

Pullup pax to current version on trunk. Includes many fixes.

diffstat:

 bin/pax/options.c |  903 +++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 665 insertions(+), 238 deletions(-)

diffs (truncated from 1401 to 300 lines):

diff -r 811a42f6c2aa -r 647464005231 bin/pax/options.c
--- a/bin/pax/options.c Wed Apr 07 06:57:54 2004 +0000
+++ b/bin/pax/options.c Wed Apr 07 06:58:00 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: options.c,v 1.39 2002/02/02 12:34:39 lukem Exp $       */
+/*     $NetBSD: options.c,v 1.39.2.1 2004/04/07 06:58:00 jmc Exp $     */
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -16,11 +16,7 @@
  * 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 University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -37,12 +33,16 @@
  * SUCH DAMAGE.
  */
 
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
 #include <sys/cdefs.h>
-#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.39 2002/02/02 12:34:39 lukem Exp $");
+__RCSID("$NetBSD: options.c,v 1.39.2.1 2004/04/07 06:58:00 jmc Exp $");
 #endif
 #endif /* not lint */
 
@@ -52,12 +52,14 @@
 #include <sys/mtio.h>
 #include <sys/param.h>
 #include <ctype.h>
+#include <errno.h>
 #include <getopt.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <paths.h>
 #include "pax.h"
 #include "options.h"
 #include "cpio.h"
@@ -71,18 +73,16 @@
  * Routines which handle command line options
  */
 
-int cpio_mode;                 /* set if we are in cpio mode */
-
 static int nopids;             /* tar mode: suppress "pids" for -p option */
 static char *flgch = FLGCH;    /* list of all possible flags (pax) */
 static OPLIST *ophead = NULL;  /* head for format specific options -x */
 static OPLIST *optail = NULL;  /* option tail */
-static char *firstminusC;      /* first -C argument encountered. */
 
 static int no_op(void);
 static void printflg(unsigned int);
 static int c_frmt(const void *, const void *);
 static off_t str_offt(char *);
+static char *getline(FILE *fp);
 static void pax_options(int, char **);
 static void pax_usage(void);
 static void tar_options(int, char **);
@@ -90,12 +90,36 @@
 static void cpio_options(int, char **);
 static void cpio_usage(void);
 
-static void checkpositionalminusC(char ***, int (*)(char *, int));
+/* errors from getline */
+#define GETLINE_FILE_CORRUPT 1
+#define GETLINE_OUT_OF_MEM 2
+static int getline_error;
 
+#define BZIP2_CMD      "bzip2"         /* command to run as bzip2 */
 #define GZIP_CMD       "gzip"          /* command to run as gzip */
 #define COMPRESS_CMD   "compress"      /* command to run as compress */
 
 /*
+ * Long options.
+ */
+#define        OPT_USE_COMPRESS_PROGRAM        0
+#define        OPT_CHECKPOINT                  1
+#define        OPT_UNLINK                      2
+#define        OPT_HELP                        3
+#define        OPT_ATIME_PRESERVE              4
+#define        OPT_IGNORE_FAILED_READ          5
+#define        OPT_REMOVE_FILES                6
+#define        OPT_NULL                        7
+#define        OPT_TOTALS                      8
+#define        OPT_VERSION                     9
+#define        OPT_EXCLUDE                     10
+#define        OPT_BLOCK_COMPRESS              11
+#define        OPT_NORECURSE                   12
+#define        OPT_FORCE_LOCAL                 13
+#define        OPT_INSECURE                    14
+#define        OPT_STRICT                      15
+
+/*
  *     Format specific routine table - MUST BE IN SORTED ORDER BY NAME
  *     (see pax.h for description of each function)
  *
@@ -145,7 +169,7 @@
 
 /*
  * ford is the archive search order used by get_arc() to determine what kind
- * of archive we are dealing with. This helps to properly id  archive formats
+ * of archive we are dealing with. This helps to properly id archive formats
  * some formats may be subsets of others....
  */
 int ford[] = {F_USTAR, F_TAR, F_SV4CRC, F_SV4CPIO, F_CPIO, F_BCPIO, -1};
@@ -178,6 +202,13 @@
        }
 }
 
+struct option pax_longopts[] = {
+       { "insecure",           no_argument,            0,
+                                               OPT_INSECURE },
+       { "force-local",        no_argument,            0,
+                                               OPT_FORCE_LOCAL },
+};
+
 /*
  * pax_options()
  *     look at the user specified flags. set globals as required and check if
@@ -197,8 +228,9 @@
        /*
         * process option flags
         */
-       while ((c = getopt(argc, argv,
-           "ab:cdf:iklno:p:rs:tuvwx:zAB:DE:G:HLMN:OPT:U:XYZ")) != -1) {
+       while ((c = getopt_long(argc, argv,
+           "ab:cdf:ijklno:p:rs:tuvwx:zAB:DE:G:HLMN:OPT:U:XYZ",
+           pax_longopts, NULL)) != -1) {
                switch (c) {
                case 'a':
                        /*
@@ -244,6 +276,13 @@
                        iflag = 1;
                        flg |= IF;
                        break;
+               case 'j':
+                       /*
+                        * pass through bzip2
+                        */
+                       jflag = 1;
+                       gzip_program = BZIP2_CMD;
+                       break;
                case 'k':
                        /*
                         * do not clobber files that exist
@@ -324,8 +363,8 @@
                                        pmode = 1;
                                        break;
                                default:
-                                       tty_warn(1,
-                                           "Invalid -p string: %c", *pt);
+                                       tty_warn(1, "Invalid -p string: %c",
+                                           *pt);
                                        pax_usage();
                                        break;
                                }
@@ -397,7 +436,6 @@
                        /*
                         * use gzip.  Non standard option.
                         */
-                       zflag = 1;
                        gzip_program = GZIP_CMD;
                        break;
                case 'A':
@@ -553,6 +591,12 @@
                        Zflag = 1;
                        flg |= CZF;
                        break;
+               case OPT_INSECURE:
+                       secure = 0;
+                       break;
+               case OPT_FORCE_LOCAL:
+                       forcelocal = 0;
+                       break;
                case '?':
                default:
                        pax_usage();
@@ -567,6 +611,7 @@
         */
        if (ISLIST(flg)) {
                act = LIST;
+               listf = stdout;
                bflg = flg & BDLIST;
        } else if (ISEXTRACT(flg)) {
                act = EXTRACT;
@@ -602,7 +647,7 @@
        case LIST:
        case EXTRACT:
                for (; optind < argc; optind++)
-                       if (pat_add(argv[optind], 0) < 0)
+                       if (pat_add(argv[optind], NULL) < 0)
                                pax_usage();
                break;
        case COPY:
@@ -612,6 +657,8 @@
                }
                --argc;
                dirptr = argv[argc];
+               if (mkpath(dirptr) < 0)
+                       pax_usage();
                /* FALLTHROUGH */
        case ARCHIVE:
        case APPND:
@@ -633,27 +680,15 @@
  *     the user specified a legal set of flags. If not, complain and exit
  */
 
-#define        OPT_USE_COMPRESS_PROGRAM        0
-#define        OPT_CHECKPOINT                  1
-#define        OPT_UNLINK                      2
-#define        OPT_HELP                        3
-#define        OPT_ATIME_PRESERVE              4
-#define        OPT_FAST_READ                   5
-#define        OPT_IGNORE_FAILED_READ          6
-#define        OPT_REMOVE_FILES                7
-#define        OPT_NULL                        8
-#define        OPT_TOTALS                      9
-#define        OPT_VERSION                     10
-#define        OPT_EXCLUDE                     11
-#define        OPT_BLOCK_COMPRESS              12
-#define        OPT_NORECURSE                   13
-
 struct option tar_longopts[] = {
        { "block-size",         required_argument,      0,      'b' },
+       { "bunzip2",            no_argument,            0,      'j' },
+       { "bzip2",              no_argument,            0,      'j' },
        { "create",             no_argument,            0,      'c' },  /* F */
        /* -e -- no corresponding long option */
        { "file",               required_argument,      0,      'f' },
        { "dereference",        no_argument,            0,      'h' },
+       { "keep-old-files",     no_argument,            0,      'k' },
        { "one-file-system",    no_argument,            0,      'l' },
        { "modification-time",  no_argument,            0,      'm' },
        { "old-archive",        no_argument,            0,      'o' },
@@ -661,6 +696,7 @@
        { "same-permissions",   no_argument,            0,      'p' },
        { "preserve-permissions", no_argument,          0,      'p' },
        { "preserve",           no_argument,            0,      'p' },
+       { "fast-read",          no_argument,            0,      'q' },
        { "append",             no_argument,            0,      'r' },  /* F */
        { "update",             no_argument,            0,      'u' },  /* F */
        { "list",               no_argument,            0,      't' },  /* F */
@@ -673,17 +709,26 @@
        { "gunzip",             no_argument,            0,      'z' },
        { "read-full-blocks",   no_argument,            0,      'B' },
        { "directory",          required_argument,      0,      'C' },
-       { "tape-length",        required_argument,      0,      'L' },
+       { "to-stdout",          no_argument,            0,      'O' },
        { "absolute-paths",     no_argument,            0,      'P' },
+       { "files-from",         required_argument,      0,      'T' },
        { "exclude-from",       required_argument,      0,      'X' },
        { "compress",           no_argument,            0,      'Z' },
        { "uncompress",         no_argument,            0,      'Z' },
+       { "strict",             no_argument,            0,
+                                               OPT_STRICT },
        { "atime-preserve",     no_argument,            0,
                                                OPT_ATIME_PRESERVE },
        { "unlink",             no_argument,            0,
                                                OPT_UNLINK },
        { "use-compress-program", required_argument,    0,
                                                OPT_USE_COMPRESS_PROGRAM },
+       { "force-local",        no_argument,            0,
+                                               OPT_FORCE_LOCAL },
+       { "insecure",           no_argument,            0,
+                                               OPT_INSECURE },
+       { "exclude",            required_argument,      0,
+                                               OPT_EXCLUDE },
 #if 0 /* Not implemented */
        { "catenate",           no_argument,            0,      'A' },  /* F */
        { "concatenate",        no_argument,            0,      'A' },  /* F */
@@ -695,26 +740,22 @@
                                                OPT_HELP },
        { "info-script",        required_argument,      0,      'F' },
        { "new-volume-script",  required_argument,      0,      'F' },
-       { "fast-read",          no_argument,            0,
-                                               OPT_FAST_READ },
        { "incremental",        no_argument,            0,      'G' },
        { "listed-incremental", required_argument,      0,      'g' },
        { "ignore-zeros",       no_argument,            0,      'i' },
        { "ignore-failed-read", no_argument,            0,
                                                OPT_IGNORE_FAILED_READ },
-       { "keep-old-files",     no_argument,            0,      'k' },



Home | Main Index | Thread Index | Old Index