diff mbox series

usb-mtp: replace the homebrew write with qemu_write_full

Message ID jpg8szcc1ar.fsf_-_@linux.bootlegged.copy
State New
Headers show
Series usb-mtp: replace the homebrew write with qemu_write_full | expand

Commit Message

Bandan Das Jan. 22, 2019, 12:41 p.m. UTC
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 <bsd@redhat.com>
---
 hw/usb/dev-mtp.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

2.20.1

Comments

Gerd Hoffmann Jan. 24, 2019, 8:01 a.m. UTC | #1
On Tue, Jan 22, 2019 at 07:41:16AM -0500, Bandan Das wrote:
> 
> 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 <bsd@redhat.com>

Hmm, doesn't apply, and git fails to do a 3way merge too due to unknown
sha1.

cheers,
  Gerd
Bandan Das Jan. 24, 2019, 8:19 a.m. UTC | #2
Gerd Hoffmann <kraxel@redhat.com> writes:

> On Tue, Jan 22, 2019 at 07:41:16AM -0500, Bandan Das wrote:
>> 
>> 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 <bsd@redhat.com>
>
> Hmm, doesn't apply, and git fails to do a 3way merge too due to unknown
> sha1.
>

Oops, sorry, I realize now this is on top of the write buffer breakup patches.

Should I resend a v2 on top of master and send a v3 for the write buffer breakup
patches ?

> cheers,
>   Gerd
Gerd Hoffmann Jan. 24, 2019, 8:31 a.m. UTC | #3
On Thu, Jan 24, 2019 at 03:19:03AM -0500, Bandan Das wrote:
> Gerd Hoffmann <kraxel@redhat.com> writes:
> 
> > On Tue, Jan 22, 2019 at 07:41:16AM -0500, Bandan Das wrote:
> >> 
> >> 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 <bsd@redhat.com>
> >
> > Hmm, doesn't apply, and git fails to do a 3way merge too due to unknown
> > sha1.
> 
> Oops, sorry, I realize now this is on top of the write buffer breakup patches.

Hmm, they are queued up already, so that should have worked.

> Should I resend a v2 on top of master and send a v3 for the write buffer breakup
> patches ?

Can you just send a single series with both this fix and the breakup
patches, against latest master?

thanks,
  Gerd
diff mbox series

Patch

diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 31fa83589b..53e20e2161 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1630,25 +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)
--