diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2002-07-27 22:53:44 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2002-07-27 22:53:44 +0000 |
commit | 3b0d121aebc77955e4421574c410eec83ce4d604 (patch) | |
tree | c74ef19156e37cffa0adc3e0b2bff93a0f81c041 /bin/test/test.c | |
parent | ae7c937aa17799b0d6ae3750fc3fed0d0cc99998 (diff) | |
download | FreeBSD-src-3b0d121aebc77955e4421574c410eec83ce4d604.zip FreeBSD-src-3b0d121aebc77955e4421574c410eec83ce4d604.tar.gz |
Make test check the tv_nsec part of a struct stat when comparing
the mtimes of a file. (This is probably only useful if you have
vfs.timestamp_precision set to something nonzero).
PR: 39163
Submitted by: Hal Burch <hburch@lumeta.com>
MFC after: 2 weeks
Diffstat (limited to 'bin/test/test.c')
-rw-r--r-- | bin/test/test.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/bin/test/test.c b/bin/test/test.c index b3e51a4..7eb2df2 100644 --- a/bin/test/test.c +++ b/bin/test/test.c @@ -521,19 +521,21 @@ newerf (const char *f1, const char *f2) { struct stat b1, b2; - return (stat (f1, &b1) == 0 && - stat (f2, &b2) == 0 && - b1.st_mtime > b2.st_mtime); + if (stat(f1, &b1) != 0 || stat(f2, &b2) != 0) + return 0; + + if (b1.st_mtimespec.tv_sec > b2.st_mtimespec.tv_sec) + return 1; + if (b1.st_mtimespec.tv_sec < b2.st_mtimespec.tv_sec) + return 0; + + return (b1.st_mtimespec.tv_nsec > b2.st_mtimespec.tv_nsec); } static int olderf (const char *f1, const char *f2) { - struct stat b1, b2; - - return (stat (f1, &b1) == 0 && - stat (f2, &b2) == 0 && - b1.st_mtime < b2.st_mtime); + return (newerf(f2, f1)); } static int |