Source-Changes-HG archive

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

[src/trunk]: src/bin/pax - don't compile in support for -M (mtree specfile in...



details:   https://anonhg.NetBSD.org/src/rev/7918c007f135
branches:  trunk
changeset: 521634:7918c007f135
user:      lukem <lukem%NetBSD.org@localhost>
date:      Sat Feb 02 12:34:39 2002 +0000

description:
- don't compile in support for -M (mtree specfile input) or -N dbdir
  (alternate directory for id info) if SMALL is defined
- enable -DSMALL and remove unused objects if CRUNCHEDPROG is defined
- minor cleanup in next_file() (preparation for future work)

diffstat:

 bin/pax/Makefile  |  20 ++++++++++++--------
 bin/pax/ftree.c   |  36 +++++++++++++++++++++++++-----------
 bin/pax/options.c |  13 +++++++++++--
 3 files changed, 48 insertions(+), 21 deletions(-)

diffs (219 lines):

diff -r 412df64f0428 -r 7918c007f135 bin/pax/Makefile
--- a/bin/pax/Makefile  Sat Feb 02 12:27:01 2002 +0000
+++ b/bin/pax/Makefile  Sat Feb 02 12:34:39 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.16 2002/01/29 10:20:28 tv Exp $
+#      $NetBSD: Makefile,v 1.17 2002/02/02 12:34:39 lukem Exp $
 #       @(#)Makefile   8.1 (Berkeley) 5/31/93
 
 # To install on versions prior to BSD 4.4 the following may have to be
@@ -28,20 +28,24 @@
 PROG=   pax
 SRCS=  ar_io.c ar_subs.c buf_subs.c cpio.c file_subs.c ftree.c\
        gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
-       tar.c tty_subs.c \
-       getid.c spec.c misc.c stat_flags.c pack_dev.c
+       tar.c tty_subs.c
 
-# XXX not yet!
-# MAN= pax.1 tar.1 cpio.1
-# LINKS+=      ${BINDIR}/pax ${BINDIR}/tar
-# LINKS+=      ${BINDIR}/pax ${BINDIR}/cpio
-
+.ifdef CRUNCHEDPROG
+CPPFLAGS+=     -DSMALL
+.else
+SRCS+=         getid.c spec.c misc.c stat_flags.c pack_dev.c
 CPPFLAGS+=     -I${.CURDIR}/../../usr.sbin/mtree \
                -I${.CURDIR}/../../sbin/mknod \
                -I${.CURDIR}/../../bin/ls
 .PATH:         ${.CURDIR}/../../usr.sbin/mtree \
                ${.CURDIR}/../../sbin/mknod \
                ${.CURDIR}/../../bin/ls
+.endif
+
+# XXX not yet!
+# MAN= pax.1 tar.1 cpio.1
+# LINKS+=      ${BINDIR}/pax ${BINDIR}/tar
+# LINKS+=      ${BINDIR}/pax ${BINDIR}/cpio
 
 NOHTML=doc2html-error
 
diff -r 412df64f0428 -r 7918c007f135 bin/pax/ftree.c
--- a/bin/pax/ftree.c   Sat Feb 02 12:27:01 2002 +0000
+++ b/bin/pax/ftree.c   Sat Feb 02 12:34:39 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftree.c,v 1.17 2002/01/31 22:43:35 tv Exp $    */
+/*     $NetBSD: ftree.c,v 1.18 2002/02/02 12:34:39 lukem Exp $ */
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -78,7 +78,7 @@
 #if 0
 static char sccsid[] = "@(#)ftree.c    8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: ftree.c,v 1.17 2002/01/31 22:43:35 tv Exp $");
