diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-11-13 08:30:35 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-11-13 08:30:35 +0000 |
commit | f9f68389af0034cdf15661bc693e77fc1cb925c5 (patch) | |
tree | 779d713933ae1328df3afdf85c078d63bd16223f /usr.bin/find | |
parent | 48eccfca3321f7c88e1a2107e3170d2194904baa (diff) |
Add the primaries -mmin, -amin, -cmin to find, similar to the GNU find; wosch
Diffstat (limited to 'usr.bin/find')
-rw-r--r-- | usr.bin/find/extern.h | 5 | ||||
-rw-r--r-- | usr.bin/find/find.1 | 21 | ||||
-rw-r--r-- | usr.bin/find/find.h | 8 | ||||
-rw-r--r-- | usr.bin/find/function.c | 98 | ||||
-rw-r--r-- | usr.bin/find/option.c | 7 |
5 files changed, 130 insertions, 9 deletions
diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h index cb373cb4e80..df8dd472979 100644 --- a/usr.bin/find/extern.h +++ b/usr.bin/find/extern.h @@ -1,4 +1,4 @@ -/* * $OpenBSD: extern.h,v 1.7 1996/12/23 04:58:08 millert Exp $*/ +/* * $OpenBSD: extern.h,v 1.8 1997/11/13 08:30:32 deraadt Exp $*/ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -50,7 +50,9 @@ void printlong __P((char *, char *, struct stat *)); int queryuser __P((char **)); void show_path __P((int)); +PLAN *c_amin __P((char *)); PLAN *c_atime __P((char *)); +PLAN *c_cmin __P((char *)); PLAN *c_ctime __P((char *)); PLAN *c_depth __P((void)); PLAN *c_empty __P((void)); @@ -64,6 +66,7 @@ PLAN *c_links __P((char *)); PLAN *c_ls __P((void)); PLAN *c_maxdepth __P((char *)); PLAN *c_mindepth __P((char *)); +PLAN *c_mmin __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 b4ad0ab9e37..6dc97135d96 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: find.1,v 1.14 1997/11/04 08:19:32 deraadt Exp $ +.\" $OpenBSD: find.1,v 1.15 1997/11/13 08:30:33 deraadt Exp $ .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -129,12 +129,25 @@ than that of the file from which the descent began. .El .Sh PRIMARIES .Bl -tag -width Ds +.It Ic -amin Ar n +True if the difference between the file last access time and the time +.Nm find +was started, rounded up to the next full minutes period, is +.Ar n +minutes periods. .It Ic -atime Ar n True if the difference between the file last access time and the time .Nm find was started, rounded up to the next full 24\-hour period, is .Ar n 24\-hour periods. +.It Ic -cmin Ar n +True if the difference between the time of last change of file status +information and the time +.Nm find +was started, rounded up to the next full minutes period, is +.Ar n +minutes periods. .It Ic -ctime Ar n True if the difference between the time of last change of file status information and the time @@ -209,6 +222,12 @@ True if the current search depth is less than or equal to what is specified in .It Ic -mindepth Ar n True if the current search depth is at least what is specified in .Ar n . +.It Ic -mmin Ar n +True if the difference between the file last modification time and the time +.Nm find +was started, rounded up to the next full minutes period, is +.Ar n +minutes periods. .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 78a314f37dd..f754a06d421 100644 --- a/usr.bin/find/find.h +++ b/usr.bin/find/find.h @@ -1,4 +1,4 @@ -/* * $OpenBSD: find.h,v 1.6 1996/12/23 04:58:09 millert Exp $*/ +/* * $OpenBSD: find.h,v 1.7 1997/11/13 08:30:33 deraadt Exp $*/ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -40,8 +40,10 @@ /* node type */ enum ntype { N_AND = 1, /* must start > 0 */ - N_ATIME, N_CLOSEPAREN, N_CTIME, N_DEPTH, N_EMPTY, N_EXEC, N_EXECDIR, - N_EXPR, N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MAXDEPTH, + N_AMIN, N_ATIME, N_CLOSEPAREN, N_CMIN, N_CTIME, N_DEPTH, + N_EMPTY, N_EXEC, N_EXECDIR, + N_EXPR, N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, + N_MMIN, N_MAXDEPTH, N_MINDEPTH, 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, diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 92d1a5a1c2a..f1f635c4bee 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -1,4 +1,4 @@ -/* $OpenBSD: function.c,v 1.10 1997/09/01 02:44:19 millert Exp $ */ +/* $OpenBSD: function.c,v 1.11 1997/11/13 08:30:33 deraadt 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.10 1997/09/01 02:44:19 millert Exp $"; +static char rcsid[] = "$OpenBSD: function.c,v 1.11 1997/11/13 08:30:33 deraadt Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -136,6 +136,37 @@ find_parsenum(plan, option, vp, endch) ++((p)->t_data); /* + * -amin n functions -- + * + * True if the difference between the file access time and the + * current time is n min periods. + */ +int +f_amin(plan, entry) + PLAN *plan; + FTSENT *entry; +{ + extern time_t now; + + COMPARE((now - entry->fts_statp->st_atime + + 60 - 1) / 60, plan->t_data); +} + +PLAN * +c_amin(arg) + char *arg; +{ + PLAN *new; + + ftsoptions &= ~FTS_NOSTAT; + + new = palloc(N_AMIN, f_amin); + new->t_data = find_parsenum(new, "-amin", arg, NULL); + TIME_CORRECT(new, N_AMIN); + return (new); +} + +/* * -atime n functions -- * * True if the difference between the file access time and the @@ -164,6 +195,38 @@ c_atime(arg) TIME_CORRECT(new, N_ATIME); return (new); } + +/* + * -cmin n functions -- + * + * True if the difference between the last change of file + * status information and the current time is n min periods. + */ +int +f_cmin(plan, entry) + PLAN *plan; + FTSENT *entry; +{ + extern time_t now; + + COMPARE((now - entry->fts_statp->st_ctime + + 60 - 1) / 60, plan->t_data); +} + +PLAN * +c_cmin(arg) + char *arg; +{ + PLAN *new; + + ftsoptions &= ~FTS_NOSTAT; + + new = palloc(N_CMIN, f_cmin); + new->t_data = find_parsenum(new, "-cmin", arg, NULL); + TIME_CORRECT(new, N_CMIN); + return (new); +} + /* * -ctime n functions -- * @@ -770,6 +833,37 @@ c_mtime(arg) } /* + * -mmin n functions -- + * + * True if the difference between the file modification time and the + * current time is n min periods. + */ +int +f_mmin(plan, entry) + PLAN *plan; + FTSENT *entry; +{ + extern time_t now; + + COMPARE((now - entry->fts_statp->st_mtime + 60 - 1) / + 60, plan->t_data); +} + +PLAN * +c_mmin(arg) + char *arg; +{ + PLAN *new; + + ftsoptions &= ~FTS_NOSTAT; + + new = palloc(N_MMIN, f_mmin); + new->t_data = find_parsenum(new, "-mmin", arg, NULL); + TIME_CORRECT(new, N_MMIN); + return (new); +} + +/* * -name functions -- * * True if the basename of the filename being examined diff --git a/usr.bin/find/option.c b/usr.bin/find/option.c index 13a643098b1..a56767e7e4d 100644 --- a/usr.bin/find/option.c +++ b/usr.bin/find/option.c @@ -1,4 +1,4 @@ -/* $OpenBSD: option.c,v 1.6 1996/12/23 04:58:11 millert Exp $ */ +/* $OpenBSD: option.c,v 1.7 1997/11/13 08:30:34 deraadt 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.6 1996/12/23 04:58:11 millert Exp $"; +static char rcsid[] = "$OpenBSD: option.c,v 1.7 1997/11/13 08:30:34 deraadt Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -59,7 +59,9 @@ static OPTION options[] = { { ")", N_CLOSEPAREN, c_closeparen, O_ZERO }, { "-a", N_AND, NULL, O_NONE }, { "-and", N_AND, NULL, O_NONE }, + { "-amin", N_AMIN, c_amin, O_ARGV }, { "-atime", N_ATIME, c_atime, O_ARGV }, + { "-cmin", N_CMIN, c_cmin, O_ARGV }, { "-ctime", N_CTIME, c_ctime, O_ARGV }, { "-depth", N_DEPTH, c_depth, O_ZERO }, { "-empty", N_EMPTY, c_empty, O_ZERO }, @@ -71,6 +73,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 }, + { "-mmin", N_MMIN, c_mmin, O_ARGV }, { "-maxdepth", N_MAXDEPTH, c_maxdepth, O_ARGV }, { "-mindepth", N_MINDEPTH, c_mindepth, O_ARGV }, { "-mount", N_XDEV, c_xdev, O_ZERO }, |