Browse Source

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>
pull/17/head
Max Reitz 12 years ago
committed by Kevin Wolf
parent
commit
39411cf3c3
  1. 2
      block/raw-posix.c

2
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);

Loading…
Cancel
Save