From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1al8hV-0001Mr-Q8 for qemu-devel@nongnu.org; Wed, 30 Mar 2016 01:29:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1al8hU-0004ng-RF for qemu-devel@nongnu.org; Wed, 30 Mar 2016 01:29:53 -0400 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]:38536) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1al8hU-0004m8-Fd for qemu-devel@nongnu.org; Wed, 30 Mar 2016 01:29:52 -0400 Received: by mail-wm0-x22b.google.com with SMTP id 20so54243085wmh.1 for ; Tue, 29 Mar 2016 22:29:52 -0700 (PDT) MIME-Version: 1.0 Date: Wed, 30 Mar 2016 13:29:51 +0800 Message-ID: From: soccercheng Cheng Content-Type: multipart/alternative; boundary=047d7b86d66c5c8af2052f3d6f4d Subject: [Qemu-devel] How to enable the writable function in usb-mtp List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --047d7b86d66c5c8af2052f3d6f4d Content-Type: text/plain; charset=UTF-8 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. BTW, 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. Regards Sting static MTPData *usb_mtp_get_storage_info(MTPState *s, MTPControl *c) { MTPData *d = usb_mtp_data_alloc(c); struct statvfs buf; int rc; trace_usb_mtp_op_get_storage_info(s->dev.addr); // if (FLAG_SET(s, MTP_FLAG_WRITABLE)) { 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; } --047d7b86d66c5c8af2052f3d6f4d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi All,

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

D= oes any know how I can make MTP writable?

The following is my change fo= r your reference.=C2=A0

BTW,
I als= o find a bug when reporting available free space in byte to guest, the patc= hes is also in the code segment below in RED.

Regards

Sting
=

= =C2=A0
static MTPData *usb_mtp_get_sto= rage_info(MTPState *s, MTPControl *c)
= {
=C2=A0 =C2=A0 MTPData *d =3D usb_mtp= _data_alloc(c);
=C2=A0 =C2=A0 struct s= tatvfs buf;=C2=A0
=C2=A0 =C2=A0 int rc= ;

=C2=A0 =C2=A0 trace_usb_mtp_op_get_storage_info(s->dev.addr);

= // =C2=A0 =C2=A0if (FLAG_SET(s, MTP_FLAG_WRITABLE)) {
=C2=A0 =C2=A0= =C2=A0if(1) =C2=A0 =C2=A0{=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0= usb_mtp_add_u16(d, 0x0003);=C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 usb_mtp_add_u16(d, 0x0002); /* Filesystem Type: 0x0002 is Generic hiera= rchical */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 usb_mtp_add_u16(d, 0x= 0000); /* Access Capability, 0x0000 is for read-write =C2=A0 =C2=A0 */
=C2=A0 =C2=A0 } else {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 usb_mtp_add_u16(d, 0x0= 001);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 usb_= mtp_add_u16(d, 0x0002);
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 usb_mtp_add_u16(d, 0x0001);
=C2=A0 =C2=A0 } =C2=A0 =C2=A0

=
=C2=A0 =C2=A0 rc =3D statvfs(s->ro= ot, &buf);
=C2=A0 =C2=A0 if (rc = =3D=3D 0) {=C2=A0
=C2=A0 =C2=A0 =C2=A0= =C2=A0 usb_mtp_add_u64(d, (uint64_t)buf.f_frsize * buf.f_blocks);
=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0//usb_mtp_add_u64(d, (uint64_t)buf.f_bavail * buf.f_blocks);
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 usb_mtp_add_u64(d, (uint64_t)buf.f_frsize * buf.f_bavail)= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 u= sb_mtp_add_u32(d, buf.f_ffree); /* total # of free file nodes as free objec= t count */
=C2=A0 =C2=A0 } else {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 usb_mtp_add_u6= 4(d, 0xffffffff);
=C2=A0 =C2=A0 =C2=A0= =C2=A0 usb_mtp_add_u64(d, 0xffffffff);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 usb_mtp_add_u32(d, 0xffffffff);
=C2=A0 =C2=A0 }

=C2=A0 =C2=A0 usb_mtp_add_str(d= , s->desc);
=C2=A0 =C2=A0 usb_mtp_a= dd_wstr(d, L"123456789abcdef");
=C2=A0 =C2=A0 return d;
}
--047d7b86d66c5c8af2052f3d6f4d--