summaryrefslogtreecommitdiffstats
path: root/libutil
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2012-02-10 13:40:32 +0000
committerEd Schouten <ed@FreeBSD.org>2012-02-10 13:40:32 +0000
commit2f06dd395d0003a4bff0dbffe4471f6e2f271d01 (patch)
treeebb11b5da9364bc28a0d682eac56426f11bfe17a /libutil
parent0e57343b2b3ee7db9cad1f85cc2ffd96472963bc (diff)
downloadpw-darwin-2f06dd395d0003a4bff0dbffe4471f6e2f271d01.tar.gz
pw-darwin-2f06dd395d0003a4bff0dbffe4471f6e2f271d01.tar.zst
pw-darwin-2f06dd395d0003a4bff0dbffe4471f6e2f271d01.zip
Detect file modification properly by using tv_nsec.
POSIX 2008 standardizes st_mtim, meaning we can simply use nanosecond precision to detect file modification. MFC after: 2 weeks
Diffstat (limited to 'libutil')
-rw-r--r--libutil/pw_util.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libutil/pw_util.c b/libutil/pw_util.c
index 5cd27b1..63c63de 100644
--- a/libutil/pw_util.c
+++ b/libutil/pw_util.c
@@ -347,7 +347,8 @@ pw_edit(int notsetuid)
sigprocmask(SIG_SETMASK, &oldsigset, NULL);
if (stat(tempname, &st2) == -1)
return (-1);
- return (st1.st_mtime != st2.st_mtime);
+ return (st1.st_mtim.tv_sec != st2.st_mtim.tv_sec ||
+ st1.st_mtim.tv_nsec != st2.st_mtim.tv_nsec);
}
/*