]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: report an error if rbd header does not match
authorJosh Durgin <josh.durgin@dreamhost.com>
Tue, 15 Nov 2011 22:27:53 +0000 (14:27 -0800)
committerSage Weil <sage@newdream.net>
Thu, 1 Dec 2011 20:38:57 +0000 (12:38 -0800)
This will fail on future incompatible versions of the header format.

Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
src/librbd.cc

index ed6734f03b2e16b350f9c46f2f081672f93d2db4..ced1b0c330b72febddc7f65f62308b576b59e96d 100644 (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();