diff options
author | Theodore Ts'o <tytso@mit.edu> | 2006-03-12 23:25:15 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2006-03-12 23:25:15 -0500 |
commit | e324b250593a32680309015eba7c6c5db7851227 (patch) | |
tree | e81329682fb802cb3f655b66feff6fbf26e05b6b /lib/blkid | |
parent | 3f546fcc27e9bfca8d365c4d78c6e6c99ca32512 (diff) | |
download | e2fsprogs-e324b250593a32680309015eba7c6c5db7851227.tar.gz |
Fix blkid's last verification logic to work when the system clock is insane
Users have reported problems on newly installed systems when the
Macintosh's system clock battery is dead and the hardware clock is
returning a date of 1904. Turns out there were some bugs in handling
dates before the Unix epoch.
Addresses Red Hat Bug: #182188
probe.c (blkid_verify): Fix the bid_time sanity checking logic,
so that if last verification time is more recent than the
current time, or the comparison between the last
verification time and the current time causes an overflow,
a device verification will take place.
devname.c (blkid_get_dev): Set the initial bid_time to be
INT_MIN, to guarantee that blkid_verify will always be run
even when the system clock is insane.
dev.c (blkid_debug_dump_dev), read.c (debug_dump_dev),
save.c (save_dev): Fix the printf format for dev->bid_time
to match the fact that it is an signed type.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/blkid')
-rw-r--r-- | lib/blkid/ChangeLog | 16 | ||||
-rw-r--r-- | lib/blkid/dev.c | 2 | ||||
-rw-r--r-- | lib/blkid/devname.c | 2 | ||||
-rw-r--r-- | lib/blkid/probe.c | 8 | ||||
-rw-r--r-- | lib/blkid/read.c | 2 | ||||
-rw-r--r-- | lib/blkid/save.c | 2 |
6 files changed, 25 insertions, 7 deletions
diff --git a/lib/blkid/ChangeLog b/lib/blkid/ChangeLog index 094f9225..e0dac822 100644 --- a/lib/blkid/ChangeLog +++ b/lib/blkid/ChangeLog @@ -1,3 +1,19 @@ +2006-03-12 Theodore Ts'o <tytso@mit.edu> + + * probe.c (blkid_verify): Fix the bid_time sanity checking logic, + so that if last verification time is more recent than the + current time, or the comparison between the last + verification time and the current time causes an overflow, + a device verification will take place. + + * devname.c (blkid_get_dev): Set the initial bid_time to be + INT_MIN, to guarantee that blkid_verify will always be run + even when the system clock is insane. + + * dev.c (blkid_debug_dump_dev), read.c (debug_dump_dev), + save.c (save_dev): Fix the printf format for dev->bid_time + to match the fact that it is an signed type. + 2006-03-10 Theodore Ts'o <tytso@mit.edu> * probe.c (probe_ext3): If the filesystem has an external journal, diff --git a/lib/blkid/dev.c b/lib/blkid/dev.c index adb855a5..ea2ccead 100644 --- a/lib/blkid/dev.c +++ b/lib/blkid/dev.c @@ -69,7 +69,7 @@ void blkid_debug_dump_dev(blkid_dev dev) printf(" dev: name = %s\n", dev->bid_name); printf(" dev: DEVNO=\"0x%0llx\"\n", dev->bid_devno); - printf(" dev: TIME=\"%lu\"\n", dev->bid_time); + printf(" dev: TIME=\"%ld\"\n", dev->bid_time); printf(" dev: PRI=\"%d\"\n", dev->bid_pri); printf(" dev: flags = 0x%08X\n", dev->bid_flags); diff --git a/lib/blkid/devname.c b/lib/blkid/devname.c index 0a13c477..b2ff40f0 100644 --- a/lib/blkid/devname.c +++ b/lib/blkid/devname.c @@ -15,6 +15,7 @@ #include <stdio.h> #include <string.h> +#include <limits.h> #if HAVE_UNISTD_H #include <unistd.h> #endif @@ -70,6 +71,7 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags) dev = blkid_new_dev(); if (!dev) return NULL; + dev->bid_time = INT_MIN; dev->bid_name = blkid_strdup(devname); dev->bid_cache = cache; list_add_tail(&dev->bid_devs, &cache->bic_devs); diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index f689bc10..4d78ec21 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -758,10 +758,10 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) now = time(0); diff = now - dev->bid_time; - if ((now < dev->bid_time) || - (diff < BLKID_PROBE_MIN) || - (dev->bid_flags & BLKID_BID_FL_VERIFIED && - diff < BLKID_PROBE_INTERVAL)) + if ((now > dev->bid_time) && (diff > 0) && + ((diff < BLKID_PROBE_MIN) || + (dev->bid_flags & BLKID_BID_FL_VERIFIED && + diff < BLKID_PROBE_INTERVAL))) return dev; DBG(DEBUG_PROBE, diff --git a/lib/blkid/read.c b/lib/blkid/read.c index c823d30d..010d9f33 100644 --- a/lib/blkid/read.c +++ b/lib/blkid/read.c @@ -453,7 +453,7 @@ static void debug_dump_dev(blkid_dev dev) printf(" dev: name = %s\n", dev->bid_name); printf(" dev: DEVNO=\"0x%0llx\"\n", dev->bid_devno); - printf(" dev: TIME=\"%lu\"\n", dev->bid_time); + printf(" dev: TIME=\"%ld\"\n", dev->bid_time); printf(" dev: PRI=\"%d\"\n", dev->bid_pri); printf(" dev: flags = 0x%08X\n", dev->bid_flags); diff --git a/lib/blkid/save.c b/lib/blkid/save.c index a2fbd7b4..f52dc46b 100644 --- a/lib/blkid/save.c +++ b/lib/blkid/save.c @@ -37,7 +37,7 @@ static int save_dev(blkid_dev dev, FILE *file) printf("device %s, type %s\n", dev->bid_name, dev->bid_type)); fprintf(file, - "<device DEVNO=\"0x%04lx\" TIME=\"%lu\"", + "<device DEVNO=\"0x%04lx\" TIME=\"%ld\"", (unsigned long) dev->bid_devno, dev->bid_time); if (dev->bid_pri) fprintf(file, " PRI=\"%d\"", dev->bid_pri); |