librbd: report an error if rbd header does not match

This will fail on future incompatible versions of the header format.

Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
This commit is contained in:
Josh Durgin 2011-11-15 14:27:53 -08:00 committed by Sage Weil
parent 353ee0004a
commit 363ebb6ccc

View File

@ -585,6 +585,12 @@ int read_header_bl(IoCtx& io_ctx, const string& md_oid, bufferlist& header, uint
header.claim_append(bl);
} while (r == READ_SIZE);
if (memcmp(RBD_HEADER_TEXT, header.c_str(), sizeof(RBD_HEADER_TEXT))) {
CephContext *cct = io_ctx.cct();
lderr(cct) << "unrecognized header format" << dendl;
return -ENXIO;
}
if (ver)
*ver = io_ctx.get_last_version();