From 7a3cd410f3a16da94524b5c7e8e18c0f38f820dd Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 5 Nov 2003 22:26:08 +0000 Subject: Give mtree(8) the ability to take [two -f spec] arguments and compare the two specifications to each other. --- usr.sbin/mtree/mtree.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'usr.sbin/mtree/mtree.c') 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); } -- cgit v1.1