• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.settings/H20-Apr-2019-6867

autom4te.cache/H20-Apr-2019-14,00612,768

src/H20-Apr-2019-3,9492,611

.autotoolsH A D20-Apr-20191.4 KiB4342

.cprojectH A D20-Apr-201920.1 KiB417415

.projectH A D20-Apr-20192.3 KiB8079

.pydevprojectH A D20-Apr-2019304 86

AUTHORSH A D20-Apr-201945 31

COPYINGH A D20-Apr-201934.3 KiB674553

ChangeLogH A D20-Apr-20190

INSTALLH A D20-Apr-201915.6 KiB378292

Makefile.amH A D20-Apr-201912 21

Makefile.inH A D20-Apr-201922.4 KiB726641

NEWSH A D20-Apr-201982 74

README.rstH A D20-Apr-20194.2 KiB10177

aclocal.m4H A D20-Apr-201939.6 KiB1,1321,014

config.guessH A D20-Apr-201943.9 KiB1,5021,291

config.subH A D20-Apr-201933.6 KiB1,7061,558

configureH A D20-Apr-2019179.2 KiB6,2115,088

configure.acH A D20-Apr-2019521 3319

depcompH A D20-Apr-201918.2 KiB631407

install-shH A D20-Apr-201913.3 KiB521344

missingH A D20-Apr-201911.2 KiB377281

README.rst

1
2
3jmtpfs:
4
5
6
7
8jmtpfs is a FUSE and libmtp based filesystem for accessing MTP (Media Transfer
9Protocol) devices. It was specifically designed for exchaning files between
10Linux (and Mac OS X) systems and newer Android devices that support MTP but not USB Mass
11Storage.
12
13The goal is to create a well behaved filesystem, allowing tools like find and
14rsync to work as expected. MTP file types are set automatically based on file
15type detection using libmagic. Setting the file appears to be necessary for
16some Android apps, like  Gallery, to be able to find and use the files.
17
18Since it is meant as an Android file transfer utility, and I don't have
19any non-Android MTP devices to test with, playlists and other non-file
20based data are not supported.
21
22Building and installing:
23
24See the INSTALL file.
25
26Usage:
27
28Run jmtpfs with a directory as a parameter, and it will mount to that directory
29the first MTP device it finds. You can then access the files on the device as
30if it were a normal disk.
31
32[jason@colossus ~]$ jmtpfs ~/mtp
33Device 0 (VID=04e8 and PID=6860) is a Samsung GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note.
34Android device detected, assigning default bug flags
35[jason@colossus ~]$ ls ~/mtp
36Internal Storage
37[jason@colossus ~]$ ls ~/mtp/Internal\ Storage/
38Android  burstlyImageCache  DCIM  Music  Notifications  Pictures  testdir
39[jason@colossus ~]$ df -h ~/mtp/Internal\ Storage
40Filesystem      Size  Used Avail Use% Mounted on
41jmtpfs           14G  3.1G   11G  23% /home/jason/mtp
42[jason@colossus ~]$ cd ~/mtp/Internal\ Storage/
43[jason@colossus Internal Storage]$ ls
44Android  burstlyImageCache  DCIM  Music  Notifications  Pictures  testdir
45[jason@colossus Internal Storage]$ cat > test.txt
46Hello Android!
47[jason@colossus Internal Storage]$ ls
48Android            DCIM   Notifications  testdir
49burstlyImageCache  Music  Pictures       test.txt
50[jason@colossus Internal Storage]$ cat test.txt
51Hello Android!
52[jason@colossus Internal Storage]$ rm test.txt
53[jason@colossus Internal Storage]$
54
55Pass the -l option will list the attached MTP devices.
56
57[jason@colossus ~]$ workspace/jmtpfs/src/jmtpfs -l
58Device 0 (VID=04e8 and PID=6860) is a Samsung GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note.
59Available devices (busLocation, devNum, productId, vendorId, product, vendor):
602, 19, 0x6860, 0x04e8, GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note, Samsung
61
62You can choose which device to mount with the -device option.
63
64[jason@colossus ~]$ workspace/jmtpfs/src/jmtpfs -device=2,19 ~/mtp
65Device 0 (VID=04e8 and PID=6860) is a Samsung GT-P7310/P7510/N7000/I9100/Galaxy Tab 7.7/10.1/S2/Nexus/Note.
66Android device detected, assigning default bug flags
67[jason@colossus ~]$ ls ~/mtp
68Internal Storage
69
70Unmount with fusermount.
71
72[jason@colossus ~]$ ls ~/mtp
73Internal Storage
74[jason@colossus ~]$ fusermount -u ~/mtp
75[jason@colossus ~]$ ls ~/mtp
76[jason@colossus ~]$
77
78
79Performance and implementation notes:
80
81libmtp (and I assume the MTP protocol itself) doesn't support seeking within a
82file or partial file reads or writes. You have to fetch or send the entire
83file. To simluate normal random access files, when a file is opened the entire
84file contents are copied from the device to a temporary file. Reads and writes
85then operate on the temporary file. When the file is closed (or if a flush or
86fsync occurs) then if a write has occurred since the file was last opened the
87entire contents of the temporary file are sent back to the device. This means
88repeatedly opening a file, making a small change, and closing it again will
89be very slow.
90
91Renaming or moving a file is implemented by copying the file from the device,
92writing it back to the device under the new name, and then deleting the
93original file. This makes renames, especially for large files, slow. This
94has special significance when using rsync to copy files to the device. Rsync
95copies to a temporary file, and then when the copy is complete it renames the
96temporary file to the real filename. So when rsyncing to a jmtpfs filessystem,
97for each file, the data gets copied to the device, read back, and then copied
98to the device again. There is a true rename (but not move) supported by libmtp,
99but this appears to confuse some Android apps, so I don't use it. Image files,
100for example, will disappear from the Gallery if they're renamed.
101