Gentoo Archives: gentoo-user

From: Rich Freeman <rich0@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Why is "mtp-probe" running when I plug in a USB device?
Date: Fri, 21 Jan 2022 22:05:27
In Reply to: [gentoo-user] Why is "mtp-probe" running when I plug in a USB device? by Grant Edwards
1 On Fri, Jan 21, 2022 at 4:23 PM Grant Edwards <grant.b.edwards@×××××.com> wrote:
2 >
3 > Why does that library think it should be probing every USB device I
4 > plug in? Is that automatic probing required for libmtp and mtpfs to
5 > work?
7 I'm guessing that MTP cannot be detected by just looking at a device
8 ID/etc and requires some kind of interrogation. It looks like libmtp
9 is designed to create a device node /dev/libmtp-1-4 which I'm guessing
10 it uses for later operations like mounting/etc. Doing this at time of
11 insertion makes the most sense, since that is how most device nodes
12 work.
14 Note that anytime you plug in a USB device, or just about any other
15 device, code tends to run. When a sound device raises an IRQ to call
16 attention to its buffer being exhausted, code tends to run. When a
17 hard drive is asked to read a block off the disk and has it available
18 to read, it likely raises an interrupt, and code runs. Much of this
19 code is in the kernel, but there is a general trend towards moving
20 more of this stuff into userspace, so now you notice it more, vs it
21 just showing up as a system % cpu figure in top with little
22 transparency into what is going on if you aren't actually doing traces
23 of some kind. With tools like udev more of this is configurable as
24 you've noticed.
26 I wouldn't view any of this as a bad thing. You're more aware of it
27 now, and you have more control over it now, and if the code does the
28 run thing it is more likely to be running as nobody instead of as the
29 kernel.
31 Why should it be strange that when you plug in a device, the operating
32 system tries to figure out what sort of device it is, and set it up so
33 that you can access it from userspace?
35 > I do _not_ want anything to happen "automagically" when I plug in a
36 > USB mtp device. I know if a device is an MTP device, and if I want it
37 > mounted, I'll mount it manually.
39 Well, you can of course disable the udev rule. I'm not sure if there
40 are issues with running device probing on demand. Obviously the whole
41 udev framework is designed to dynamically create and destroy device
42 nodes as devices are plugged in or removed.
44 Would you want /dev/sdb to not exist until you're ready to mount the
45 disk drive? Perhaps you would want to run some command line
46 identifying the disk by its host and port or something, so that it can
47 create /dev/sdb, and then you can mount it normally from there?
49 Should ALSA devices not exist until the first time you're ready to
50 play a sound? Then you run something as root to configure them?
52 --
53 Rich