- 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)
This commit is contained in:
lukem 2002-02-02 12:34:39 +00:00
parent 711fef427b
commit 6ee4925cf5
3 changed files with 48 additions and 21 deletions

View File

@ -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
# XXX not yet!
# MAN= pax.1 tar.1 cpio.1
# LINKS+= ${BINDIR}/pax ${BINDIR}/tar
# LINKS+= ${BINDIR}/pax ${BINDIR}/cpio
tar.c tty_subs.c
.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

View File

@ -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 @@ __RCSID("$NetBSD: ftree.c,v 1.17 2002/01/31 22:43:35 tv Exp $");
#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 *fttail = NULL; /* tail of linked list of file args */
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 @@ int
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 @@ ftree_start(void)
}
return(0);
}
#endif /* SMALL */
/*
* set up the operation mode of fts, open the first file arg. We must
@ -405,17 +411,20 @@ ftree_arg(void)
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 @@ next_file(ARCHD *arcn)
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 @@ next_file(ARCHD *arcn)
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 @@ next_file(ARCHD *arcn)
} 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 @@ next_file(ARCHD *arcn)
continue;
}
#ifndef SMALL
got_ftent:
#endif /* SMALL */
/*
* ok got a file tree node to process. copy info into arcn
* structure (initialize as required)

View File

@ -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 @@ __RCSID("$NetBSD: options.c,v 1.38 2002/01/31 22:43:35 tv Exp $");
#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 @@ pax_options(int argc, char **argv)
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_options(int argc, char **argv)
pax_usage();
}
break;
#endif /* !SMALL */
case 'O':
/*
* Force one volume. Non standard option.