summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mtree/mtree.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-11-05 22:26:08 +0000
committerphk <phk@FreeBSD.org>2003-11-05 22:26:08 +0000
commit7a3cd410f3a16da94524b5c7e8e18c0f38f820dd (patch)
tree382104a66bfe97e7e359325b15384857b7b59927 /usr.sbin/mtree/mtree.c
parent5ef31a1b16d94984d9191da253117e79cd0a079b (diff)
downloadFreeBSD-src-7a3cd410f3a16da94524b5c7e8e18c0f38f820dd.zip
FreeBSD-src-7a3cd410f3a16da94524b5c7e8e18c0f38f820dd.tar.gz
Give mtree(8) the ability to take [two -f spec] arguments and compare
the two specifications to each other.
Diffstat (limited to 'usr.sbin/mtree/mtree.c')
-rw-r--r--usr.sbin/mtree/mtree.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/usr.sbin/mtree/mtree.c b/usr.sbin/mtree/mtree.c
index 0cc9559..2fe395e 100644
--- a/usr.sbin/mtree/mtree.c
+++ b/usr.sbin/mtree/mtree.c
@@ -64,10 +64,13 @@ main(int argc, char *argv[])
int ch;
char *dir, *p;
int status;
+ FILE *spec1, *spec2;
dir = NULL;
keys = KEYDEFAULT;
init_excludes();
+ spec1 = stdin;
+ spec2 = NULL;
while ((ch = getopt(argc, argv, "cdef:iK:k:LnPp:qrs:UuxX:")) != -1)
switch((char)ch) {
@@ -81,8 +84,16 @@ main(int argc, char *argv[])
eflag = 1;
break;
case 'f':
- if (!(freopen(optarg, "r", stdin)))
- err(1, "%s", optarg);
+ if (spec1 == stdin) {
+ spec1 = fopen(optarg, "r");
+ if (spec1 == NULL)
+ err(1, "%s", optarg);
+ } else if (spec2 == NULL) {
+ spec2 = fopen(optarg, "r");
+ if (spec2 == NULL)
+ err(1, "%s", optarg);
+ } else
+ usage();
break;
case 'i':
iflag = 1;
@@ -157,7 +168,10 @@ main(int argc, char *argv[])
cwalk();
exit(0);
}
- status = mtree_verifyspec(stdin);
+ if (spec2 != NULL)
+ status = mtree_specspec(spec1, spec2);
+ else
+ status = mtree_verifyspec(spec1);
if (Uflag & (status == MISMATCHEXIT))
status = 0;
exit(status);
@@ -167,7 +181,7 @@ static void
usage(void)
{
(void)fprintf(stderr,
-"usage: mtree [-LPUcdeinqrux] [-f spec] [-K key] [-k key] [-p path] [-s seed]\n"
+"usage: mtree [-LPUcdeinqrux] [-f spec] [-f spec] [-K key] [-k key] [-p path] [-s seed]\n"
"\t[-X excludes]\n");
exit(1);
}
OpenPOWER on IntegriCloud