+__RCSID("$NetBSD: ftree.c,v 1.18 2002/02/02 12:34:39 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -96,7 +96,9 @@
 #include "pax.h"
 #include "ftree.h"
 #include "extern.h"
+#ifndef SMALL
 #include "mtree.h"
+#endif /* SMALL */
 
 /*
  * routines to interface with the fts library function.
@@ -120,7 +122,9 @@
 static FTREE *ftcur = NULL;            /* current file arg being processed */
 static FTSENT *ftent = NULL;           /* current file tree entry */
 static int ftree_skip;                 /* when set skip to next file arg */
+#ifndef SMALL
 static NODE *ftnode = NULL;            /* mtree(8) specfile; used by -M */
+#endif /* SMALL */
 
 static int ftree_arg(void);
 
@@ -144,6 +148,7 @@
 ftree_start(void)
 {
 
+#ifndef SMALL
        /*
         * if -M is given, the list of filenames on stdin is actually
         * an mtree(8) specfile, so parse the specfile into a NODE *
@@ -164,6 +169,7 @@
                }
                return(0);
        }
+#endif /* SMALL */
 
        /*
         * set up the operation mode of fts, open the first file arg. We must
@@ -405,17 +411,20 @@
 int
 next_file(ARCHD *arcn)
 {
+#ifndef SMALL
        static  char    curdir[PAXPATHLEN+2], curpath[PAXPATHLEN+2];
        static  int     curdirlen;
 
        struct stat     statbuf;
        FTSENT          Mftent;
+#endif /* SMALL */
        int             cnt;
        time_t          atime, mtime;
        char            *curlink;
 #define MFTENT_DUMMY_DEV       UINT_MAX
 
        curlink = NULL;
+#ifndef SMALL
        /*
         * if parsing an mtree(8) specfile, build up `dummy' ftsent
         * from specfile info, and jump below to complete setup of arcn.
@@ -439,9 +448,9 @@
                Mftent.fts_statp = &statbuf;
                Mftent.fts_pointer = ftnode;
                ftent = &Mftent;
-                                               /* stat existing file */
+                                               /* look for existing file */
                if (lstat(Mftent.fts_path, &statbuf) == -1) {
-                                               /* fake up stat buffer */
+                                               /* missing: fake up stat info */
                        memset(&statbuf, 0, sizeof(statbuf));
                        statbuf.st_dev = MFTENT_DUMMY_DEV;
                        statbuf.st_ino = ftnode->lineno;
@@ -467,14 +476,16 @@
                                NODETEST(ftnode->flags & F_SLINK, "symlink");
                        /* don't require F_FLAGS or F_SIZE */
 #undef NODETEST
-               } else if (ftnode->flags & F_TYPE && 
-                   nodetoino(ftnode->type) != (statbuf.st_mode & S_IFMT)) {
-                       tty_warn(1,
+               } else {
+                       if (ftnode->flags & F_TYPE && nodetoino(ftnode->type)
+                           != (statbuf.st_mode & S_IFMT)) {
+                               tty_warn(1,
                            "line %lu: %s: type mismatch: specfile %s, tree %s",
-                           (u_long)ftnode->lineno, ftent->fts_path,
-                           inotype(nodetoino(ftnode->type)),
-                           inotype(statbuf.st_mode));
-                       return(-1);
+                                   (u_long)ftnode->lineno, ftent->fts_path,
+                                   inotype(nodetoino(ftnode->type)),
+                                   inotype(statbuf.st_mode));
+                               return(-1);
+                       }
                }
                /*
                 * override settings with those from specfile
@@ -534,6 +545,7 @@
                } while (ftnode != NULL && ftnode->flags & F_VISIT);
                goto got_ftent;
        }
+#endif /* SMALL */
 
        /*
         * ftree_sel() might have set the ftree_skip flag if the user has the
@@ -627,7 +639,9 @@
                        continue;
                }
 
+#ifndef SMALL
  got_ftent:
+#endif /* SMALL */
                /*
                 * ok got a file tree node to process. copy info into arcn
                 * structure (initialize as required)
diff -r 412df64f0428 -r 7918c007f135 bin/pax/options.c
--- a/bin/pax/options.c Sat Feb 02 12:27:01 2002 +0000
+++ b/bin/pax/options.c Sat Feb 02 12:34:39 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: options.c,v 1.38 2002/01/31 22:43:35 tv Exp $  */
+/*     $NetBSD: options.c,v 1.39 2002/02/02 12:34:39 lukem Exp $       */
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)options.c  8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: options.c,v 1.38 2002/01/31 22:43:35 tv Exp $");
+__RCSID("$NetBSD: options.c,v 1.39 2002/02/02 12:34:39 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -63,7 +63,9 @@
 #include "cpio.h"
 #include "tar.h"
 #include "extern.h"
+#ifndef SMALL
 #include "mtree.h"
+#endif /* SMALL */
 
 /*
  * Routines which handle command line options
@@ -467,6 +469,12 @@
                        Lflag = 1;
                        flg |= CLF;
                        break;
+#ifdef SMALL
+               case 'M':
+               case 'N':
+                       tty_warn(1, "Support for -%c is not compiled in", c);
+                       exit(1);
+#else  /* !SMALL */
                case 'M':
                        /*
                         * Treat list of filenames on stdin as an
@@ -486,6 +494,7 @@
                                pax_usage();
                        }
                        break;
+#endif /* !SMALL */
                case 'O':
                        /*
                         * Force one volume.  Non standard option.



Home | Main Index | Thread Index | Old Index