| 79 | } |
| 80 | |
| 81 | static int parse_diff_body(int fd, __u8 *tag, uint64_t *offset, uint64_t *length) |
| 82 | { |
| 83 | int r; |
| 84 | |
| 85 | if (!(*tag)) { |
| 86 | r = safe_read_exact(fd, tag, 1); |
| 87 | if (r < 0) |
| 88 | return r; |
| 89 | } |
| 90 | |
| 91 | if (*tag == RBD_DIFF_END) { |
| 92 | offset = 0; |
| 93 | length = 0; |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | if (*tag != RBD_DIFF_WRITE && *tag != RBD_DIFF_ZERO) |
| 98 | return -ENOTSUP; |
| 99 | |
| 100 | char buf[16]; |
| 101 | r = safe_read_exact(fd, buf, 16); |
| 102 | if (r < 0) |
| 103 | return r; |
| 104 | |
| 105 | bufferlist bl; |
| 106 | bl.append(buf, 16); |
| 107 | auto p = bl.cbegin(); |
| 108 | decode(*offset, p); |
| 109 | decode(*length, p); |
| 110 | |
| 111 | if (!(*length)) |
| 112 | return -ENOTSUP; |
| 113 | |
| 114 | return 0; |
| 115 | } |
| 116 | |
| 117 | /* |
| 118 | * fd: the diff file to read from |
no test coverage detected