• [gentoo-user] Why is "mtp-probe" running when I plug in a USB device?

    From Grant Edwards@21:1/5 to All on Fri Jan 21 22:30:02 2022
    I've noticed that whenever I plug in any sort of USB device,
    "mtp-probe" runs and logs the fact that the newly attached thing "was
    not an MTP device".

    This appears to be triggered by a rule in

    /lib/udev/rules.d/69-libmtp.rules

    which is owned by media-libs/libmtp

    Why does that library think it should be probing every USB device I
    plug in? Is that automatic probing required for libmtp and mtpfs to
    work?

    I do _not_ want anything to happen "automagically" when I plug in a
    USB mtp device. I know if a device is an MTP device, and if I want it
    mounted, I'll mount it manually.

    --
    Grant

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich Freeman@21:1/5 to grant.b.edwards@gmail.com on Fri Jan 21 23:10:02 2022
    On Fri, Jan 21, 2022 at 4:23 PM Grant Edwards <grant.b.edwards@gmail.com> wrote:

    Why does that library think it should be probing every USB device I
    plug in? Is that automatic probing required for libmtp and mtpfs to
    work?

    I'm guessing that MTP cannot be detected by just looking at a device
    ID/etc and requires some kind of interrogation. It looks like libmtp
    is designed to create a device node /dev/libmtp-1-4 which I'm guessing
    it uses for later operations like mounting/etc. Doing this at time of insertion makes the most sense, since that is how most device nodes
    work.

    Note that anytime you plug in a USB device, or just about any other
    device, code tends to run. When a sound device raises an IRQ to call
    attention to its buffer being exhausted, code tends to run. When a
    hard drive is asked to read a block off the disk and has it available
    to read, it likely raises an interrupt, and code runs. Much of this
    code is in the kernel, but there is a general trend towards moving
    more of this stuff into userspace, so now you notice it more, vs it
    just showing up as a system % cpu figure in top with little
    transparency into what is going on if you aren't actually doing traces
    of some kind. With tools like udev more of this is configurable as
    you've noticed.

    I wouldn't view any of this as a bad thing. You're more aware of it
    now, and you have more control over it now, and if the code does the
    run thing it is more likely to be running as nobody instead of as the
    kernel.

    Why should it be strange that when you plug in a device, the operating
    system tries to figure out what sort of device it is, and set it up so
    that you can access it from userspace?

    I do _not_ want anything to happen "automagically" when I plug in a
    USB mtp device. I know if a device is an MTP device, and if I want it mounted, I'll mount it manually.

    Well, you can of course disable the udev rule. I'm not sure if there
    are issues with running device probing on demand. Obviously the whole
    udev framework is designed to dynamically create and destroy device
    nodes as devices are plugged in or removed.

    Would you want /dev/sdb to not exist until you're ready to mount the
    disk drive? Perhaps you would want to run some command line
    identifying the disk by its host and port or something, so that it can
    create /dev/sdb, and then you can mount it normally from there?

    Should ALSA devices not exist until the first time you're ready to
    play a sound? Then you run something as root to configure them?

    --
    Rich

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Grant Edwards@21:1/5 to Grant Edwards on Fri Jan 21 22:40:01 2022
    On 2022-01-21, Grant Edwards <grant.b.edwards@gmail.com> wrote:
    [...]

    This appears to be triggered by a rule in

    /lib/udev/rules.d/69-libmtp.rules

    which is owned by media-libs/libmtp

    Why does that library think it should be probing every USB device I
    [...]

    Oh, and tell those damn kids to GET OFF MY LAWN!

    --
    Grant

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)