usb-mtp: fix error conditions for write operation

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>
Message-id: 20180907220851.9658-2-bsd@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Bandan 2018-09-07 18:08:49 -04:00 committed by Gerd Hoffmann
parent 07f426c35e
commit 44dd419680

View File

@ -1665,13 +1665,14 @@ static void usb_mtp_write_data(MTPState *s)
goto success; goto success;
} }
rc = write_retry(d->fd, d->data, s->dataset.size); rc = write_retry(d->fd, d->data, d->offset);
if (!rc) { if (rc != d->offset) {
usb_mtp_queue_result(s, RES_STORE_FULL, d->trans, usb_mtp_queue_result(s, RES_STORE_FULL, d->trans,
0, 0, 0, 0); 0, 0, 0, 0);
goto done; 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, usb_mtp_queue_result(s, RES_INCOMPLETE_TRANSFER, d->trans,
0, 0, 0, 0); 0, 0, 0, 0);
goto done; goto done;