* [PATCH] hw/usb/dev-mtp: Correctly report free space
@ 2024-06-18 0:36 Fabio D'Urso
2024-06-18 4:27 ` Philippe Mathieu-Daudé
2024-06-18 15:40 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 3+ messages in thread
From: Fabio D'Urso @ 2024-06-18 0:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Fabio D'Urso
In order to compute the amount of free space (in bytes), the number
of available blocks (f_bavail) should be multiplied by the block
size (f_frsize) instead of the total number of blocks (f_blocks).
Signed-off-by: Fabio D'Urso <fdurso@google.com>
---
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 7e4a0765ae..554b397e88 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -886,7 +886,7 @@ static MTPData *usb_mtp_get_storage_info(MTPState *s, MTPControl *c)
rc = statvfs(s->root, &buf);
if (rc == 0) {
usb_mtp_add_u64(d, (uint64_t)buf.f_frsize * buf.f_blocks);
- usb_mtp_add_u64(d, (uint64_t)buf.f_bavail * buf.f_blocks);
+ usb_mtp_add_u64(d, (uint64_t)buf.f_frsize * buf.f_bavail);
usb_mtp_add_u32(d, buf.f_ffree);
} else {
usb_mtp_add_u64(d, 0xffffffff);
--
2.45.2.627.g7a2c4fd464-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hw/usb/dev-mtp: Correctly report free space
2024-06-18 0:36 [PATCH] hw/usb/dev-mtp: Correctly report free space Fabio D'Urso
@ 2024-06-18 4:27 ` Philippe Mathieu-Daudé
2024-06-18 15:40 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-06-18 4:27 UTC (permalink / raw)
To: Fabio D'Urso, qemu-devel; +Cc: Gerd Hoffmann
On 18/6/24 02:36, Fabio D'Urso wrote:
> In order to compute the amount of free space (in bytes), the number
> of available blocks (f_bavail) should be multiplied by the block
> size (f_frsize) instead of the total number of blocks (f_blocks).
>
> Signed-off-by: Fabio D'Urso <fdurso@google.com>
> ---
> 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 7e4a0765ae..554b397e88 100644
> --- a/hw/usb/dev-mtp.c
> +++ b/hw/usb/dev-mtp.c
> @@ -886,7 +886,7 @@ static MTPData *usb_mtp_get_storage_info(MTPState *s, MTPControl *c)
> rc = statvfs(s->root, &buf);
> if (rc == 0) {
> usb_mtp_add_u64(d, (uint64_t)buf.f_frsize * buf.f_blocks);
> - usb_mtp_add_u64(d, (uint64_t)buf.f_bavail * buf.f_blocks);
> + usb_mtp_add_u64(d, (uint64_t)buf.f_frsize * buf.f_bavail);
Indeed (USB MTP Spec v1.1, 5.2.2.5 "Free Space In Bytes").
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> usb_mtp_add_u32(d, buf.f_ffree);
> } else {
> usb_mtp_add_u64(d, 0xffffffff);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hw/usb/dev-mtp: Correctly report free space
2024-06-18 0:36 [PATCH] hw/usb/dev-mtp: Correctly report free space Fabio D'Urso
2024-06-18 4:27 ` Philippe Mathieu-Daudé
@ 2024-06-18 15:40 ` Philippe Mathieu-Daudé
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-06-18 15:40 UTC (permalink / raw)
To: Fabio D'Urso, qemu-devel; +Cc: Gerd Hoffmann
On 18/6/24 02:36, Fabio D'Urso wrote:
> In order to compute the amount of free space (in bytes), the number
> of available blocks (f_bavail) should be multiplied by the block
> size (f_frsize) instead of the total number of blocks (f_blocks).
>
> Signed-off-by: Fabio D'Urso <fdurso@google.com>
> ---
> hw/usb/dev-mtp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Patch queued, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-18 15:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-18 0:36 [PATCH] hw/usb/dev-mtp: Correctly report free space Fabio D'Urso
2024-06-18 4:27 ` Philippe Mathieu-Daudé
2024-06-18 15:40 ` Philippe Mathieu-Daudé
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).