]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: parse diff file body for diff merging
authorYunchuan Wen <yunchuanwen@ubuntukylin.com>
Wed, 7 Jan 2015 08:32:58 +0000 (16:32 +0800)
committerYunchuan Wen <yunchuanwen@ubuntukylin.com>
Mon, 12 Jan 2015 01:03:41 +0000 (01:03 +0000)
Signed-off-by: MingXin Liu <mingxinliu@ubuntukylin.com>
Signed-off-by: Yunchuan Wen <yunchuanwen@ubuntukylin.com>
Reviewed-by: Li Wang <liwang@ubuntukylin.com>
src/rbd.cc

index 91761af2c1e824aa866cef29e08cebbd079a9328..781ba7af4f4e4b08f2b9c46cac484132833bf640 100644 (file)
@@ -1762,6 +1762,42 @@ static int parse_diff_header(int fd, __u8 *tag, string *from, string *to, uint64
   return 0;
 }
 
+static int parse_diff_body(int fd, __u8 *tag, uint64_t *offset, uint64_t *length)
+{
+  int r;
+
+  if (!(*tag)) {
+    r = safe_read_exact(fd, tag, 1);
+    if (r < 0)
+      return r;
+  }
+
+  if (*tag == 'e') {
+    offset = 0;
+    length = 0;
+    return 0;
+  }
+
+  if (*tag != 'w' && *tag != 'z')
+    return -ENOTSUP;
+
+  char buf[16];
+  r = safe_read_exact(fd, buf, 16);
+  if (r < 0)
+    return r;
+
+  bufferlist bl;
+  bl.append(buf, 16);
+  bufferlist::iterator p = bl.begin();
+  ::decode(*offset, p);
+  ::decode(*length, p);
+
+  if (!(*length))
+    return -ENOTSUP;
+
+  return 0;
+}
+
 /*
  * fd: the diff file to read from
  * pd: the diff file to be written into