diff options
author | Marc Espie <espie@cvs.openbsd.org> | 1999-03-17 17:36:31 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 1999-03-17 17:36:31 +0000 |
commit | c9110c14acb8acd5982ff60e15ff39880b636c71 (patch) | |
tree | dfd4b33efa4388d6ede9bae83e2906281d531a9e | |
parent | da80b969266b1dc4a1512202f550bd045cb66323 (diff) |
Add -W option so -type W gets a chance to work.
-rw-r--r-- | usr.bin/find/find.1 | 18 | ||||
-rw-r--r-- | usr.bin/find/function.c | 6 | ||||
-rw-r--r-- | usr.bin/find/main.c | 11 |
3 files changed, 25 insertions, 10 deletions
diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1 index 5dd5a6e2aae..21ecd372532 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: find.1,v 1.18 1999/02/24 10:25:45 deraadt Exp $ +.\" $OpenBSD: find.1,v 1.19 1999/03/17 17:36:30 espie Exp $ .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -43,7 +43,7 @@ .Nd walk a file hierarchy .Sh SYNOPSIS .Nm find -.Op Fl HdhXx +.Op Fl HdhXxW .Op Fl f Ar file .Op Ar file ... .Ar expression @@ -110,9 +110,13 @@ argument to .Xr xargs 1 . .It Fl x Prevents -.Nm find +.Nm from descending into directories that have a device number different than that of the file from which the descent began. +.It Fl W +Let +.Nm +take whiteouts into account when scanning directories. .El .Sh PRIMARIES .Bl -tag -width Ds @@ -330,7 +334,8 @@ Possible file types are as follows: .Pp .Bl -tag -width flag -offset indent -compact .It Cm W -whiteout +whiteout (currently, these won't even be visible without also specifying +.Fl W ) .It Cm b block special .It Cm c @@ -497,3 +502,8 @@ These problems are handled by the option and the .Xr getopt 3 ``--'' construct. +.Pp +The +.Fl W +option is probably not the most elegant way to handle whiteouts, it may +be replaced by a more sophisticated algorithm eventually. diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index d7f4c6bf4f3..0237c2a3a37 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -1,4 +1,4 @@ -/* $OpenBSD: function.c,v 1.12 1998/09/26 09:04:43 deraadt Exp $ */ +/* $OpenBSD: function.c,v 1.13 1999/03/17 17:36:30 espie Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -38,7 +38,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)function.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: function.c,v 1.12 1998/09/26 09:04:43 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: function.c,v 1.13 1999/03/17 17:36:30 espie Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -1170,6 +1170,8 @@ c_type(typestring) #ifdef S_IFWHT case 'W': mask = S_IFWHT; + if ((ftsoptions & FTS_WHITEOUT) == 0) + warnx("-type W without -W is a no-op"); break; #endif case 'b': diff --git a/usr.bin/find/main.c b/usr.bin/find/main.c index fc12f0bccf0..c03a38b08eb 100644 --- a/usr.bin/find/main.c +++ b/usr.bin/find/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.7 1997/06/17 05:53:44 millert Exp $ */ +/* $OpenBSD: main.c,v 1.8 1999/03/17 17:36:30 espie Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -35,7 +35,7 @@ #ifndef lint /*static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: main.c,v 1.7 1997/06/17 05:53:44 millert Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.8 1999/03/17 17:36:30 espie Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -78,7 +78,7 @@ main(argc, argv) sigaction(SIGINFO, &sa, NULL); ftsoptions = FTS_NOSTAT|FTS_PHYSICAL; - while ((ch = getopt(argc, argv, "Hdf:hXx")) != -1) + while ((ch = getopt(argc, argv, "Hdf:hXxW")) != -1) switch(ch) { case 'H': ftsoptions |= FTS_COMFOLLOW; @@ -100,6 +100,9 @@ main(argc, argv) ftsoptions &= ~FTS_NOSTAT; ftsoptions |= FTS_XDEV; break; + case 'W': + ftsoptions |= FTS_WHITEOUT; + break; case '?': default: break; @@ -137,6 +140,6 @@ static void usage() { (void)fprintf(stderr, - "usage: find [-HdhXx] [-f file] [file ...] expression\n"); + "usage: find [-HdhXxW] [-f file] [file ...] expression\n"); exit(1); } |