Write of existing objects by the initiator is acheived by
making a temporary buffer with the new changes, deleting the
old file and then writing a new file with the same name.
Also, add a "readonly" property which needs to be set to false
for deletion to work.
Signed-off-by: Bandan Da
Fix a possible null dereference when deleting a folder and
its contents. An ignored event might be received for its contents
after the parent folder is deleted which will return a null object.
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions
ng. Depending on
the MTP client, it may choose not to implement it (such as simple-mtpfs that
runs on top of fuse).
- Needs more testing :)
Bandan Das (5):
usb-mtp: Add one more argument when building results
usb-mtp: print parent path in IN_IGNORED trace fn
usb-mtp: Support delete o
Eric Blake writes:
> On 02/20/2018 09:28 AM, Gerd Hoffmann wrote:
>> From: Bandan Das
>>
>> Allow write operations on behalf of the initiator. The
>> precursor to write is the sending of the write metadata
>> that consists of the ObjectInfo dataset. This patch
The response to a SendObjectInfo consists of the storageid,
parent obejct handle and the handle reserved for the new
incoming object
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 50 +++---
1 file changed, 27 insertions(+), 23 deletions(-)
diff
initiator (The SendObjectInfo implementation is in a
later patch)
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 152 ++-
1 file changed, 150 insertions(+), 2 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 5ef77f3e9f
Fix a possible null dereference when deleting a folder and
its contents. An ignored event might be received for its contents
after the parent folder is deleted which will return a null object.
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions
more testing :)
Bandan Das (5):
usb-mtp: Add one more argument when building results
usb-mtp: print parent path in IN_IGNORED trace fn
usb-mtp: Support delete of mtp objects
usb-mtp: Introduce write support for MTP objects
usb-mtp: Advertise SendObjectInfo for write support
hw/usb/de
Write of existing objects by the initiator is acheived by
making a temporary buffer with the new changes, deleting the
old file and then writing a new file with the same name.
Also, add a "readonly" property which needs to be set to false
for deletion to work.
Signed-off-by: Bandan Da
igned-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 132 ++-
1 file changed, 130 insertions(+), 2 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 9b51708614..086296f415 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -47,6
Daniel P. Berrangé writes:
>> #define TYPE_USB_MTP "usb-mtp"
>> @@ -804,6 +815,7 @@ static MTPData *usb_mtp_get_device_info(MTPState *s,
>> MTPControl *c)
>> CMD_GET_OBJECT_HANDLES,
>> CMD_GET_OBJECT_INFO,
>> CMD_DELETE_OBJECT,
>> +CMD_SEND_OBJECT,
>
> Seems w
initiator (The SendObjectInfo implementation is in a
later patch)
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 157 ++-
1 file changed, 155 insertions(+), 2 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 5ef77f3e9f
implement it (such as simple-mtpfs that
runs on top of fuse).
- Needs more testing :)
Bandan Das (5):
usb-mtp: Add one more argument when building results
usb-mtp: print parent path in IN_IGNORED trace fn
usb-mtp: Support delete of mtp objects
usb-mtp: Introduce write support for MTP
Fix a possible null dereference when deleting a folder and
its contents. An ignored event might be received for its contents
after the parent folder is deleted which will return a null object.
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions
The response to a SendObjectInfo consists of the storageid,
parent obejct handle and the handle reserved for the new
incoming object
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 50 +++---
1 file changed, 27 insertions(+), 23 deletions(-)
diff
igned-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 136 ++-
1 file changed, 134 insertions(+), 2 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 6372c11e81..a6ba57 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -47,6
Write of existing objects by the initiator is acheived by
making a temporary buffer with the new changes, deleting the
old file and then writing a new file with the same name.
Also, add a "readonly" property which needs to be set to false
for deletion to work.
Signed-off-by: Bandan Da
initiator (The SendObjectInfo implementation is in a
later patch)
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 157 ++-
1 file changed, 155 insertions(+), 2 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 5ef77f3e9f
Write of existing objects by the initiator is acheived by
making a temporary buffer with the new changes, deleting the
old file and then writing a new file with the same name.
Also, add a "readonly" property which needs to be set to false
for deletion to work.
Signed-off-by: Bandan Da
Fix a possible null dereference when deleting a folder and
its contents. An ignored event might be received for its contents
after the parent folder is deleted which will return a null object.
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions
The response to a SendObjectInfo consists of the storageid,
parent obejct handle and the handle reserved for the new
incoming object
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 50 +++---
1 file changed, 27 insertions(+), 23 deletions(-)
diff
un fsync when saving. Depending on
the MTP client, it may choose not to implement it (such as simple-mtpfs that
runs on top of fuse).
- Needs more testing :)
Bandan Das (5):
usb-mtp: Add one more argument when building results
usb-mtp: print parent path in IN_IGNORED trace fn
usb-mtp: Supp
igned-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 136 ++-
1 file changed, 134 insertions(+), 2 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index ecb37828d5..6ecf70a79b 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -47,6
Greg Kurz writes:
...
>>
>> I think there's an underlying problem with this code which we
>> should deal with differently. The 'dataset' local in this
>> file is (I think) pointing at on-the-wire information from
>> the USB device, but we're treating it as an array of
>> host-order uint16_t value
v2:
Rebase
Prevent a null dereference when deleting objects
Fix some coverity issues and a few others pointed out by Peter
Bandan Das (3):
usb-mtp: return incomplete transfer on a lstat failure
usb-mtp: fix some usb_mtp_write_data return paths
usb-mtp: prevent null dereference while
MTP writes objects in small chunks and at the end gets the
real file size to update the object metadata. If this fails for
any reason, return an INCOMPLETE_TRANSFER to the initiator
Spotted by Coverity: CID 1398651
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 19 ++-
1 file
Spotted by Coverity: CID 1399144
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 1f22284949..06e376bcd2 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1177,9 +1177,7
During a write, free up the "path" before getting more data.
Also, while we at it, remove the confusing usage of d->fd for
storing mkdir status
Spotted by Coverity: CID 1398642
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 18 ++
1 file changed, 10 insertions(+)
Peter Maydell writes:
> On Fri, 15 Feb 2019 at 18:45, Bandan Das wrote:
>>
...
>> I believe this is a false positive, there's still more data incoming
>> and we have successfully written the data we got this time, so we return
>> without freeing up any of the
Peter Maydell writes:
> On Wed, 30 Jan 2019 at 07:41, Gerd Hoffmann wrote:
>>
>> From: Bandan Das
>>
>> For every MTP_WRITE_BUF_SZ copied, this patch writes it to file before
>> getting the next block of data. The file is kept opened for the
>> duration
n absolute path.
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 38 --
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 9846e4b513..7c07295519 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -2
This function is used in the delete path only and can
be replaced by a call to usb_mtp_object_free.
Reviewed-by: Peter Maydell
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 14 ++
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
,
only READ_ONLY can be returned.
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 62 ++--
1 file changed, 34 insertions(+), 28 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 06e376bcd2..91b820baaf 100644
--- a/hw/usb/dev-mtp.c
Gerd Hoffmann writes:
> On Thu, Mar 28, 2019 at 01:37:21PM -0400, Bandan Das wrote:
>> This function is used in the delete path only and can
>> be replaced by a call to usb_mtp_object_free.
>>
>> Reviewed-by: Peter Maydell
>> Signed-off-by: Bandan Das
>
>
make it less confusing. Applies on top of
[PATCH v3] usb-mtp: fix return status of delete
Message-ID:
Bandan Das (3):
usb-mtp: fix return status of delete
usb-mtp: remove usb_mtp_object_free_one
usb-mtp: refactor the flow of usb_mtp_write_data
hw/usb/dev-mtp.c | 133
There's no functional change but the flow is (hopefully)
more consistent for both file and folder object types.
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 57 +---
1 file changed, 30 insertions(+), 27 deletions(-)
diff --git a/hw/usb/dev-
go and there won't be
an object for it.
Fixes: c5ead51f90cf
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index ebf210fbf8..5de22738ce 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-
Forgot to cc people ...
Bandan Das writes:
> Commit c5ead51f90cf (usb-mtp: return incomplete transfer on a lstat
> failure) checks if lstat succeeded when updating attributes of a
> file. However, it also changed behavior to return an error by
> default. This is incorrect because
Daniel P. Berrangé writes:
> Two previous attempts to fix this due to GCC 9 highlighting
> unaligned data access. My attempt:
>
> https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg07763.html
>
> And a previous one:
>
> https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg07923.html
Daniel P. Berrangé writes:
> The ObjectInfo 'length' field provides the length of the
> wide character string filename. This is then converted to
> a multi-byte character string. This may have a different
> byte count to the wide character string. We should use the
> C string length of the multi-
During a write, free up the "path" before getting more data.
Also, while we at it, remove the confusing usage of d->fd for
storing mkdir status
Spotted by Coverity: CID 1398642
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 18 ++
1 file changed, 10 insertions(+)
Fix some coverity issues and a few others pointed out by Peter
Bandan Das (2):
usb-mtp: return incomplete transfer on a lstat failure
usb-mtp: fix some usb_mtp_write_data return paths
hw/usb/dev-mtp.c | 38 +-
1 file changed, 25 insertions(+), 13
MTP writes objects in small chunks and at the end gets the
real file size to update the object metadata. If this fails for
any reason, return an INCOMPLETE_TRANSFER to the initiator
Spotted by Coverity: CID 1398651
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 20 +++-
1
Daniel P. Berrangé writes:
...
>> > The store is read only by default. Are you trying something like:
>> > -device usb-mtp,rootdir=/code/mtpshare,readonly=false ?
>>
>> Ah ha, I didn't realize I had to enable write support explicitly. Will
>> retry with that.
>
> Even after setting readonly=fal
Daniel P. Berrangé writes:
> On Tue, Apr 16, 2019 at 12:10:16PM -0400, Bandan Das wrote:
>> Daniel P. Berrangé writes:
>> ...
>> >> > The store is read only by default. Are you trying something like:
>> >> > -device usb-mtp,rootdir=/code/mtpshare,
Daniel P. Berrangé writes:
>> I can't find usb-mtp sending a "I/O error" on an error condition
>> for the objectinfo phase. It might be libmtp or even the command itself
>> failing for some reason. For incomplete transfer, I just checked, it's
>> spitting out the error message correctly as INCOMP
ename = utf16_to_str(MIN(dataset->length,
> -dlen - offsetof(ObjectInfo, filename)),
> +filename = utf16_to_str(MIN(dataset->length, filename_chars),
> dataset->filename);
>
> if (strchr(filename, '/')) {
Reviewed-by: Bandan Das
Peter Maydell writes:
> On Fri, 8 Mar 2019 at 19:39, Bandan Das wrote:
>>
>> Peter Maydell writes:
>> > But the two places in usb_mtp_get_data() that call
>> > usb_mtp_write_metadata() still don't check its return
>> > value: don't they need
filemonitor-inotify.c b/util/filemonitor-inotify.c
> index 3a72be037f..3eb29f860b 100644
> --- a/util/filemonitor-inotify.c
> +++ b/util/filemonitor-inotify.c
> @@ -29,7 +29,7 @@
>
> struct QFileMonitor {
> int fd;
> -
> +int nextid; /* watch ID counter */
> QemuMutex lock; /* protects dirs & idmap */
> GHashTable *dirs; /* dirname => QFileMonitorDir */
> GHashTable *idmap; /* inotify ID => dirname */
> @@ -47,7 +47,6 @@ typedef struct {
> typedef struct {
> char *path;
> int id; /* inotify ID */
> -int nextid; /* watch ID counter */
> GArray *watches; /* QFileMonitorWatch elements */
> } QFileMonitorDir;
>
> @@ -277,7 +276,7 @@ qemu_file_monitor_add_watch(QFileMonitor *mon,
> }
> }
>
> -watch.id = dir->nextid++;
> +watch.id = mon->nextid++;
> watch.filename = g_strdup(filename);
> watch.cb = cb;
> watch.opaque = opaque;
Thanks, this fixes it! I had a related question about the way
qemu_file_monitor_add_watch works.
Am I correct in understanding that if there is already a watch on a dir,
we return back mon->nextid++ i.e the next free id. Why don't we return
back the originally assigned watchid ?
Reviewed-and-tested-by: Bandan Das
Daniel P. Berrangé writes:
...
>> Thanks, this fixes it! I had a related question about the way
>> qemu_file_monitor_add_watch works.
>>
>> Am I correct in understanding that if there is already a watch on a dir,
>> we return back mon->nextid++ i.e the next free id. Why don't we return
>> back th
Peter Maydell writes:
...
>> +} else {
>> +usb_mtp_queue_result(s, RES_STORE_FULL, d->trans,
>> + 0, 0, 0, 0);
>> +}
>
> Presumably one of these should be RES_OK of some kind ?
>
Ah, yes, that's a typo.
>
Daniel P. Berrangé writes:
> On Fri, Mar 15, 2019 at 01:24:42PM -0400, Bandan Das wrote:
>> Daniel P. Berrangé writes:
>> ...
>> >> Thanks, this fixes it! I had a related question about the way
>> >> qemu_file_monitor_add_watch works.
>> >>
&
y sets watches on the directory as a
> whole, not files within, so there is no risk of guest
> triggered wrap around on the low 32 bits.
>
> Signed-off-by: Daniel P. Berrangé
> ---
>
> Depends: <20190314151527.25533-1-berra...@redhat.com>
>
Reviewed-by: Bandan Da
This function is used in the delete path only and can
be replaced by a call to usb_mtp_object_free.
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 14 ++
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 91b820baaf..4dc1317e2e
There's no functional change but the flow is (hopefully)
more consistent for both file and folder object types.
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 58 +---
1 file changed, 30 insertions(+), 28 deletions(-)
diff --git a/hw/usb/dev-
The first patch removes a unnecessary function
and the second is just a code reorg of usb_mtp_write_data
to make it less confusing. Applies on top of
[PATCH v3] usb-mtp: fix return status of delete
Message-ID:
Bandan Das (2):
usb-mtp: remove usb_mtp_object_free_one
usb-mtp: refactor the flow
There's no functional change but the flow is (hopefully)
more consistent for both file and folder object types.
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 53
1 file changed, 26 insertions(+), 27 deletions(-)
diff --git a/hw/usb/dev-
This function is used in the delete path only and can
be replaced by a call to usb_mtp_object_free.
Reviewed-by: Peter Maydell
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 14 ++
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
Message-ID:
Bandan Das (2):
usb-mtp: remove usb_mtp_object_free_one
usb-mtp: refactor the flow of usb_mtp_write_data
hw/usb/dev-mtp.c | 67
1 file changed, 28 insertions(+), 39 deletions(-)
--
2.19.2
Peter Maydell writes:
> On Tue, 26 Mar 2019 at 17:58, Bandan Das wrote:
>>
>
...
> Doesn't this mean you're no longer sending the RES_OK result
> for this case ?
>
Ugh, I messed up this version. I will send a v3 and
fix the indentation to
confusing. Applies on top of
[PATCH v3] usb-mtp: fix return status of delete
Message-ID:
Bandan Das (2):
usb-mtp: remove usb_mtp_object_free_one
usb-mtp: refactor the flow of usb_mtp_write_data
hw/usb/dev-mtp.c | 71 ++--
1 file changed, 32 insertions
There's no functional change but the flow is (hopefully)
more consistent for both file and folder object types.
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 57 +---
1 file changed, 30 insertions(+), 27 deletions(-)
diff --git a/hw/usb/dev-
This function is used in the delete path only and can
be replaced by a call to usb_mtp_object_free.
Reviewed-by: Peter Maydell
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 14 ++
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
Peter Maydell writes:
> On Fri, 19 Oct 2018 at 10:22, dcb <1798...@bugs.launchpad.net> wrote:
>> hw/usb/dev-mtp.c:1616:52: warning: logical ‘or’ of collectively
>> exhaustive tests is always true [-Wlogical-op]
>>
>> Source code is
>>
>> if ((ret == -1) && (errno != EINTR || errno
qemu_write_full takes care of partial blocking writes,
as in cases of larger file sizes
Suggested-by: Peter Maydell
Signed-off-by: Bandan
---
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 31fa8358
Gerd Hoffmann 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
>> Signed-off-by: Bandan
>
> H
buffer again instead of reallocating to a larger buffer size.
Tested with different file sizes on a Linux guest.
Bandan Das (3):
usb-mtp: Reallocate buffer in multiples of MTP_WRITE_BUF_SZ
usb-mtp: breakup MTP write into smaller chunks
usb-mtp: replace the homebrew write with qemu_write_full
This is a "pre-patch" to breaking up the write buffer for
MTP writes. Instead of allocating a mtp buffer equal to size
sent by the initiator, we start with a small size and reallocate
multiples (of that small size) as needed.
Signed-off-by: Bandan Das
---
hw/usb/dev-
qemu_write_full takes care of partial blocking writes,
as in cases of larger file sizes
Signed-off-by: Bandan Das
---
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
file size in the object metadata once the file has
completely been written.
Suggested-by: Gerd Hoffman
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 134 ---
1 file changed, 91 insertions(+), 43 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev
file upto a certain data size we have received so far and second,
reuse the buffer again instead of reallocating to a larger buffer size.
Tested with different file sizes on a Linux guest.
Bandan Das (3):
usb-mtp: Reallocate buffer in multiples of MTP_WRITE_BUF_SZ
usb-mtp: breakup MTP write
This is a "pre-patch" to breaking up the write buffer for
MTP writes. Instead of allocating a mtp buffer equal to size
sent by the initiator, we start with a small size and reallocate
multiples (of that small size) as needed.
Signed-off-by: Bandan Das
---
hw/usb/dev-
Eric Blake writes:
> On 1/28/19 8:24 AM, Bandan Das wrote:
>> This is a "pre-patch" to breaking up the write buffer for
>> MTP writes. Instead of allocating a mtp buffer equal to size
>> sent by the initiator, we start with a small size and reallocate
>> mul
qemu_write_full takes care of partial blocking writes,
as in cases of larger file sizes
Suggested-by: Peter Maydell
Signed-off-by: Bandan Das
---
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
file size in the object metadata once the file has
completely been written.
Suggested-by: Gerd Hoffman
Signed-off-by: Bandan Das
---
hw/usb/dev-mtp.c | 134 ---
1 file changed, 91 insertions(+), 43 deletions(-)
diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev
301 - 375 of 375 matches
Mail list logo