You are not logged in.

#1 2012-05-17 00:38:41

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Mtpfs fails to show files in android sdcard subdirectories

Dear Archers,

TLDR: Using mtpfs with an android device in media transfer mode does not show all available files.


Longer:
I've been trying to get my Xperia Arc (Android 2.3.3) to play nicely in media transfer mode with my Arch Linux laptop.

The Arch Linux wiki section on mtp is currently a stub, so I loosely based my approach on this mtpfs how-to for Ubuntu combined with this automounting how-to for Arch Linux.

Specifically, I added the following lines to my automount.rules file under /etc/udev/rules.d:

# Android rule
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", ATTR{idProduct}=="014f", ACTION=="add", MODE="0666", RUN+="/bin/su <whoami> -c '/usr/bin/mtpfs -o allow_other /media/phone'"
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", ATTR{idProduct}=="014f", ACTION=="remove", RUN+='/bin/fusermount -u /media/phone'

where <whoami> is the name of my personal user account.

This seems to work okay. I can plug in my phone and ls like so:

$ ls /media/phone/Memory\ Card/
11-22-2011.pdf       bluetooth                  dietlist           games      MEMSTICK.IND      osmdroid     System            wallpapers
alarms               CDAInfo.txt                download           gmail.asc  MemStickInfo.txt  osmtracker   tmp
Android              customized-capability.xml  east_corridor.jpg  image      MSTK_PRO.IND      others       Traceability.txt
APG                  DCIM                       foursquare         LOST.DIR   music             PCCompanion  TurboGPS
battery_history.txt  default-capability.xml     Gameloft           media      notifications     ringtones    video

Problem: files in subdirectories from here do not appear. For example:

$ ls /media/phone/Memory\ Card/DCIM/100ANDRO/
$ 

This, despite the fact that I know there are over 50 photos in the DCIM/100ANDRO subdirectory. And this problem pervades the entire filesystem. Only files in the /media/phone/Memory\ Card/ base directory appear.

Edit: of course, I tried several variants on a google search that used terms like: android mtpfs linux fails subdirectories

Running "udevadm monitor" while {,un}plugging the phone gives:

monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[68329.972269] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
KERNEL[68329.972370] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
UDEV  [68332.843073] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
UDEV  [68332.848718] add      /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
KERNEL[68339.174915] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
KERNEL[68339.175235] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)
UDEV  [68339.199266] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2/2-1.2:1.0 (usb)
UDEV  [68339.201547] remove   /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.2 (usb)

Also, dmesg contains:

[68228.446581] usb 2-1.2: new high-speed USB device number 12 using ehci_hcd
[68228.531340] usb 2-1.2: New USB device found, idVendor=0fce, idProduct=014f
[68228.531351] usb 2-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[68228.531358] usb 2-1.2: Product: SEMC HSUSB Device
[68228.531363] usb 2-1.2: Manufacturer: SEMC
[68228.531367] usb 2-1.2: SerialNumber: 43423541314445533259
[68237.720580] usb 2-1.2: USB disconnect, device number 12

Questions:

  • Can anyone reproduce this problem?

  • Does anyone know how to get it working?

  • Is it a bug that I should report to the mtpfs devs?

  • Do you need more information?

Thanks for considering this problem. I look forward to any responses.

Last edited by /dev/zero (2012-05-17 00:41:42)

Offline

#2 2012-06-15 16:30:32

JKAbrams
Member
From: Sweden
Registered: 2011-11-07
Posts: 81

Re: Mtpfs fails to show files in android sdcard subdirectories

Have you got any progress on this?

I have a Samsung Galaxy Nexus with the the same kind of problem, but I've been messing around alot and somehow I got to a point where I can see the files in /media/nexus/ but I'm unable do normal file operations.
I suspect this may have to do with file permissions issues.

This is my setup (-vv):

Based on your file but I added a couple of options based on some other suggestions:

cat /etc/udev/rules.d/51-android.rules 
# Samsung Galaxy Nexus
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", OWNER="jk", ACTION=="add", MODE="0777" SYMLINK+="nexus", RUN+="/bin/su jk -c '/bin/mount /media/nexus'"
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", ACTION=="remove", RUN+='/bin/fusermount -u /media/nexus'

I'm unable to make the automount work, also tested with your version of the RUN command, but still does not mount/unmount the device.

I've uncommented user_allow_other in /etc/fuse.conf

$ cat /etc/fuse.conf 
# Allow non-root users to specify the 'allow_other' or 'allow_root'
# mount options.
user_allow_other

fuse added to MODULES array.
I did not have a group for fuse so I added one and added my user to the group. Is this nessesary?

Manually mounting the device (kind of) works:

$ cat /etc/fstab
<snip>
#GalaxyNexus
mtpfs                                           /media/nexus    fuse    user,noauto,allow_other         0       0
$ mount /media/nexus
Listing raw device(s)
Device 0 (VID=04e8 and PID=685c) is a Samsung Galaxy Nexus/Galaxy S i9000/i9250, Android 4.0 updates.
   Found 1 device(s):
   Samsung: Galaxy Nexus/Galaxy S i9000/i9250, Android 4.0 updates (04e8:685c) @ bus 1, dev 42
