Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] android and mtp
Date: Sat, 22 Dec 2012 12:20:22
Message-Id: 20121222141512.2c2dbfef@khamul.example.com
In Reply to: Re: [gentoo-user] android and mtp by luis jure
1 On Sat, 22 Dec 2012 10:01:37 -0200
2 luis jure <ljc@××××××××××××.uy> wrote:
3
4 >
5 > on 2012-12-21 at 23:20 Neil Bothwick wrote:
6 >
7 > > No, and there's a good reason for that.
8 >
9 > well, i'm glad to know that there's a good reason to use MTP, because
10 > what i've read so far about it made me wonder...
11
12 It all becomes understandable when you figure out what MTP actually is.
13 It's Media Transfer Protocol, it's not eg Media Transfer Filesystem.
14 Wiki tells you some more:
15
16 http://en.wikipedia.org/wiki/Media_Transfer_Protocol
17
18 So it's a protocol for getting an entire file (originally usually an
19 mp3) from storage to a device that would play it. It makes sense to copy
20 the entire file to an mp3 player then play it, seeks would not involve
21 network (or bus) traffic.
22
23 Consider that http also doesn't let you usually transfer bits of
24 files. That protocol is also happier giving you all or nothing (yes,
25 you can do partial downloads, but that's not really a seek action,
26 it's a once-off action to say where the start of the copy happens from.
27
28
29
30
31 >
32 > from the link mark sent earlier:
33 >
34 > <quote>
35 > libmtp (and I assume the MTP protocol itself) doesn’t support seeking
36 > within a file or partial file reads or writes. You have to fetch or
37 > send the entire file. To simluate normal random access files, when a
38 > file is opened the entire file contents are copied from the device to
39 > a temporary file. Reads and writes then operate on the temporary
40 > file. When the file is closed (or if a flush or fsync occurs) then if
41 > a write has occurred since the file was last opened the entire
42 > contents of the temporary file are sent back to the device. This
43 > means repeatedly opening a file, making a small change, and closing
44 > it again will be very slow.
45 >
46 > Renaming or moving a file is implemented by copying the file from the
47 > device, writing it back to the device under the new name, and then
48 > deleting the original file. This makes renames, especially for large
49 > files, slow. This has special significance when using rsync to copy
50 > files to the device. Rsync copies to a temporary file, and then when
51 > the copy is complete it renames the temporary file to the real
52 > filename. So when rsyncing to a jmtpfs filessystem, for each file,
53 > the data gets copied to the device, read back, and then copied to the
54 > device again. There is a true rename (but not move) supported by
55 > libmtp, but this appears to confuse some Android apps, so I don’t use
56 > it. Image files, for example, will disappear from the Gallery if
57 > they’re renamed. </quote>
58 >
59
60
61
62 --
63 Alan McKinnon
64 alan.mckinnon@×××××.com

Replies

Subject Author
Re: [gentoo-user] android and mtp luis jure <ljc@××××××××××××.uy>