diff options
Diffstat (limited to 'usr.bin/find')
-rw-r--r-- | usr.bin/find/extern.h | 3 | ||||
-rw-r--r-- | usr.bin/find/find.1 | 7 | ||||
-rw-r--r-- | usr.bin/find/find.h | 8 | ||||
-rw-r--r-- | usr.bin/find/function.c | 33 | ||||
-rw-r--r-- | usr.bin/find/option.c | 5 |
5 files changed, 46 insertions, 10 deletions
diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h index 9e5b9195ad6..d3d3578cb8e 100644 --- a/usr.bin/find/extern.h +++ b/usr.bin/find/extern.h @@ -1,4 +1,4 @@ -/* * $OpenBSD: extern.h,v 1.2 1996/06/26 05:33:07 deraadt Exp $*/ +/* * $OpenBSD: extern.h,v 1.3 1996/08/31 22:40:18 tholo Exp $*/ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -59,6 +59,7 @@ PLAN *c_group __P((char *)); PLAN *c_inum __P((char *)); PLAN *c_links __P((char *)); PLAN *c_ls __P((void)); +PLAN *c_mdepth __P((char *)); PLAN *c_name __P((char *)); PLAN *c_newer __P((char *)); PLAN *c_nogroup __P((void)); diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1 index fee98965338..2bb96ee1c50 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: find.1,v 1.5 1996/06/26 05:33:08 deraadt Exp $ +.\" $OpenBSD: find.1,v 1.6 1996/08/31 22:40:19 tholo Exp $ .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -35,7 +35,7 @@ .\" .\" from: @(#)find.1 8.1 (Berkeley) 6/6/93 .\" -.Dd June 6, 1993 +.Dd August 31, 1996 .Dt FIND 1 .Os .Sh NAME @@ -191,6 +191,9 @@ will be displayed instead of the size in bytes. If the file is a symbolic link, the pathname of the linked\-to file will be displayed preceded by ``\->''. The format is identical to that produced by ``ls \-dgils''. +.It Ic -maxdepth Ar n +True if the current search depth is less than what is specified in +.Ar n . .It Ic -mtime Ar n True if the difference between the file last modification time and the time .Nm find diff --git a/usr.bin/find/find.h b/usr.bin/find/find.h index 1a51ebaf898..829e504c68c 100644 --- a/usr.bin/find/find.h +++ b/usr.bin/find/find.h @@ -1,4 +1,4 @@ -/* * $OpenBSD: find.h,v 1.2 1996/06/26 05:33:09 deraadt Exp $*/ +/* * $OpenBSD: find.h,v 1.3 1996/08/31 22:40:20 tholo Exp $*/ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -41,8 +41,8 @@ enum ntype { N_AND = 1, /* must start > 0 */ N_ATIME, N_CLOSEPAREN, N_CTIME, N_DEPTH, N_EXEC, N_EXPR, N_FOLLOW, - N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MTIME, N_NAME, N_NEWER, - N_NOGROUP, N_NOT, N_NOUSER, N_OK, N_OPENPAREN, N_OR, N_PATH, + N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MDEPTH, N_MTIME, N_NAME, + N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_OK, N_OPENPAREN, N_OR, N_PATH, N_PERM, N_PRINT, N_PRINT0, N_PRUNE, N_SIZE, N_TYPE, N_USER, N_XDEV, }; @@ -77,10 +77,12 @@ typedef struct _plandata { } ex; char *_a_data[2]; /* array of char pointers */ char *_c_data; /* char pointer */ + int _d_data; /* tree depth */ } p_un; } PLAN; #define a_data p_un._a_data #define c_data p_un._c_data +#define d_data p_un._d_data #define i_data p_un._i_data #define g_data p_un._g_data #define l_data p_un._l_data diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 7b7447edf04..707a925b24c 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -1,4 +1,4 @@ -/* $OpenBSD: function.c,v 1.4 1996/06/26 05:33:10 deraadt Exp $ */ +/* $OpenBSD: function.c,v 1.5 1996/08/31 22:40:21 tholo 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.4 1996/06/26 05:33:10 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: function.c,v 1.5 1996/08/31 22:40:21 tholo Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -544,6 +544,35 @@ c_ls() } /* + * - maxdepth n functions -- + * + * True if the current search depth is less than or equal to the + * maximum depth specified + */ +int +f_mdepth(plan, entry) + PLAN *plan; + FTSENT *entry; +{ + extern FTS *tree; + + if (entry->fts_level >= plan->d_data) + fts_set(tree, entry, FTS_SKIP); + return (entry->fts_level <= plan->d_data); +} + +PLAN * +c_mdepth(arg) + char *arg; +{ + PLAN *new; + + new = palloc(N_MDEPTH, f_mdepth); + new->d_data = atoi(arg); + return (new); +} + +/* * -mtime n functions -- * * True if the difference between the file modification time and the diff --git a/usr.bin/find/option.c b/usr.bin/find/option.c index cab351e7738..f9ceb16986a 100644 --- a/usr.bin/find/option.c +++ b/usr.bin/find/option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: option.c,v 1.2 1996/06/26 05:33:13 deraadt Exp $ */ +/* $OpenBSD: option.c,v 1.3 1996/08/31 22:40:22 tholo Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -38,7 +38,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)option.c 8.1 (Berkeley) 6/6/93";*/ -static char rcsid[] = "$OpenBSD: option.c,v 1.2 1996/06/26 05:33:13 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: option.c,v 1.3 1996/08/31 22:40:22 tholo Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -69,6 +69,7 @@ static OPTION options[] = { { "-inum", N_INUM, c_inum, O_ARGV }, { "-links", N_LINKS, c_links, O_ARGV }, { "-ls", N_LS, c_ls, O_ZERO }, + { "-maxdepth", N_MDEPTH, c_mdepth, O_ARGV }, { "-mtime", N_MTIME, c_mtime, O_ARGV }, { "-name", N_NAME, c_name, O_ARGV }, { "-newer", N_NEWER, c_newer, O_ARGV }, |