From 363ebb6cccbe21711b0e0c570b75739791b80195 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Tue, 15 Nov 2011 14:27:53 -0800 Subject: [PATCH] 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 --- src/librbd.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librbd.cc b/src/librbd.cc index ed6734f03b2e1..ced1b0c330b72 100644 --- a/src/librbd.cc +++ b/src/librbd.cc @@ -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(); -- 2.39.5