]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
Detect file modification properly by using tv_nsec.
authorEd Schouten <ed@FreeBSD.org>
Fri, 10 Feb 2012 13:40:32 +0000 (13:40 +0000)
committerEd Schouten <ed@FreeBSD.org>
Fri, 10 Feb 2012 13:40:32 +0000 (13:40 +0000)
POSIX 2008 standardizes st_mtim, meaning we can simply use nanosecond
precision to detect file modification.

MFC after: 2 weeks

libutil/pw_util.c

index 5cd27b155ff4c96bc96b11201a52019f239854e9..63c63de81aa68c755619ef69fc06b79fe9c8895f 100644 (file)
@@ -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);
 }
 
 /*