123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #include <config.h>
- #include <sys/stat.h>
- #include <sys/time.h>
- #include <unistd.h>
- #include <string.h>
- #include <assert.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <stat-time.h>
- #include <timespec.h>
- #define TEMPLATE "ckmtime.XXXXXX"
- #define BILLION 1000000000
- int
- main (int argc, char **argv)
- {
- int fd;
- char name[sizeof(TEMPLATE)];
- struct stat st;
- struct timespec ts, td;
- double diff;
-
- gettime (&ts);
-
- strcpy (name, TEMPLATE);
- umask (077);
- fd = mkstemp (name);
- assert (fd != -1);
- unlink (name);
- assert (fstat (fd, &st) == 0);
- close (fd);
- td = timespec_sub (get_stat_mtime (&st), ts);
- diff = td.tv_sec * BILLION + td.tv_nsec;
- if (diff < 0)
- diff = - diff;
- if (diff / BILLION >= 1)
- {
- fprintf (stderr, "file timestamp unreliable\n");
- return 1;
- }
- return 0;
- }
|