summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2014-11-18 11:23:04 +0100
committerKevin Wolf <kwolf@redhat.com>2014-11-18 12:08:59 +0100
commit39411cf3c316de0fe3cbb9585774bacfe3bd8efd (patch)
treea63dda7bee86b7377056493dcbe6e837f035f135
parent867678530240ed7a4aaf647df08be98bebd3b1f0 (diff)
downloadqemu-39411cf3c316de0fe3cbb9585774bacfe3bd8efd.tar.gz
block/raw-posix: Fix preallocating write() loop
write() may write less bytes than requested; in this case, the number of bytes written is returned. This is the byte count we should be subtracting from the number of bytes still to be written, and not the byte count we requested to write. Reported-by: László Érsek <lersek@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block/raw-posix.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 414e6d1e91..e0e48c5f51 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1451,7 +1451,7 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp)
"Could not write to the new file");
break;
}
- left -= num;
+ left -= result;
}
fsync(fd);
g_free(buf);