From: Bandan <bsd@redhat.com>
To: qemu-devel@nongnu.org
Cc: kraxel@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] usb-mtp: fix error conditions for write operation
Date: Fri, 31 Aug 2018 15:16:18 -0400 [thread overview]
Message-ID: <20180831191619.20275-2-bsd@redhat.com> (raw)
In-Reply-To: <20180831191619.20275-1-bsd@redhat.com>
Return STORE_FULL if we can't write all the bytes but
return incomplete transfer if data received is less then
what was specified in the metadata. Also, use d->offset
as the file size which is valid for all file sizes.
Signed-off-by: Bandan <bsd@redhat.com>
---
hw/usb/dev-mtp.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 3fdc4b0da1..15edf3bb82 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1665,13 +1665,14 @@ static void usb_mtp_write_data(MTPState *s)
goto success;
}
- rc = write_retry(d->fd, d->data, s->dataset.size);
- if (!rc) {
+ rc = write_retry(d->fd, d->data, d->offset);
+ if (rc != d->offset) {
usb_mtp_queue_result(s, RES_STORE_FULL, d->trans,
0, 0, 0, 0);
goto done;
}
- if (rc != s->dataset.size) {
+ /* Only for < 4G file sizes */
+ if (s->dataset.size != 0xFFFFFFFF && rc != s->dataset.size) {
usb_mtp_queue_result(s, RES_INCOMPLETE_TRANSFER, d->trans,
0, 0, 0, 0);
goto done;
--
2.11.0
next prev parent reply other threads:[~2018-08-31 19:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-31 19:16 [Qemu-devel] [PATCH 0/2] Misc usb-mtp fixes Bandan
2018-08-31 19:16 ` Bandan [this message]
2018-08-31 19:16 ` [Qemu-devel] [PATCH 2/2] doc: replace x-root with rootdir for usb-mtp Bandan
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=20180831191619.20275-2-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).