From ae82dd5a5c964bb310a5512d10d1e062cbb0c1a5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 7 Jul 2010 16:34:27 -0700 Subject: [PATCH] rbdtool: fix export Signed-off-by: Sage Weil --- src/rbdtool.cc | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/rbdtool.cc b/src/rbdtool.cc index 38ed5b5c079..00a42afb2ff 100644 --- a/src/rbdtool.cc +++ b/src/rbdtool.cc @@ -580,22 +580,19 @@ static int do_export(pool_t pool, string& md_oid, const char *path) goto done; } - pos += block_size; - if (bl.length()) { + ret = lseek64(fd, pos, SEEK_SET); + if (ret < 0) { + ret = -errno; + cerr << "could not seek to pos " << pos << std::endl; + goto done; + } ret = write(fd, bl.c_str(), bl.length()); if (ret < 0) goto done; - - if (bl.length() < block_size) { - ret = lseek64(fd, pos, SEEK_SET); - if (ret < 0) { - ret = -errno; - cerr << "could not seek to pos " << pos << std::endl; - goto done; - } - } } + + pos += block_size; } r = ftruncate(fd, header.image_size); if (r < 0)