diff --git a/ChangeLog b/ChangeLog index 563b8ab8..e2b3ffbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,9 @@ is of type struct timespec, not time_t. (parse_used): Likewise. (parse_time): Likewise. + * find/pred.c (pred_timewindow): in the COMP_EQ case, accept times + exactly at the end of the window and do not accept times exactly + at the start (reversing the previous treatment of the bounds). * find/testsuite/Makefile.am (EXTRA_DIST_EXP): Added test for -mtime 0; find.posix/mtime0.{exp,xo}. * NEWS: mention this bugfix. diff --git a/find/pred.c b/find/pred.c index bc26b588..d62a950f 100644 --- a/find/pred.c +++ b/find/pred.c @@ -273,7 +273,7 @@ compare_ts(struct timespec ts1, * Returns true if THE_TIME is * COMP_GT: after the specified time * COMP_LT: before the specified time - * COMP_EQ: less than WINDOW seconds after the specified time. + * COMP_EQ: after the specified time but by not more than WINDOW seconds. */ static boolean pred_timewindow(struct timespec ts, struct predicate const *pred_ptr, int window) @@ -288,8 +288,21 @@ pred_timewindow(struct timespec ts, struct predicate const *pred_ptr, int window case COMP_EQ: { + /* consider "find . -mtime 0". + * + * Here, the origin is exactly 86400 seconds before the start + * of the program (since -daystart was not specified). This + * function will be called with window=86400 and + * pred_ptr->args.reftime.ts as the origin. Hence a file + * created the instant the program starts will show a time + * difference (value of delta) of 86400. Similarly, a file + * created exactly 24h ago would be the newest file which was + * _not_ created today. So, if delta is 0.0, the file + * was not created today. If the delta is 86400, the file + * was created this instant. + */ double delta = ts_difference(ts, pred_ptr->args.reftime.ts); - return (delta >= 0.0 && delta < window); + return (delta > 0.0 && delta <= window); } } assert (0); diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am index 0f98e0c0..2f1ac65f 100644 --- a/find/testsuite/Makefile.am +++ b/find/testsuite/Makefile.am @@ -78,6 +78,7 @@ find.posix/links.xo \ find.posix/sv-bug-11175.xo \ find.posix/sv-bug-12181.xo \ find.posix/depth1.xo \ +find.posix/mtime0.xo \ find.posix/sizes.xo \ find.posix/name.xo \ find.posix/nameslash.xo \