bin/144411: [patch] mtree(8) doesn't reject non-regular files
for -X
Garrett Cooper
gcooper at FreeBSD.org
Wed Oct 13 07:20:07 UTC 2010
The following reply was made to PR bin/144411; it has been noted by GNATS.
From: Garrett Cooper <gcooper at FreeBSD.org>
To: bug-followup <bug-followup at freebsd.org>
Cc: Bruce Evans <brde at optusnet.com.au>
Subject: Re: bin/144411: [patch] mtree(8) doesn't reject non-regular files for -X
Date: Wed, 13 Oct 2010 00:18:06 -0700
--001636c933da11631d04927a65d8
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Forwarding the feedback received so the information gets captured in th=
e PR.
Thanks for the help with the review Bruce!
-Garrett
---------- Forwarded message ----------
From: Bruce Evans <brde at optusnet.com.au>
Date: Tue, Oct 12, 2010 at 9:02 PM
Subject: Re: bin/144411: [patch] mtree(8) doesn't reject non-regular
files for -X
To: Garrett Cooper <gcooper at freebsd.org>
Cc: Bruce Evans <brde at optusnet.com.au>, freebsd-bugs at freebsd.org
On Sun, 10 Oct 2010, Garrett Cooper wrote:
> ...
> =A0 I've been sitting on this PR for a while and I'd like to wrap it
> up and move on, if that's ok. Here's a patch with a more suitable
> comment above the stat(2) call.
% Index: usr.sbin/mtree/excludes.c
% =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
% --- usr.sbin/mtree/excludes.c (revision 213667)
% +++ usr.sbin/mtree/excludes.c (working copy)
% @@ -30,9 +30,10 @@
% =A0#include <sys/cdefs.h>
% =A0__FBSDID("$FreeBSD$");
% % +#include <sys/queue.h>
% +#include <sys/stat.h>
% +#include <sys/time.h> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* XXX for mtree.h =
*/
% =A0#include <sys/types.h>
% -#include <sys/time.h> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* XXX for mtree.h =
*/
% -#include <sys/queue.h>
% % =A0#include <err.h>
% =A0#include <fnmatch.h>
% @@ -63,11 +64,22 @@
% =A0void
% =A0read_excludes_file(const char *name)
% =A0{
% + =A0 =A0 struct stat exclude_stat;
% + =A0 =A0 struct exclude *e;
% =A0 =A0 =A0 FILE *fp;
% =A0 =A0 =A0 char *line, *str;
% - =A0 =A0 struct exclude *e;
% =A0 =A0 =A0 size_t len;
% % + =A0 /* % + =A0 * Make sure that the path we're dealing with points
to a regular file,
% + =A0 =A0 =A0* because the exclude list should be a regular file, not a d=
irectory,
% + =A0 =A0 =A0* etc.
% + =A0 =A0 =A0*/
% + =A0 =A0 if (stat(name, &exclude_stat) !=3D 0)
% + =A0 =A0 =A0 =A0 =A0 =A0 err(EXIT_FAILURE, "stat: %s", name);
% + =A0 =A0 if (!S_ISREG(exclude_stat.st_mode))
% + =A0 =A0 =A0 =A0 =A0 =A0 errx(EXIT_FAILURE, "invalid exclude file: %s", =
name);
% +
% =A0 =A0 =A0 fp =3D fopen(name, "r");
% =A0 =A0 =A0 if (fp =3D=3D 0)
% =A0 =A0 =A0 =A0 =A0 =A0 =A0 err(1, "%s", name);
I like the main part of the patch.
The reordering of the includes may be premature or incomplete. =A0Old
sources include <sys/types.h> first since it was a prerequisite for
all POSIX headers, and most FreeBSD man pages and style(9) still say
to do this although POSIX dropped this requirement in 2001 or earlier
and FreeBSD mostly removed this requirement in ~2002-2003. =A0So now,
the include of <sys/types.h> might not be needed at all, but it is
hard to tell since there is so much pollution in other headers. =A0I
would keep the include of <sys/types.h> first if it is kept.
Bruce
--001636c933da11631d04927a65d8
Content-Type: text/plain; charset=US-ASCII; name="bin.144411.diff.txt"
Content-Disposition: attachment; filename="bin.144411.diff.txt"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gf7v7you0
SW5kZXg6IHVzci5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