On Fri, Jan 21, 2022 at 4:23 PM Grant Edwards <[email protected]> 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

