summaryrefslogtreecommitdiffstats
path: root/usr.bin/find
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-03-11 13:48:37 +0000
committerpeter <peter@FreeBSD.org>1997-03-11 13:48:37 +0000
commitcfb813cdf2dd92bfd0fef347dc2f940a1f6a2ae3 (patch)
treefe5d4664a370535b99fc058f6c681ce1fb92b085 /usr.bin/find
parentc399e58e973651508fa2987cff6cf8af682eb322 (diff)
downloadFreeBSD-src-cfb813cdf2dd92bfd0fef347dc2f940a1f6a2ae3.zip
FreeBSD-src-cfb813cdf2dd92bfd0fef347dc2f940a1f6a2ae3.tar.gz
Merge from Lite2 - use new getvfsbyname() and related changes.
understand whiteouts (FTS_W from fts()).
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/Makefile1
-rw-r--r--usr.bin/find/find.125
-rw-r--r--usr.bin/find/find.c17
-rw-r--r--usr.bin/find/function.c71
-rw-r--r--usr.bin/find/main.c3
5 files changed, 59 insertions, 58 deletions
diff --git a/usr.bin/find/Makefile b/usr.bin/find/Makefile
index c305d6a..af1ea26 100644
--- a/usr.bin/find/Makefile
+++ b/usr.bin/find/Makefile
@@ -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>
diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1
index dfccf38..c832a4a 100644
--- a/usr.bin/find/find.1
+++ b/usr.bin/find/find.1
@@ -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
diff --git a/usr.bin/find/find.c b/usr.bin/find/find.c
index d69b098..8afadf8b 100644
--- a/usr.bin/find/find.c
+++ b/usr.bin/find/find.c
@@ -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)) {
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index 73014fd..5a6a069 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -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);
}
diff --git a/usr.bin/find/main.c b/usr.bin/find/main.c
index c7110ab..b62cdf3 100644
--- a/usr.bin/find/main.c
+++ b/usr.bin/find/main.c
@@ -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"
OpenPOWER on IntegriCloud