Is there any documentation for udev builtins?
If you just run udevadm test-builtin
without arguments it'll list the builtin commands along with a short description for each of them:
udevadm test-builtin --help
calling: test-builtin udevadm test-builtin [OPTIONS] COMMAND DEVPATH Test a built-in command. -h --help Print this message -V --version Print version of the program Commands: blkid Filesystem and partition probing btrfs btrfs volume management hwdb Hardware database input_id Input device properties keyboard Keyboard scan code to key mapping kmod Kernel module loader net_id Network device properties net_setup_link Configure network link path_id Compose persistent device path usb_id USB device properties uaccess Manage device node user ACL
Unfortunately, as you've noticed, builtins usage is only explained briefly in the manual.
A practical example can be found in the file 50-udev-default.rules
available on your system (under /lib/udev/rules.d/
) which contains stuff like:
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", IMPORT{builtin}="usb_id", IMPORT{builtin}="hwdb --subsystem=usb"
SUBSYSTEM=="input", ENV{ID_INPUT}=="", IMPORT{builtin}="input_id"
ENV{MODALIAS}!="", IMPORT{builtin}="hwdb --subsystem=$env{SUBSYSTEM}"
Unfortunately, this information is missing on manpages and even knowing how to read them(see below) you will find trouble on trying to find that info.
However, the beauty of the opensource relies on having the power to read the sources. If you take a look at the udev-builtin.c
source file inside systemd
/udev
repository and have basic C language knowledge, you will find the following snippet of code: A structure that maps all existing builtin types.
static const struct udev_builtin *builtins[_UDEV_BUILTIN_MAX] = {
#if HAVE_BLKID
[UDEV_BUILTIN_BLKID] = &udev_builtin_blkid,
#endif
[UDEV_BUILTIN_BTRFS] = &udev_builtin_btrfs,
[UDEV_BUILTIN_HWDB] = &udev_builtin_hwdb,
[UDEV_BUILTIN_INPUT_ID] = &udev_builtin_input_id,
[UDEV_BUILTIN_KEYBOARD] = &udev_builtin_keyboard,
#if HAVE_KMOD
[UDEV_BUILTIN_KMOD] = &udev_builtin_kmod,
#endif
[UDEV_BUILTIN_NET_ID] = &udev_builtin_net_id,
[UDEV_BUILTIN_NET_LINK] = &udev_builtin_net_setup_link,
[UDEV_BUILTIN_PATH_ID] = &udev_builtin_path_id,
[UDEV_BUILTIN_USB_ID] = &udev_builtin_usb_id,
#if HAVE_ACL
[UDEV_BUILTIN_UACCESS] = &udev_builtin_uaccess,
#endif
};
This struct
holds all built-in types, and they map source files depending on what type it is. Example:
udev-builtin-kmod.c
- A Kernel Module loader.udev-builtin-keyboard.c
- A keyboard handler.udev-builtin-usb_id.c
- A USB handler that will set the usb type and initialize the device.
Related:
- How do I use man pages to learn how to use commands?