From: Yunchuan Wen Date: Wed, 7 Jan 2015 08:32:58 +0000 (+0800) Subject: rbd: parse diff file body for diff merging X-Git-Tag: v0.93~268^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9c82efcc79382797183006ee276d1e0c8a1ccbeb;p=ceph.git rbd: parse diff file body for diff merging Signed-off-by: MingXin Liu Signed-off-by: Yunchuan Wen Reviewed-by: Li Wang --- diff --git a/src/rbd.cc b/src/rbd.cc index 91761af2c1e8..781ba7af4f4e 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -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