Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/find find(1): Compare timestamp in nsec scale in -an...



details:   https://anonhg.NetBSD.org/src/rev/443109fe997c
branches:  trunk
changeset: 786629:443109fe997c
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Sat May 04 06:29:32 2013 +0000

description:
find(1): Compare timestamp in nsec scale in -anewer/-cnewer/-newer.

diffstat:

 usr.bin/find/find.h     |   5 ++++-
 usr.bin/find/function.c |  19 +++++++++++--------
 2 files changed, 15 insertions(+), 9 deletions(-)

diffs (129 lines):

diff -r a55a81d3cc4c -r 443109fe997c usr.bin/find/find.h
--- a/usr.bin/find/find.h       Sat May 04 06:26:44 2013 +0000
+++ b/usr.bin/find/find.h       Sat May 04 06:29:32 2013 +0000
@@ -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 @@
                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 @@
 #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
diff -r a55a81d3cc4c -r 443109fe997c usr.bin/find/function.c
--- a/usr.bin/find/function.c   Sat May 04 06:26:44 2013 +0000
+++ b/usr.bin/find/function.c   Sat May 04 06:29:32 2013 +0000
@@ -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 @@
 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 @@
        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 @@
        TIME_CORRECT(new, N_ATIME);
        return (new);
 }
+
 /*
  * -cmin n functions --
  *
@@ -304,7 +305,7 @@
 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 @@
        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 @@
        new->min_data = atoi(arg);
        return (new);
 }
+
 /*
  * -mmin n functions --
  *
@@ -1239,6 +1241,7 @@
        TIME_CORRECT(new, N_MMIN);
        return (new);
 }
+
 /*
  * -mtime n functions --
  *
@@ -1327,7 +1330,7 @@
 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 @@
        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);
 }
 



Home | Main Index | Thread Index | Old Index