Module Name: src
Committed By: uebayasi
Date: Sat May 4 06:29:32 UTC 2013
Modified Files:
src/usr.bin/find: find.h function.c
Log Message:
find(1): Compare timestamp in nsec scale in -anewer/-cnewer/-newer.
To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/find/find.h
cvs rdiff -u -r1.71 -r1.72 src/usr.bin/find/function.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/find/find.h
diff -u src/usr.bin/find/find.h:1.24 src/usr.bin/find/find.h:1.25
--- src/usr.bin/find/find.h:1.24 Tue Feb 6 13:25:01 2007
+++ src/usr.bin/find/find.h Sat May 4 06:29:32 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: find.h,v 1.24 2007/02/06 13:25:01 elad Exp $ */
+/* $NetBSD: find.h,v 1.25 2013/05/04 06:29:32 uebayasi Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -35,6 +35,7 @@
*/
#include <regex.h>
+#include <time.h>
/* node type */
enum ntype {
@@ -71,6 +72,7 @@ typedef struct _plandata {
nlink_t _l_data; /* link count */
off_t _o_data; /* file size */
time_t _t_data; /* time value */
+ struct timespec _ts_data; /* time value */
uid_t _u_data; /* uid */
short _mt_data; /* mount flags */
struct _plandata *_p_data[2]; /* PLAN trees */
@@ -106,6 +108,7 @@ typedef struct _plandata {
#define o_data p_un._o_data
#define p_data p_un._p_data
#define t_data p_un._t_data
+#define ts_data p_un._ts_data
#define u_data p_un._u_data
#define e_argv p_un.ex._e_argv
#define e_orig p_un.ex._e_orig
Index: src/usr.bin/find/function.c
diff -u src/usr.bin/find/function.c:1.71 src/usr.bin/find/function.c:1.72
--- src/usr.bin/find/function.c:1.71 Sun Aug 26 14:26:37 2012
+++ src/usr.bin/find/function.c Sat May 4 06:29:32 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: function.c,v 1.71 2012/08/26 14:26:37 wiz Exp $ */
+/* $NetBSD: function.c,v 1.72 2013/05/04 06:29:32 uebayasi Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "from: @(#)function.c 8.10 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: function.c,v 1.71 2012/08/26 14:26:37 wiz Exp $");
+__RCSID("$NetBSD: function.c,v 1.72 2013/05/04 06:29:32 uebayasi Exp $");
#endif
#endif /* not lint */
@@ -218,7 +218,7 @@ int
f_anewer(PLAN *plan, FTSENT *entry)
{
- return (entry->fts_statp->st_atime > plan->t_data);
+ return timespeccmp(&entry->fts_statp->st_atim, &plan->ts_data, >);
}
PLAN *
@@ -234,7 +234,7 @@ c_anewer(char ***argvp, int isok)
if (stat(filename, &sb))
err(1, "%s", filename);
new = palloc(N_ANEWER, f_anewer);
- new->t_data = sb.st_atime;
+ new->ts_data = sb.st_atim;
return (new);
}
@@ -265,6 +265,7 @@ c_atime(char ***argvp, int isok)
TIME_CORRECT(new, N_ATIME);
return (new);
}
+
/*
* -cmin n functions --
*
@@ -304,7 +305,7 @@ int
f_cnewer(PLAN *plan, FTSENT *entry)
{
- return (entry->fts_statp->st_ctime > plan->t_data);
+ return timespeccmp(&entry->fts_statp->st_ctim, &plan->ts_data, >);
}
PLAN *
@@ -320,7 +321,7 @@ c_cnewer(char ***argvp, int isok)
if (stat(filename, &sb))
err(1, "%s", filename);
new = palloc(N_CNEWER, f_cnewer);
- new->t_data = sb.st_ctime;
+ new->ts_data = sb.st_ctim;
return (new);
}
@@ -1212,6 +1213,7 @@ c_mindepth(char ***argvp, int isok)
new->min_data = atoi(arg);
return (new);
}
+
/*
* -mmin n functions --
*
@@ -1239,6 +1241,7 @@ c_mmin(char ***argvp, int isok)
TIME_CORRECT(new, N_MMIN);
return (new);
}
+
/*
* -mtime n functions --
*
@@ -1327,7 +1330,7 @@ int
f_newer(PLAN *plan, FTSENT *entry)
{
- return (entry->fts_statp->st_mtime > plan->t_data);
+ return timespeccmp(&entry->fts_statp->st_mtim, &plan->ts_data, >);
}
PLAN *
@@ -1343,7 +1346,7 @@ c_newer(char ***argvp, int isok)
if (stat(filename, &sb))
err(1, "%s", filename);
new = palloc(N_NEWER, f_newer);
- new->t_data = sb.st_mtime;
+ new->ts_data = sb.st_mtim;
return (new);
}