hw/usb/dev-mtp: Correctly report free space
PATCH 1/1 hw/usb/dev-mtp: Correctly report free space
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).
--- hw/usb/dev-mtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/dev-mtp.c +1 -1
@@ -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 );
Signature · 1 line
2.45.2.627.g7a2c4fd464-goog
Quoted 14 lines · 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 <[email protected]>--- hw/usb/dev-mtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/usb/dev-mtp.c +0
-0
hw/usb/dev-mtp.c static MTPData *usb_mtp_get_storage_info(MTPState *s, MTPControl *c) · line 889
Quoted 5 lines
hw/usb/dev-mtp.c +1
-1@@ -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").
Quoted 3 lines
hw/usb/dev-mtp.c +0
-0usb_mtp_add_u32 (d, buf.f_ffree); }else {usb_mtp_add_u64 (d,0xffffffff );
Quoted 8 lines · 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 <[email protected]>--- hw/usb/dev-mtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Patch queued, thanks!