From: Bandan Das <bsd@redhat.com>
To: qemu-devel@nongnu.org
Cc: kraxel@redhat.com
Subject: [Qemu-devel] [PATCH v2 1/3] usb-mtp: fix error conditions for write operation
Date: Fri, 7 Sep 2018 18:08:49 -0400 [thread overview]
Message-ID: <20180907220851.9658-2-bsd@redhat.com> (raw)
In-Reply-To: <20180907220851.9658-1-bsd@redhat.com>
From: Bandan <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.14.4
next prev parent reply other threads:[~2018-09-07 22:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-07 22:08 [Qemu-devel] [PATCH v2 0/3] Misc usb-mtp fixes Bandan Das
2018-09-07 22:08 ` Bandan Das [this message]
2018-09-07 22:08 ` [Qemu-devel] [PATCH v2 2/3] doc: replace x-root with rootdir for usb-mtp Bandan Das
2018-09-07 22:08 ` [Qemu-devel] [PATCH v2 3/3] usb-mtp: reset ObjectInfo dataset size on cleanup Bandan Das
2018-09-13 11:54 ` [Qemu-devel] [PATCH v2 0/3] Misc usb-mtp fixes Gerd Hoffmann
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=20180907220851.9658-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).