AC_CHECK_MEMBERS([struct termios.c_line],,,
[[#include <termios.h>]])
+AC_CHECK_MEMBERS([struct stat.st_mtim.tv_nsec],,,
+ [#include <sys/stat.h>])
+
AC_CHECK_DECLS([
ADDR_NO_RANDOMIZE,
FDPIC_FUNCPTRS,
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
int bid_pri; /* Device priority */
dev_t bid_devno; /* Device major/minor number */
time_t bid_time; /* Last update time of device */
+ suseconds_t bid_utime; /* Last update time (microseconds) */
unsigned int bid_flags; /* Device status bitflags */
char *bid_label; /* Shortcut to device LABEL */
char *bid_uuid; /* Shortcut to binary UUID */
printf(" dev: name = %s\n", dev->bid_name);
printf(" dev: DEVNO=\"0x%0llx\"\n", (long long)dev->bid_devno);
- printf(" dev: TIME=\"%ld\"\n", (long)dev->bid_time);
+ printf(" dev: TIME=\"%ld.%ld\"\n", (long)dev->bid_time, (long)dev->bid_utime);
printf(" dev: PRI=\"%d\"\n", dev->bid_pri);
printf(" dev: flags = 0x%08X\n", dev->bid_flags);
*
* The following tags are required for each entry:
* <ID="id"> unique (within this file) ID number of this device
- * <TIME="time"> (ascii time_t) time this entry was last read from disk
+ * <TIME="sec.usec"> (time_t and suseconds_t) time this entry was last
+ * read from disk
* <TYPE="type"> (detected) type of filesystem/data for this partition
*
* The following tags may be present, depending on the device contents
dev->bid_devno = STRTOULL(value, 0, 0);
else if (!strcmp(name, "PRI"))
dev->bid_pri = strtol(value, 0, 0);
- else if (!strcmp(name, "TIME"))
- dev->bid_time = STRTOULL(value, 0, 0);
- else
+ else if (!strcmp(name, "TIME")) {
+ char *end = NULL;
+ dev->bid_time = STRTOULL(value, &end, 0);
+ if (end && *end == '.')
+ dev->bid_utime = STRTOULL(end + 1, 0, 0);
+ } else
ret = blkid_set_tag(dev, name, value, strlen(value));
DBG(DEBUG_READ, printf(" tag: %s=\"%s\"\n", name, value));
printf(" dev: name = %s\n", dev->bid_name);
printf(" dev: DEVNO=\"0x%0llx\"\n", (long long)dev->bid_devno);
- printf(" dev: TIME=\"%lld\"\n", (long long)dev->bid_time);
+ printf(" dev: TIME=\"%ld.%ld\"\n", (long)dev->bid_time, (long)dev->bid_utime);
printf(" dev: PRI=\"%d\"\n", dev->bid_pri);
printf(" dev: flags = 0x%08X\n", dev->bid_flags);
printf("device %s, type %s\n", dev->bid_name, dev->bid_type ?
dev->bid_type : "(null)"));
- fprintf(file,
- "<device DEVNO=\"0x%04lx\" TIME=\"%ld\"",
- (unsigned long) dev->bid_devno, (long) dev->bid_time);
+ fprintf(file, "<device DEVNO=\"0x%04lx\" TIME=\"%ld.%ld\"",
+ (unsigned long) dev->bid_devno,
+ (long) dev->bid_time,
+ (long) dev->bid_utime);
+
if (dev->bid_pri)
fprintf(file, " PRI=\"%d\"", dev->bid_pri);
list_for_each(p, &dev->bid_tags) {
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
+#include <sys/time.h>
#include <sys/types.h>
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
return NULL;
}
- if ((now >= dev->bid_time) &&
- (st.st_mtime <= dev->bid_time) &&
- ((diff < BLKID_PROBE_MIN) ||
- (dev->bid_flags & BLKID_BID_FL_VERIFIED &&
- diff < BLKID_PROBE_INTERVAL)))
+ if (now >= dev->bid_time &&
+#ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
+ (st.st_mtime < dev->bid_time ||
+ (st.st_mtime == dev->bid_time &&
+ st.st_mtim.tv_nsec / 1000 <= dev->bid_utime)) &&
+#else
+ st.st_mtime <= dev->bid_time &&
+#endif
+ (diff < BLKID_PROBE_MIN ||
+ (dev->bid_flags & BLKID_BID_FL_VERIFIED &&
+ diff < BLKID_PROBE_INTERVAL)))
return dev;
+#ifndef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
DBG(DEBUG_PROBE,
printf("need to revalidate %s (cache time %lu, stat time %lu,\n\t"
"time since last check %lu)\n",
dev->bid_name, (unsigned long)dev->bid_time,
(unsigned long)st.st_mtime, (unsigned long)diff));
-
+#else
+ DBG(DEBUG_PROBE,
+ printf("need to revalidate %s (cache time %lu.%lu, stat time %lu.%lu,\n\t"
+ "time since last check %lu)\n",
+ dev->bid_name,
+ (unsigned long)dev->bid_time, (unsigned long)dev->bid_utime,
+ (unsigned long)st.st_mtime, (unsigned long)st.st_mtim.tv_nsec / 1000,
+ (unsigned long)diff));
+#endif
if (!cache->probe) {
cache->probe = blkid_new_probe();
found_type:
if (dev) {
+#ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
+ struct timeval tv;
+ if (!gettimeofday(&tv, NULL)) {
+ dev->bid_time = tv.tv_sec;
+ dev->bid_utime = tv.tv_usec;
+ } else
+#endif
+ dev->bid_time = time(0);
+
dev->bid_devno = st.st_rdev;
- dev->bid_time = time(0);
dev->bid_flags |= BLKID_BID_FL_VERIFIED;
cache->bic_flags |= BLKID_BIC_FL_CHANGED;