qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Fabio D'Urso <fdurso@google.com>, qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [PATCH] hw/usb/dev-mtp: Correctly report free space
Date: Tue, 18 Jun 2024 06:27:15 +0200	[thread overview]
Message-ID: <8afcbe55-f9d9-47d7-8173-53e688d05120@linaro.org> (raw)
In-Reply-To: <20240618003657.3344685-1-fdurso@google.com>

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);



  reply	other threads:[~2024-06-18  4:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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é [this message]
2024-06-18 15:40 ` Philippe Mathieu-Daudé

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=8afcbe55-f9d9-47d7-8173-53e688d05120@linaro.org \
    --to=philmd@linaro.org \
    --cc=fdurso@google.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).