Date: Sat, 11 Oct 1997 17:02:42 +0200 (MET DST) From: Wolfram Schneider <wosch@cs.tu-berlin.de> To: current@freebsd.org Subject: find primaries -mmin, -amin, -cmin Message-ID: <199710111502.RAA00932@panke.panke.de>
next in thread | raw e-mail | index | archive | help
This patch add the primaries -mmin, -amin, -cmin to find,
similar to the GNU find.
Index: extern.h
===================================================================
RCS file: /usr/cvs/src/usr.bin/find/extern.h,v
retrieving revision 1.4
diff -u -r1.4 extern.h
--- extern.h 1997/08/29 23:09:39 1.4
+++ extern.h 1997/10/11 09:34:07
@@ -47,7 +47,9 @@
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_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));
Index: find.1
===================================================================
RCS file: /usr/cvs/src/usr.bin/find/find.1,v
retrieving revision 1.11
diff -u -r1.11 find.1
--- find.1 1997/08/29 23:09:41 1.11
+++ find.1 1997/10/11 09:46:34
@@ -131,12 +131,25 @@
.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 @@
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
Index: find.h
===================================================================
RCS file: /usr/cvs/src/usr.bin/find/find.h,v
retrieving revision 1.4
diff -u -r1.4 find.h
--- find.h 1997/08/29 23:09:42 1.4
+++ find.h 1997/10/11 09:33:42
@@ -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
Index: function.c
===================================================================
RCS file: /usr/cvs/src/usr.bin/find/function.c,v
retrieving revision 1.11
diff -u -r1.11 function.c
--- function.c 1997/01/28 13:18:46 1.11
+++ function.c 1997/10/11 09:38:36
@@ -126,6 +126,38 @@
++((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 @@
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 @@
return (new);
}
+
/*
* -depth functions --
*
@@ -593,6 +659,38 @@
TIME_CORRECT(new, N_MTIME);
return (new);
}
+
+/*
+ * -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 --
Index: option.c
===================================================================
RCS file: /usr/cvs/src/usr.bin/find/option.c,v
retrieving revision 1.3
diff -u -r1.3 option.c
--- option.c 1996/10/04 12:54:07 1.3
+++ option.c 1997/10/11 09:29:20
@@ -58,7 +58,9 @@
{ ")", 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 },
@@ -69,6 +71,7 @@
{ "-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 },
--
Wolfram Schneider <wosch@apfel.de> http://www.apfel.de/~wosch/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199710111502.RAA00932>
