diff options
author | Karel Zak | 2013-02-01 15:59:58 +0100 |
---|---|---|
committer | Karel Zak | 2013-02-01 15:59:58 +0100 |
commit | 6a0766444dc4f1b23b1f0da9c380fb1ced0bfb0a (patch) | |
tree | 5eeedd7a2849384809efbffe14f5a1329cd1570b /libblkid/src/verify.c | |
parent | textual: improve an error message and a help text (diff) | |
download | kernel-qcow2-util-linux-6a0766444dc4f1b23b1f0da9c380fb1ced0bfb0a.tar.gz kernel-qcow2-util-linux-6a0766444dc4f1b23b1f0da9c380fb1ced0bfb0a.tar.xz kernel-qcow2-util-linux-6a0766444dc4f1b23b1f0da9c380fb1ced0bfb0a.zip |
libblkid: remove optimization from verify( funrtion
Now libblkid (the cache based part) tries to probe for the cached
filesystem firstly. This optimization is broken, because:
* new another superblock could be on the device and the original
is already obsolete
* we still need to probe for partitions and raids
* the code was too fragile
The patch also suggests lsblk --fs in blkid.8 for end users. lsblk
read information from used db.
Reported-by: Andreas Hofmeister <andi@collax.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid/src/verify.c')
-rw-r--r-- | libblkid/src/verify.c | 76 |
1 files changed, 11 insertions, 65 deletions
diff --git a/libblkid/src/verify.c b/libblkid/src/verify.c index 8a6fc20af..9383e8570 100644 --- a/libblkid/src/verify.c +++ b/libblkid/src/verify.c @@ -43,26 +43,6 @@ static void blkid_probe_to_tags(blkid_probe pr, blkid_dev dev) blkid_set_tag(dev, name, data, len); } } - - /* - * remove obsolete tags - */ - if (!nvals || !blkid_probe_has_value(pr, "LABEL")) - blkid_set_tag(dev, "LABEL", NULL, 0); - if (!nvals || !blkid_probe_has_value(pr, "UUID")) - blkid_set_tag(dev, "UUID", NULL, 0); - if (!nvals || !blkid_probe_has_value(pr, "PART_ENTRY_UUID")) - blkid_set_tag(dev, "PARTUUID", NULL, 0); - if (!nvals || !blkid_probe_has_value(pr, "PART_ENTRY_NAME")) - blkid_set_tag(dev, "PARTLABEL", NULL, 0); - if (!nvals || !blkid_probe_has_value(pr, "TYPE")) - blkid_set_tag(dev, "TYPE", NULL, 0); - if (!nvals || !blkid_probe_has_value(pr, "SEC_TYPE")) - blkid_set_tag(dev, "SEC_TYPE", NULL, 0); - if (!nvals || !blkid_probe_has_value(pr, "EXT_JOURNAL")) /* extN */ - blkid_set_tag(dev, "EXT_JOURNAL", NULL, 0); - if (!nvals || !blkid_probe_has_value(pr, "MOUNT")) /* ocfs */ - blkid_set_tag(dev, "MOUNT", NULL, 0); } /* @@ -76,9 +56,10 @@ static void blkid_probe_to_tags(blkid_probe pr, blkid_dev dev) */ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) { + blkid_tag_iterate iter; + const char *type, *value; struct stat st; time_t diff, now; - char *fltr[2]; int fd; if (!dev || !cache) @@ -155,64 +136,29 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) return NULL; } - blkid_probe_enable_superblocks(cache->probe, TRUE); + /* remove old cache info */ + iter = blkid_tag_iterate_begin(dev); + while (blkid_tag_next(iter, &type, &value) == 0) + blkid_set_tag(dev, type, NULL, 0); + blkid_tag_iterate_end(iter); + /* enable superblocks probing */ + blkid_probe_enable_superblocks(cache->probe, TRUE); blkid_probe_set_superblocks_flags(cache->probe, BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE); - /* - * If we already know the type, then try that first. - */ - if (dev->bid_type) { - blkid_tag_iterate iter; - const char *type, *value; - - fltr[0] = dev->bid_type; - fltr[1] = NULL; - - blkid_probe_filter_superblocks_type(cache->probe, - BLKID_FLTR_ONLYIN, fltr); - - if (blkid_do_probe(cache->probe) == 0) { - /* - * Cool, we found FS type, let's also read PART{UUID,LABEL} - */ - blkid_probe_enable_superblocks(cache->probe, FALSE); - blkid_probe_enable_partitions(cache->probe, TRUE); - blkid_probe_set_partitions_flags(cache->probe, BLKID_PARTS_ENTRY_DETAILS); - if (blkid_do_probe(cache->probe) == 0) - goto found_type; - } - - blkid_probe_enable_superblocks(cache->probe, TRUE); - blkid_probe_invert_superblocks_filter(cache->probe); - - /* - * Zap the device filesystem information and try again - */ - DBG(DEBUG_PROBE, - printf("previous fs type %s not valid, " - "trying full probe\n", dev->bid_type)); - iter = blkid_tag_iterate_begin(dev); - while (blkid_tag_next(iter, &type, &value) == 0) - blkid_set_tag(dev, type, 0, 0); - blkid_tag_iterate_end(iter); - } - + /* enable partitions probing */ blkid_probe_enable_partitions(cache->probe, TRUE); blkid_probe_set_partitions_flags(cache->probe, BLKID_PARTS_ENTRY_DETAILS); - /* - * Probe for all types. - */ + /* probe */ if (blkid_do_safeprobe(cache->probe)) { /* found nothing or error */ blkid_free_dev(dev); dev = NULL; } -found_type: if (dev) { #ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC struct timeval tv; |