aboutsummaryrefslogtreecommitdiff
path: root/hw/usb
diff options
context:
space:
mode:
authorBandan Das <bsd@redhat.com>2019-01-29 08:19:08 -0500
committerGerd Hoffmann <kraxel@redhat.com>2019-01-30 06:47:52 +0100
commit49f9e8d660d41cbe325d554e742d7100d59a7abf (patch)
tree579730c2d075574756ac0188ef3326f63f9df702 /hw/usb
parentc1ef0f2519c706f738d76b9b68b6627c889bab14 (diff)
usb-mtp: replace the homebrew write with qemu_write_full
qemu_write_full takes care of partial blocking writes, as in cases of larger file sizes Suggested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Bandan Das <bsd@redhat.com> Message-id: 20190129131908.27924-4-bsd@redhat.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/usb')
-rw-r--r--hw/usb/dev-mtp.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 2ca25c9da5..f1d20fa1b9 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1632,24 +1632,16 @@ static char *utf16_to_str(uint8_t len, uint16_t *arr)
/* Wrapper around write, returns 0 on failure */
static uint64_t write_retry(int fd, void *buf, uint64_t size, off_t offset)
{
- uint64_t bytes_left = size, ret;
+ uint64_t ret = 0;
if (lseek(fd, offset, SEEK_SET) < 0) {
goto done;
}
- while (bytes_left > 0) {
- ret = write(fd, buf, bytes_left);
- if ((ret == -1) && (errno != EINTR || errno != EAGAIN ||
- errno != EWOULDBLOCK)) {
- break;
- }
- bytes_left -= ret;
- buf += ret;
- }
+ ret = qemu_write_full(fd, buf, size);
done:
- return size - bytes_left;
+ return ret;
}
static void usb_mtp_update_object(MTPObject *parent, char *name)