klibc-bot for Martijn Dekker
2019-Jan-25 03:15 UTC
[klibc] [klibc:update-dash] builtin: Greater resolution in test -nt / test -ot
Commit-ID: bae97a14a3dab910cd57c1d36003b18a869f788f Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=bae97a14a3dab910cd57c1d36003b18a869f788f Author: Martijn Dekker <martijn at inlv.org> AuthorDate: Wed, 7 Mar 2018 17:32:29 +0000 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Fri, 25 Jan 2019 02:57:21 +0000 [klibc] builtin: Greater resolution in test -nt / test -ot Op 07-03-18 om 15:46 schreef Martijn Dekker:> Op 06-03-18 om 09:19 schreef Herbert Xu: >> On Thu, Jun 22, 2017 at 10:30:02AM +0200, Petr Sko??k wrote: >>> would you be willing to pull something like this? > [...] >>> I could use greater resolution in `test -nt` / `test -ot`, and st_mtim >>> field is standardized under POSIX.1-2008 (or so stat(2) says). >> >> Sure. But your patch is corrupted. > > Fixed patch attached. > > But I wouldn't apply it as is. My system does not have st_mtim. So I > think it needs a configure test and a fallback to the old method.Here's an attempt to make that happen. See attached. - M. Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/bltin/test.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/usr/dash/bltin/test.c b/usr/dash/bltin/test.c index 58c05fec..d1458df3 100644 --- a/usr/dash/bltin/test.c +++ b/usr/dash/bltin/test.c @@ -476,9 +476,17 @@ newerf (const char *f1, const char *f2) { struct stat b1, b2; +#ifdef HAVE_ST_MTIM + return (stat (f1, &b1) == 0 && + stat (f2, &b2) == 0 && + ( b1.st_mtim.tv_sec > b2.st_mtim.tv_sec || + (b1.st_mtim.tv_sec == b2.st_mtim.tv_sec && (b1.st_mtim.tv_nsec > b2.st_mtim.tv_nsec ))) + ); +#else return (stat (f1, &b1) == 0 && stat (f2, &b2) == 0 && b1.st_mtime > b2.st_mtime); +#endif } static int @@ -486,9 +494,17 @@ olderf (const char *f1, const char *f2) { struct stat b1, b2; +#ifdef HAVE_ST_MTIM + return (stat (f1, &b1) == 0 && + stat (f2, &b2) == 0 && + (b1.st_mtim.tv_sec < b2.st_mtim.tv_sec || + (b1.st_mtim.tv_sec == b2.st_mtim.tv_sec && (b1.st_mtim.tv_nsec < b2.st_mtim.tv_nsec ))) + ); +#else return (stat (f1, &b1) == 0 && stat (f2, &b2) == 0 && b1.st_mtime < b2.st_mtime); +#endif } static int
Possibly Parallel Threads
- [klibc:update-dash] dash: builtin: Greater resolution in test -nt / test -ot
- [klibc:update-dash] builtin: Reset t_wp_op in testcmd
- [klibc:update-dash] dash: builtin: Reset t_wp_op in testcmd
- [klibc:update-dash] dash: builtin: Use test_access from NetBSD when faccessat is unavailable
- [PATCH] New APIs: Implement stat calls that return nanosecond timestamps (RHBZ#1144891).