Skip to content

Normal file read/write support with the GVFS MTP backend!

A couple of weeks ago, Han-Wen Nienhuys, the author of go-mtpfs, pointed out to me that Android’s MTP implementation includes a set of methods that allow you to do normal read and write operations on files without having to do the whole download/upload dance. With these extensions, you can expose files in the way that most people expect – you can just open a text file, picture, video etc, make changes and save it back. As a bonus, this functionality also allows you to do very useful operations like copy or move a file on the device.

I’ve now had a chance to put together an initial implementation of support for these extensions, and my PPA is in the process of rebuilding packages, so people can try them out easily. I’ve not started the upstreaming process on the GVFS changes as I still need to get the libmtp changes approved and upstreamed, but the libmtp maintainer has been AWOL for a few weeks now.

Obviously, it’s important to remember that these extensions are Android specific and won’t help you if you have a non-Android device, nor if your Android device doesn’t use Google’s MTP implementation (which, unfortunately, includes most Samsung devices).

You can grab Ubuntu packages from my ppa and the source is available on my github page.

{ 7 } Comments

  1. Craig Thompson | 2nd April 2013 at 19:05 | Permalink

    Any idea when this functionality will be available for Samsung devices? I am running your gvfs mtp backend on 12.04 and it works great with my GS3 running 4.1.2, but I would like the ability to open/edit/save directly from my devices micro SD card.

    Thanks for all your help.

  2. Philip Langdale | 2nd April 2013 at 19:27 | Permalink

    That’s largely up to Samsung. They don’t use Google’s MTP implementation, and as a result, are missing these extensions. That means there’s no way to do direct writes to files. On the read side, they do implement the older GetPartialObject call, which is limited to operating on files up to 4GB in size (Google’s extensions include a 64bit version of this call). I will add support for GetPartialObject but I need to get a change into libmtp first to allow me to check if it’s supported or not.

    You’d need to switch to CyanogenMod or another AOSP based ROM to get the Google MTP stack.

  3. Hans-Joerg | 4th May 2013 at 01:42 | Permalink

    Hi Philip,

    Yesterday I bought a new Samsung S3 and was very happy to read, that You have closed that “gap” for automatically mounting a Andriod device on Ubuntu-systems. But by adding Your repository and the additional update I got the error-message:
    W: Fehlschlag beim Holen von 404 Not Found
    What is my fault? Could You please help?
    Kind regards

  4. Philip Langdale | 4th May 2013 at 06:43 | Permalink


    You’re running Ubuntu 10.04 which I didn’t create packages for; it’s just too old. At the very least, I’d recommend upgrading to 12.04 (the new LTS release) or preferably a newer release.

  5. Hans-Joerg | 4th May 2013 at 09:29 | Permalink

    Hi Philip,

    thanks for fast and helpfull answer!
    Than I will do so.
    Kind Regards

  6. Blackjackshellac | 22nd November 2013 at 08:26 | Permalink

    Good work, still annoyed that google decided to use this horrible protocol. Hopefully they can add some extensions to also support file-like metadata to the individual objects so that they don’t just look like a bunch of files from Dec-31-1969.

  7. Philip Langdale | 22nd November 2013 at 08:39 | Permalink

    The protocol supports basic metadata like that and gvfs-mtp reads it. The device may not be setting it.

Post a Comment

Your email is never published nor shared. Required fields are marked *