Ubuntu – Some Ubuntu 13.04 applications cannot access files on MTP-mounted systems. Why

13.04androidgeditmtpnautilus

Ubuntu 13.04 comes with MTP support to access files on newer Android devices. My Nexus 10 works OK: after plugging in, I can access the N10 files with Nautilus, and I can copy from and to the device. Evince will open PDF files right from the device, but some applications fail to open files directly from the device like gedit or libreoffice. Gedit says something like:

Cannot open file mtp://[usb:001,009]/65537/5823/5824

I guess MTP is integrated at the gvfs level, so should not all gvfs-enabled applications be able to access the MTP device? Why evince but not gedit?

I know that MTP could be mounted with fuse, but it would be nice if it worked with regular applications from Nautilus just like sftp:// or smb://.

Best Answer

The MTP specification doesn't support the basic open/read/write/close operations that are required to implement normal file access on Linux - it only provides upload/download for files, and that's what the MTP backend implements.

Nautilus will copy files just fine, but as soon as you try to use an application that doesn't explicitly account for the restricted set of operations, you'll get an error. evince is an example of an app that does support it (it copies the file to /tmp then opens it).

So, that's what's going on in 13.04.

Now, it happens to be the case that Google implemented a set of MTP extensions in Android that offer open/read/write/close, and it's possible to provide normal file access with these. I've done this work in the gvfs development branch but it missed the 1.16 release window, so it's not going to show up in Ubuntu until 13.10 at the earliest. 14.04 and still not there

In the meantime, you can use my ppa to install builds where I have backported this work.

https://launchpad.net/~langdalepl/+archive/gvfs-mtp

Finally, it's important to note that these extensions only exist in Google's MTP stack. You have a Nexus 10, so it will work as it's running stock Android - but someone using a Samsung device, or devices from other manufacturers, will not have these extensions and might not have support for normal file I/O.

Related Question