summaryrefslogtreecommitdiff
path: root/send-stream.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-11-15 16:45:01 +0100
committerDavid Sterba <dsterba@suse.com>2016-11-23 10:50:35 +0100
commitbb2c0e23d891416b724dd0e72f83aa0d035849c3 (patch)
tree92729e27d66741bb159eeb63f581ea2066152fca /send-stream.c
parent691d1ac8fa0830d04d9bce1cbbb81cad2dbe600d (diff)
btrfs-progs: send-stream: track the read position in the stream
Can be later used for more precise error reporting. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'send-stream.c')
-rw-r--r--send-stream.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/send-stream.c b/send-stream.c
index 80bf680b..920c7420 100644
--- a/send-stream.c
+++ b/send-stream.c
@@ -33,6 +33,12 @@ struct btrfs_send_stream {
struct btrfs_tlv_header *cmd_attrs[BTRFS_SEND_A_MAX + 1];
u32 version;
+ /*
+ * end of last successful read, equivalent to start of current
+ * malformated part of block
+ */
+ size_t stream_pos;
+
struct btrfs_send_ops *ops;
void *user;
};
@@ -71,6 +77,8 @@ out_eof:
if (pos < len) {
error("short read from stream: expected %zu read %zu", len, pos);
ret = -EIO;
+ } else {
+ sctx->stream_pos += pos;
}
out:
@@ -478,6 +486,7 @@ int btrfs_read_and_process_send_stream(int fd,
sctx.fd = fd;
sctx.ops = ops;
sctx.user = user;
+ sctx.stream_pos = 0;
ret = read_buf(&sctx, (char*)&hdr, sizeof(hdr));
if (ret < 0)