From: Bandan Das <bsd@redhat.com>
To: qemu-devel@nongnu.org
Cc: kraxel@redhat.com
Subject: [Qemu-devel] [PATCH v3 3/3] usb-mtp: replace the homebrew write with qemu_write_full
Date: Mon, 28 Jan 2019 09:24:10 -0500 [thread overview]
Message-ID: <20190128142410.11584-4-bsd@redhat.com> (raw)
In-Reply-To: <20190128142410.11584-1-bsd@redhat.com>
qemu_write_full takes care of partial blocking writes,
as in cases of larger file sizes
Signed-off-by: Bandan Das <bsd@redhat.com>
---
hw/usb/dev-mtp.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index b607c7be05..f4d9470493 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1630,24 +1630,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)
--
2.19.2
prev parent reply other threads:[~2019-01-28 14:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-28 14:24 [Qemu-devel] [PATCH v3 0/3] Break down the MTP write operation Bandan Das
2019-01-28 14:24 ` [Qemu-devel] [PATCH v3 1/3] usb-mtp: Reallocate buffer in multiples of MTP_WRITE_BUF_SZ Bandan Das
2019-01-28 16:47 ` Eric Blake
2019-01-29 13:20 ` Bandan Das
2019-01-28 14:24 ` [Qemu-devel] [PATCH v3 2/3] usb-mtp: breakup MTP write into smaller chunks Bandan Das
2019-01-28 14:24 ` Bandan Das [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190128142410.11584-4-bsd@redhat.com \
--to=bsd@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).