diff options
author | Karel Zak | 2013-09-11 13:19:44 +0200 |
---|---|---|
committer | Karel Zak | 2013-09-11 16:24:56 +0200 |
commit | c89a1defc729afaabf70921c7dd183e9e108db9d (patch) | |
tree | b903f5256107c86280e0e64e26d8997821dddaad /libblkid/src/probe.c | |
parent | tests: use stable MBR ID (diff) | |
download | kernel-qcow2-util-linux-c89a1defc729afaabf70921c7dd183e9e108db9d.tar.gz kernel-qcow2-util-linux-c89a1defc729afaabf70921c7dd183e9e108db9d.tar.xz kernel-qcow2-util-linux-c89a1defc729afaabf70921c7dd183e9e108db9d.zip |
libblkid: use separate function to verify checksums
* consolidate "incorrect checksum" debug messages
* verify all on one place
Based on patch from Gabriel de Perthuis <g2p.code@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid/src/probe.c')
-rw-r--r-- | libblkid/src/probe.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c index d2b301d7f..6e3ae42dc 100644 --- a/libblkid/src/probe.c +++ b/libblkid/src/probe.c @@ -336,6 +336,16 @@ struct blkid_chain *blkid_probe_get_chain(blkid_probe pr) return pr->cur_chain; } +static const char *blkid_probe_get_probername(blkid_probe pr) +{ + struct blkid_chain *chn = blkid_probe_get_chain(pr); + + if (chn && chn->idx >= 0 && chn->idx < chn->driver->nidinfos) + return chn->driver->idinfos[chn->idx]->name; + + return NULL; +} + void *blkid_probe_get_binary_data(blkid_probe pr, struct blkid_chain *chn) { int rc, org_prob_flags; @@ -1341,6 +1351,20 @@ int blkid_probe_set_magic(blkid_probe pr, blkid_loff_t offset, return rc; } +int blkid_probe_verify_csum(blkid_probe pr, uint64_t csum, uint64_t expected) +{ + if (csum != expected) { + DBG(LOWPROBE, blkid_debug( + "incorrect checksum for type %s," + " got %jX, expected %jX", + blkid_probe_get_probername(pr), + csum, expected)); + return 0; + } + + return 1; +} + /** * blkid_probe_get_devno: * @pr: probe |