summaryrefslogtreecommitdiffstats
path: root/usr.bin/find
diff options
context:
space:
mode:
authorwosch <wosch@FreeBSD.org>1997-10-13 21:06:22 +0000
committerwosch <wosch@FreeBSD.org>1997-10-13 21:06:22 +0000
commit167c2cb9c3c9ae837756bf47957aa71eecf7ef6b (patch)
tree8412d8eac3f6df718e95e7ddc727292a339517a5 /usr.bin/find
parent2afa55ca386e52677c9f53098ccb3c3d8a217936 (diff)
downloadFreeBSD-src-167c2cb9c3c9ae837756bf47957aa71eecf7ef6b.zip
FreeBSD-src-167c2cb9c3c9ae837756bf47957aa71eecf7ef6b.tar.gz
Add the primaries -mmin, -amin, -cmin to find, similar to the GNU find.
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/extern.h3
-rw-r--r--usr.bin/find/find.121
-rw-r--r--usr.bin/find/find.h6
-rw-r--r--usr.bin/find/function.c98
-rw-r--r--usr.bin/find/option.c3
5 files changed, 128 insertions, 3 deletions
diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h
index 6567583..b587015 100644
--- a/usr.bin/find/extern.h
+++ b/usr.bin/find/extern.h
@@ -47,7 +47,9 @@ struct stat;
void printlong __P((char *, char *, struct stat *));
int queryuser __P((char **));
+PLAN *c_amin __P((char *));
PLAN *c_atime __P((char *));
+PLAN *c_cmin __P((char *));
PLAN *c_ctime __P((char *));
PLAN *c_delete __P((void));
PLAN *c_depth __P((void));
@@ -74,6 +76,7 @@ PLAN *c_user __P((char *));
PLAN *c_xdev __P((void));
PLAN *c_openparen __P((void));
PLAN *c_closeparen __P((void));
+PLAN *c_mmin __P((char *));
PLAN *c_mtime __P((char *));
PLAN *c_not __P((void));
PLAN *c_or __P((void));
diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1
index 680810e..3ad2800 100644
--- a/usr.bin/find/find.1
+++ b/usr.bin/find/find.1
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)find.1 8.7 (Berkeley) 5/9/95
-.\" $Id: find.1,v 1.10 1997/05/19 18:16:00 jdp Exp $
+.\" $Id: find.1,v 1.11 1997/08/29 23:09:41 imp Exp $
.\"
.Dd May 9, 1995
.Dt FIND 1
@@ -131,12 +131,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
@@ -214,6 +227,12 @@ 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 -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 349883a..33b00ad 100644
--- a/usr.bin/find/find.h
+++ b/usr.bin/find/find.h
@@ -39,8 +39,10 @@
/* node type */
enum ntype {
N_AND = 1, /* must start > 0 */
- N_ATIME, N_CLOSEPAREN, N_CTIME, N_DEPTH, N_EXEC, N_EXECDIR, N_EXPR,
- N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MTIME, N_NAME,
+ N_AMIN, N_ATIME, N_CLOSEPAREN, N_CMIN, N_CTIME, N_DEPTH,
+ N_EXEC, N_EXECDIR, N_EXPR,
+ N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MMIN,
+ 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_PRUNE, N_SIZE, N_TYPE, N_USER, N_XDEV,
N_PRINT0, N_DELETE
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index 46f3771..7c552ef 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -126,6 +126,38 @@ 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
@@ -155,6 +187,39 @@ 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 --
*
@@ -186,6 +251,7 @@ c_ctime(arg)
return (new);
}
+
/*
* -depth functions --
*
@@ -678,6 +744,38 @@ 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 9977cc2..53ac0fb 100644
--- a/usr.bin/find/option.c
+++ b/usr.bin/find/option.c
@@ -58,7 +58,9 @@ static OPTION const 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 },
{ "-delete", N_DELETE, c_delete, O_ZERO },
{ "-depth", N_DEPTH, c_depth, O_ZERO },
@@ -70,6 +72,7 @@ static OPTION const 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 },
{ "-mtime", N_MTIME, c_mtime, O_ARGV },
{ "-name", N_NAME, c_name, O_ARGV },
{ "-newer", N_NEWER, c_newer, O_ARGV },
OpenPOWER on IntegriCloud