Add -q. this will cause the warning messages about missing
directories to not be printed. This is from OpenBSD (and I think NetBSD also) and makes our mtree more compatible with other BSDs. This makes cross compilation easier than it was before. Other changes will be needed to allow NetBSD or OpenBSD to cross build on FreeBSD, but this is a start. Reviewed by: andrey Obtained from: OpenBSD Concentric Red Circles by: My own stupidity
This commit is contained in:
parent
da010626df
commit
c96eb6d2e8
@ -40,7 +40,7 @@
|
||||
.Nd map a directory hierarchy
|
||||
.Sh SYNOPSIS
|
||||
.Nm mtree
|
||||
.Op Fl PUcdeinrux
|
||||
.Op Fl PUcdeinqrux
|
||||
.Bk -words
|
||||
.Op Fl f Ar spec
|
||||
.Ek
|
||||
@ -100,6 +100,11 @@ a comment is emitted before each directory and before the close of that
|
||||
directory when using the
|
||||
.Fl c
|
||||
option.
|
||||
.It Fl q
|
||||
Quiet mode. Do not complain when a
|
||||
.Dq missing
|
||||
directory can not be created because it is already exists.
|
||||
This occurs when the directory is a symbolic link.
|
||||
.It Fl r
|
||||
Remove any files in the file hierarchy that are not described in the
|
||||
specification.
|
||||
|
@ -58,7 +58,7 @@ static const char rcsid[] =
|
||||
extern long int crc_total;
|
||||
|
||||
int ftsoptions = FTS_LOGICAL;
|
||||
int cflag, dflag, eflag, iflag, nflag, rflag, sflag, uflag, Uflag;
|
||||
int cflag, dflag, eflag, iflag, nflag, qflag, rflag, sflag, uflag, Uflag;
|
||||
u_int keys;
|
||||
char fullpath[MAXPATHLEN];
|
||||
|
||||
@ -112,6 +112,9 @@ main(argc, argv)
|
||||
case 'p':
|
||||
dir = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
qflag = 1;
|
||||
break;
|
||||
case 'P':
|
||||
ftsoptions ^= FTS_LOGICAL;
|
||||
ftsoptions |= FTS_PHYSICAL;
|
||||
@ -167,7 +170,7 @@ static void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: mtree [-PUcdeinrux] [-f spec] [-K key] [-k key] [-p path] [-s seed]\n"
|
||||
"usage: mtree [-PUcdeinqrux] [-f spec] [-K key] [-k key] [-p path] [-s seed]\n"
|
||||
"\t[-X excludes]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ static const char rcsid[] =
|
||||
|
||||
extern long int crc_total;
|
||||
extern int ftsoptions;
|
||||
extern int dflag, eflag, rflag, sflag, uflag;
|
||||
extern int dflag, eflag, qflag, rflag, sflag, uflag;
|
||||
extern char fullpath[MAXPATHLEN];
|
||||
extern int lineno;
|
||||
|
||||
@ -171,8 +171,16 @@ miss(p, tail)
|
||||
if (p->type != F_DIR && (dflag || p->flags & F_VISIT))
|
||||
continue;
|
||||
(void)strcpy(tail, p->name);
|
||||
if (!(p->flags & F_VISIT))
|
||||
(void)printf("missing: %s", path);
|
||||
if (!(p->flags & F_VISIT)) {
|
||||
/* Don't print missing message if file exists as a
|
||||
symbolic link and the -q flag is set. */
|
||||
struct stat statbuf;
|
||||
|
||||
if (qflag && stat(path, &statbuf) == 0)
|
||||
p->flags |= F_VISIT;
|
||||
else
|
||||
(void)printf("missing: %s", path);
|
||||
}
|
||||
if (p->type != F_DIR && p->type != F_LINK) {
|
||||
putchar('\n');
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user