Merge from Lite2 - use new getvfsbyname() and related changes.
understand whiteouts (FTS_W from fts()).
This commit is contained in:
parent
6f0a860fc1
commit
841484cd42
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=23695
@ -2,5 +2,6 @@
|
||||
|
||||
PROG= find
|
||||
SRCS= find.c function.c ls.c main.c misc.c operator.c option.c
|
||||
CFLAGS+=-D_NEW_VFSCONF
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -32,10 +32,10 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" @(#)find.1 8.4 (Berkeley) 4/1/94
|
||||
.\" $Id$
|
||||
.\" @(#)find.1 8.7 (Berkeley) 5/9/95
|
||||
.\" $Id: find.1,v 1.6 1997/02/22 19:55:03 peter Exp $
|
||||
.\"
|
||||
.Dd April 1, 1994
|
||||
.Dd May 9, 1995
|
||||
.Dt FIND 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -165,9 +165,14 @@ was executed.
|
||||
.It Ic -fstype Ar type
|
||||
True if the file is contained in a file system of type
|
||||
.Ar type .
|
||||
Currently supported types are ``local'', ``mfs'', ``nfs'', ``msdos'',
|
||||
``rdonly'' and ``ufs''.
|
||||
The types ``local'' and ``rdonly'' are not specific file system types.
|
||||
The
|
||||
.Xr sysctl 8
|
||||
command can be used to find out the types of filesystems
|
||||
that are available on the system:
|
||||
.Bd -literal -offset indent
|
||||
sysctl vfs
|
||||
.Ed
|
||||
In addition, there are two pseudo-types, ``local'' and ``rdonly''.
|
||||
The former matches any file system physically mounted on the system where
|
||||
the
|
||||
.Nm find
|
||||
@ -204,7 +209,7 @@ True if the difference between the file last modification time and the time
|
||||
was started, rounded up to the next full 24\-hour period, is
|
||||
.Ar n
|
||||
24\-hour periods.
|
||||
.It Ic \&-ok Ar utility Ns Op argument ... ;
|
||||
.It Ic \&-ok Ar utility Op argument ... ;
|
||||
The
|
||||
.Ic \&-ok
|
||||
primary is identical to the
|
||||
@ -273,13 +278,15 @@ Note, the first character of a symbolic mode may not be a dash (``\-'').
|
||||
.It Ic -print
|
||||
This primary always evaluates to true.
|
||||
It prints the pathname of the current file to standard output.
|
||||
The expression is appended to the user specified expression if none of
|
||||
If none of
|
||||
.Ic -exec ,
|
||||
.Ic -ls ,
|
||||
.Ic -print0 ,
|
||||
or
|
||||
.Ic \&-ok
|
||||
are specified.
|
||||
is specified, the given expression shall be effectively replaced by
|
||||
.Cm \&( Ns Ar given\& expression Ns Cm \&)
|
||||
.Ic -print .
|
||||
.It Ic -print0
|
||||
This primary always evaluates to true.
|
||||
It prints the pathname of the current file to standard output, followed by a
|
||||
|
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)find.c 8.3 (Berkeley) 4/1/94";
|
||||
static char sccsid[] = "@(#)find.c 8.5 (Berkeley) 8/5/94";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -90,15 +90,14 @@ find_formplan(argv)
|
||||
|
||||
/*
|
||||
* if the user didn't specify one of -print, -ok or -exec, then -print
|
||||
* is assumed so we add a -print node on the end. It is possible that
|
||||
* the user might want the -print someplace else on the command line,
|
||||
* but there's no way to know that.
|
||||
* is assumed so we bracket the current expression with parens, if
|
||||
* necessary, and add a -print node on the end.
|
||||
*/
|
||||
if (!isoutput) {
|
||||
new = c_print();
|
||||
if (plan == NULL)
|
||||
if (plan == NULL) {
|
||||
new = c_print();
|
||||
tail = plan = new;
|
||||
else {
|
||||
} else {
|
||||
new = c_openparen();
|
||||
new->next = plan;
|
||||
plan = new;
|
||||
@ -177,6 +176,10 @@ find_execute(plan, paths)
|
||||
entry->fts_path, strerror(entry->fts_errno));
|
||||
rval = 1;
|
||||
continue;
|
||||
#ifdef FTS_W
|
||||
case FTS_W:
|
||||
continue;
|
||||
#endif /* FTS_W */
|
||||
}
|
||||
#define BADCH " \t\n\\'\""
|
||||
if (isxargs && strpbrk(entry->fts_path, BADCH)) {
|
||||
|
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)function.c 8.6 (Berkeley) 4/1/94";
|
||||
static char sccsid[] = "@(#)function.c 8.10 (Berkeley) 5/4/95";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -375,18 +375,15 @@ f_fstype(plan, entry)
|
||||
}
|
||||
|
||||
first = 0;
|
||||
switch (plan->flags) {
|
||||
case F_MTFLAG:
|
||||
val = sb.f_flags;
|
||||
break;
|
||||
case F_MTTYPE:
|
||||
val = sb.f_type;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
||||
/*
|
||||
* Further tests may need both of these values, so
|
||||
* always copy both of them.
|
||||
*/
|
||||
val = sb.f_flags;
|
||||
val = sb.f_type;
|
||||
}
|
||||
switch(plan->flags) {
|
||||
switch (plan->flags) {
|
||||
case F_MTFLAG:
|
||||
return (val & plan->mt_data);
|
||||
case F_MTTYPE:
|
||||
@ -401,10 +398,21 @@ c_fstype(arg)
|
||||
char *arg;
|
||||
{
|
||||
register PLAN *new;
|
||||
|
||||
struct vfsconf vfc;
|
||||
|
||||
ftsoptions &= ~FTS_NOSTAT;
|
||||
|
||||
new = palloc(N_FSTYPE, f_fstype);
|
||||
|
||||
/*
|
||||
* Check first for a filesystem name.
|
||||
*/
|
||||
if (getvfsbyname(arg, &vfc) == 0) {
|
||||
new->flags = F_MTTYPE;
|
||||
new->mt_data = vfc.vfc_typenum;
|
||||
return (new);
|
||||
}
|
||||
|
||||
switch (*arg) {
|
||||
case 'l':
|
||||
if (!strcmp(arg, "local")) {
|
||||
@ -413,24 +421,6 @@ c_fstype(arg)
|
||||
return (new);
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
if (!strcmp(arg, "mfs")) {
|
||||
new->flags = F_MTTYPE;
|
||||
new->mt_data = MOUNT_MFS;
|
||||
return (new);
|
||||
} else if (!strcmp(arg, "msdos")) {
|
||||
new->flags = F_MTTYPE;
|
||||
new->mt_data = MOUNT_MSDOS;
|
||||
return (new);
|
||||
}
|
||||
break;
|
||||
case 'n':
|
||||
if (!strcmp(arg, "nfs")) {
|
||||
new->flags = F_MTTYPE;
|
||||
new->mt_data = MOUNT_NFS;
|
||||
return (new);
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
if (!strcmp(arg, "rdonly")) {
|
||||
new->flags = F_MTFLAG;
|
||||
@ -438,13 +428,6 @@ c_fstype(arg)
|
||||
return (new);
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
if (!strcmp(arg, "ufs")) {
|
||||
new->flags = F_MTTYPE;
|
||||
new->mt_data = MOUNT_UFS;
|
||||
return (new);
|
||||
}
|
||||
break;
|
||||
}
|
||||
errx(1, "%s: unknown file type", arg);
|
||||
/* NOTREACHED */
|
||||
@ -881,9 +864,9 @@ c_size(arg)
|
||||
/*
|
||||
* -type c functions --
|
||||
*
|
||||
* True if the type of the file is c, where c is b, c, d, p, or f for
|
||||
* block special file, character special file, directory, FIFO, or
|
||||
* regular file, respectively.
|
||||
* True if the type of the file is c, where c is b, c, d, p, f or w
|
||||
* for block special file, character special file, directory, FIFO,
|
||||
* regular file or whiteout respectively.
|
||||
*/
|
||||
int
|
||||
f_type(plan, entry)
|
||||
@ -924,6 +907,12 @@ c_type(typestring)
|
||||
case 's':
|
||||
mask = S_IFSOCK;
|
||||
break;
|
||||
#ifdef FTS_WHITEOUT
|
||||
case 'w':
|
||||
mask = S_IFWHT;
|
||||
ftsoptions |= FTS_WHITEOUT;
|
||||
break;
|
||||
#endif /* FTS_WHITEOUT */
|
||||
default:
|
||||
errx(1, "-type: %s: unknown type", typestring);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ char copyright[] =
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 4/16/94";
|
||||
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -55,6 +55,7 @@ static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 4/16/94";
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "find.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user