Autor: Didier Kryn Data: Dla: dng Temat: Re: [DNG] What is an init system?
Le 28/05/2024 à 20:51, karl@??? a écrit : >> Well, for a server, you can go with static /dev, but for a desktop
>> or laptop where you want to plug/uplug external devices, you definitely
>> need some brand of a hotplugger, because, yes, the kernel does create
>> the device files, but it gives them owners/groups/permisssions which
>> make them often unusable. Also the hotplugger creates/manages the
>> /dev/disk tree which I find pretty usefull. If I had time to devote to
>> it I would give a serious try to mdev. The thing is that it does not
>> come ready-made; you need to understand it and build your own
>> configuration. I like its simplicity though.
> A static /dev (in my view) is where device files maintained on disk,
> not by the kernel (with CONFIG_DEVTMPFS).
>
> All that above is about usb.
>
> One problem with usb is that the relation between the hw and the module
> to use is hidden --- so it is easy use some form of automounter but
> hard to do it manually.
>
> By attaching a usb device you see something like this in the log:
> May 28 10:53:30 angelit kern.info kernel: [1420143.035368] usb 2-3: new high-speed USB device number 2 using ehci-pci
>
> From this you can get:
> # cat /sys/bus/usb/devices/2-3/manufacturer
> Kingston
> # cat /sys/bus/usb/devices/2-3/product
> DataTraveler 3.0
>
> or if you like,
> # cat /sys/bus/usb/devices/2-3/uevent
> MAJOR=189
> MINOR=129
> DEVNAME=bus/usb/002/002
> DEVTYPE=usb_device
> DRIVER=usb
> PRODUCT=951/1666/100
> TYPE=0/0/0
> BUSNUM=002
> DEVNUM=002
>
> its device file is simply the DEVNAME value above with/dev/ prepended
> # ls -l /dev/bus/usb/002/002
> crw-rw-rw- 1 root root 189, 129 May 15 2019 /dev/bus/usb/002/002
>
> But how do I figure out what module to use (yes, I know it is
> usb-storage) ?
A static /dev is like in the old days before the advent of
hotpluggers and before the kernel DEVTMPFS option. This option was
created to create/delete device files /in place ot the hotplugger,/
because kernel people found udev buggy. But a hotplugger is still needed
for proper assignment of owner/group/permission.
If you have neither DEVTMPFS nor hotplugger, then your device files
are either permanent in a directory of your disk or created by a custom
init script, practically before any other action. In the last case, it
is much like if you write your own hotplugger by hand.
There is a chain of drivers for practically everything, not only
for USB, but also for disks and network. I have the impression that it
becomes everyday more complicated. Either you keep in sync with it and
maintain your own logic, or you give up, like most people and rely on
some existing hotplugger.
I would personnally recommend to rely on the kernel to
create/delete device files, since this is the most difficult. Then, if
you don't want to use any existing hotplugger, write, in some sense,
your own, not as general as the existing ones, but just fitting your
needs. mdev seems to me the simplest way: it is just made for customization.