[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] How to enable the writable function in usb-mtp

From: soccercheng Cheng
Subject: [Qemu-devel] How to enable the writable function in usb-mtp
Date: Wed, 30 Mar 2016 13:29:51 +0800

Hi All,

I've found that in the current dev-mtp.c, if I set the storage access capability to 0x0000 (Access Capability, 0x0000 is for read-write ), it still wont' work, the guest Windows treats the exposed MTP as read-only. 

Does any know how I can make MTP writable?

The following is my change for your reference. 

I also find a bug when reporting available free space in byte to guest, the patches is also in the code segment below in RED.



static MTPData *usb_mtp_get_storage_info(MTPState *s, MTPControl *c)
    MTPData *d = usb_mtp_data_alloc(c);
    struct statvfs buf; 
    int rc;


    if(1)    { 
        usb_mtp_add_u16(d, 0x0003); 
        usb_mtp_add_u16(d, 0x0002); /* Filesystem Type: 0x0002 is Generic hierarchical */
        usb_mtp_add_u16(d, 0x0000); /* Access Capability, 0x0000 is for read-write     */
    } else {
        usb_mtp_add_u16(d, 0x0001);
        usb_mtp_add_u16(d, 0x0002);
        usb_mtp_add_u16(d, 0x0001);

    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); /* total # of free file nodes as free object count */
    } else {
        usb_mtp_add_u64(d, 0xffffffff);
        usb_mtp_add_u64(d, 0xffffffff);
        usb_mtp_add_u32(d, 0xffffffff);

    usb_mtp_add_str(d, s->desc);
    usb_mtp_add_wstr(d, L"123456789abcdef");
    return d;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]