Attempting to connect device
Android device detected, assigning default bug flags
Listing File Information on Device with name: (NULL)

Is this last line a error btw? Sometimes it takes a while for the last line to show.

Before mounting

$ ls -la /media/
totalt 16K
drwxrwxrwx  5 root root 4,0K 13 jun 01.27 .
drwxr-xr-x 25 root root 4,0K 12 jun 23.35 ..
drwxr-xr-x  2 root root 4,0K  6 dec  2011 dvd
drwxrwxr-x  2 jk   jk   4,0K 13 jun 01.27 nexus

After mounting:

$ ls -la /media/
totalt 12K
drwxrwxrwx  5 root root 4,0K 13 jun 01.27 .
drwxr-xr-x 25 root root 4,0K 12 jun 23.35 ..
drwxr-xr-x  2 root root 4,0K  6 dec  2011 dvd
drwxrwxrwx  2 jk   jk      0  1 jan  1970 nexus

Now trying to copy files to the device does not work:

$ cp -fv /§/Music/Parody/Johnny\ Crass\ -\ Internet\ Sandman.mp3 /media/nexus/Internal\ Storage/Music/InternetSandman.mp3
”/§/Music/Parody/Johnny Crass - Internet Sandman.mp3” -> ”/media/nexus/Internal Storage/Music/InternetSandman.mp3”

The command executes imidiatly but nothing gets written. I can not find any error logged for this, where should I look?

However pasting the file i the filemanager dolphin gives the following error:
Could not change permissions for
/media/nexus/Internal Storage/Music/InternetSandman.mp3

By using mtp-connect, now this works:

$ mtp-connect --sendfile /§/Music/Parody/Johnny\ Crass\ -\ Internet\ Sandman.mp3 
libmtp version: 1.1.3

Device 0 (VID=04e8 and PID=685c) is a Samsung Galaxy Nexus/Galaxy S i9000/i9250, Android 4.0 updates.
Android device detected, assigning default bug flags
Send file /§/Music/Parody/Johnny Crass - Internet Sandman.mp3
Sending /§/Music/Parody/Johnny Crass - Internet Sandman.mp3 to KDE_MULTIHEAD=false
type: mp3, 2
Sending file...
Progress: 4286476 of 4286476 (100%)
New file ID: 373

The mp3 gets written in /media/nexus/Internal Storage/Music/

And I'm able to see the files on the device:

$ ls -la /media/nexus/Internal\ Storage/Music/
totalt 9,7M
drwxrwxrwx 2 jk jk    0  1 jan  1970 .
drwxrwxrwx 2 jk jk    0  1 jan  1970 ..
-rwxrwxrwx 1 jk jk 4,1M 15 jun 17.21 Johnny Crass - Internet Sandman.mp3
-rwxrwxrwx 1 jk jk 5,6M 15 jun 16.45 Laura Branigan - Self Control.mp3
drwxrwxrwx 2 jk jk    0  1 jan  1970 Nightwish

I'm currently using libmtp-git from AUR, but I cannot see any difference to normal libmtp 1.1.3.

As a workaround I found out that on my device I can set USB Debuggung = ON (under developer options) and then I'm able to use the program aafm or gmtp to send files to the device.
But the apps are a little cluncy and tries to be smart with placing the files, mp3-files always goes to Music folder, no matter where I put them (I think this application uses the mtp-connect method as above to write files), I want to be able to use a normal file manager and console to write files.

Edit: spelling

Last edited by JKAbrams (2012-06-15 16:32:35)

Offline

#3 2012-06-16 03:29:06

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: Mtpfs fails to show files in android sdcard subdirectories

JKAbrams wrote:

Have you got any progress on this?

Not really. A more recent thread took place here. Still no solution. The last I heard from the dev was,

Chris Debenham (mtpfs dev) wrote:

It looks like mtpfs is working okay - but the info coming back from libmtp
is not quite right.

So I guess the next step would be to file a bug report with the libmtp people.


I don't know the answers to all your other questions, but I'll do what I can:


JKAbrams wrote:

I did not have a group for fuse so I added one and added my user to the group. Is this nessesary?

I don't think it's necessary. I've never come across the idea before this. I don't have a fuse group, and yet I can use sshfs, and I've also managed to mount basic filesystems created when working through fuse tutorials.


JKAbrams wrote:

The command executes imidiatly but nothing gets written. I can not find any error logged for this, where should I look?

Have you tried running mtpfs with the flags, -d -f?


JKAbrams wrote:

As a workaround I found out that on my device I can set USB Debuggung = ON (under developer options) and then I'm able to use the program aafm or gmtp to send files to the device.

Interesting idea!

Last edited by /dev/zero (2012-06-16 03:30:17)

Offline

#4 2012-07-14 09:05:23

exterm
Member
Registered: 2011-05-01
Posts: 17

Re: Mtpfs fails to show files in android sdcard subdirectories

there is a (closed) libmtp bug report that could relate to this:
http://sourceforge.net/tracker/?func=de … tid=809061

Offline

Board footer

Powered by FluxBB