vendredi 22 avril 2016

mtp under [arch]linux: mtpfs vs gvfs-mtp [mount update]

Wanted to copy some file from a Moto G to my laptop. Installed mtpfs. Mounting took minutes and failed. As a last hope I tried gvfs-mtp. I don't know how to use the gvfs-* CLI though. But it's supposed to work out of the box in GTK apps. So Chromium + Ctrl-O. I can see the smartphone listed. Walk through the phone FS. It's instantaneous, snappy as I like it. But what about the CLI ?

Well gvfs-info says nothing. There's gvfs-mount, which says nothing. gvfs-mount --list outputs the mounted drives on this machine. And the last one is mtp://[usb:005,009]/ ... Hmm maybe gvfs-ls takes an URI ?

$ gvfs-ls mtp:/// # Error: The specified location is not mounted
$ gvfs-ls mtp://  # Error: The specified location is not mounted
$ gvfs-ls mtp:///sdcard # same as above

could the [usb:...] be mandatory ? odd syntax but alas

$ gvfs-ls mtp://[usb:005,009]/
Internal Storage # yay

$ gvfs-tree mtp://[usb:005,009]/ | head -n 32
mtp://[usb:005,009]/
`-- Internal Storage
    |-- .CM_Cloud
    |   |-- cm
    |   |   |-- cm_cloud_sdk_expand.db
    |   |   `-- cm_cloud_sdk_expand.db-journal
    |   `-- cmqp
    |       |-- cm_cloud_sdk_expand.db
    |       `-- cm_cloud_sdk_expand.db-journal
    |-- .DataStorage
    |   `-- ContextData.xml
    |-- .UTSystemConfig
    |   `-- Global
    |       `-- Alvin2.xml
    |-- .com.zwsoft.zwcad
    |   |-- local_Thumb
    |   |   |-- Fonts
    |   |   `-- Sample Drawings
    |   |       |-- Villa.dwg.png
    |   |       |-- ar_house_2.dwg.png
    |   |       |-- crane.dwg.png
    |   |       `-- l_1a.dwg.png
    |   |-- resources
    |   |   |-- adinit.dat
    |   |   |-- arialuni.ttf
    |   |   |-- plotstyle
    |   |   |   |-- Icad.ctb
    |   |   |   |-- Monochrome.ctb
    |   |   |   |-- zwcad-Color.stb
    |   |   |   |-- zwcad.ctb
    |   |   |   `-- zwcad.stb
    |   |   |-- zwcad.dwt

Didn't try to copy anything yet, I guess it won't be worse than doing a full http roundtrip over wifi as I did before.

ps: there was a side effect of trying gvfs through GTK file open dialog. It mounted the volume on click. Thus the ability to use gvfs-* afterwards.

So there's a few things to do in cli beforehand.

source: http://stackoverflow.com/questions/483460/how-to-mount-from-command-line-like-the-nautilus-does

$ gvfs-mount --list
Volume(0): XT1032
  Type: GProxyVolume (GProxyVolumeMonitorMTP)

This shows XT1032 (Moto G) is detected but not mounted. What we want is the following:

$ gvfs-mount --list
Volume(0): XT1032
  Type: GProxyVolume (GProxyVolumeMonitorMTP)
  Mount(0): XT1032 -> mtp://[usb:005,013]/
    Type: GProxyShadowMount (GProxyVolumeMonitorMTP)
Mount(1): mtp -> mtp://[usb:005,013]/
  Type: GDaemonMount

Usually to mount a 'storage' device, one uses /dev/sd*. But there's no sd* node for the XT1032.
gvfs-mount --list --info lists a bit more info (sic) (errata: --list -i)

$ Volume(0): XT1032
  Type: GProxyVolume (GProxyVolumeMonitorMTP)
  ids:
   unix-device: '/dev/bus/usb/005/013'
  activation_root=mtp://[usb:005,013]/
  themed icons:  [phone]
  symbolic themed icons:  [phone-symbolic]  [phone]
  can_mount=1
  can_eject=0
  should_automount=1

And trying with the /dev/bus/... path

$ gvfs-mount -d /dev/bus/usb/005/013
Mounted /dev/bus/usb/005/013 at /run/user/1000/gvfs/mtp:host=%5Busb%3A005%2C013%5D

$ gvfs-ls mtp://[usb:005,013]/                                                                                                                  
Internal Storage

# yay

Aucun commentaire:

Enregistrer un commentaire