diff options
author | Theodore Ts'o <tytso@mit.edu> | 2008-05-21 16:56:42 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-05-21 16:56:42 -0400 |
commit | c0af709e52dd4952d78f051ea5c082437ee3412b (patch) | |
tree | e6b07da8d129add939eedfa4139d267fbb7fa7c9 /lib/blkid | |
parent | a16031c639c1965c7a35eb9ac9b2d45798efe7e9 (diff) | |
parent | 491d8bc3e0fafda6cbb41e76549c620eb700f650 (diff) | |
download | e2fsprogs-c0af709e52dd4952d78f051ea5c082437ee3412b.tar.gz |
Merge branch 'maint'
Conflicts:
README
version.h
Diffstat (limited to 'lib/blkid')
-rw-r--r-- | lib/blkid/probe.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index d8457a86..c8bc8402 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -1220,33 +1220,39 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) now = time(0); diff = now - dev->bid_time; - if ((now > dev->bid_time) && (diff > 0) && + if (stat(dev->bid_name, &st) < 0) { + DBG(DEBUG_PROBE, + printf("blkid_verify: error %s (%d) while " + "trying to stat %s\n", strerror(errno), errno, + dev->bid_name)); + open_err: + if ((errno == EPERM) || (errno == EACCES) || (errno == ENOENT)) { + /* We don't have read permission, just return cache data. */ + DBG(DEBUG_PROBE, printf("returning unverified data for %s\n", + dev->bid_name)); + return dev; + } + blkid_free_dev(dev); + 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))) return dev; DBG(DEBUG_PROBE, - printf("need to revalidate %s (time since last check %llu)\n", - dev->bid_name, (unsigned long long)diff)); - - if (((probe.fd = open(dev->bid_name, O_RDONLY)) < 0) || - (fstat(probe.fd, &st) < 0)) { - if (probe.fd >= 0) close(probe.fd); - if ((errno != EPERM) && (errno != EACCES) && - (errno != ENOENT)) { - DBG(DEBUG_PROBE, - printf("blkid_verify: error %s (%d) while " - "opening %s\n", strerror(errno), errno, - dev->bid_name)); - blkid_free_dev(dev); - return NULL; - } - /* We don't have read permission, just return cache data. */ - DBG(DEBUG_PROBE, - printf("returning unverified data for %s\n", - dev->bid_name)); - return dev; + printf("need to revalidate %s (cache time %d, stat time %d,\n\t" + "time since last check %lu)\n", + dev->bid_name, dev->bid_time, st.st_mtime, (unsigned long)diff)); + + if ((probe.fd = open(dev->bid_name, O_RDONLY)) < 0) { + DBG(DEBUG_PROBE, printf("blkid_verify: error %s (%d) while " + "opening %s\n", strerror(errno), errno, + dev->bid_name)); + goto open_err; } probe.cache = cache; |