最終更新:2022-03-03 (木) 18:26:51 (784d)
udevadm info
Top / udevadm info
Query sysfs or the udev database.
例
udevadm info -q all -n /dev/input/event0
パス
- --name=, --path=, or absolute path in /dev/ or /sys expected.
- Linux/sysがルートになるっぽい
デバイスパスから元のデバイスを取得
- udevadm info --query=path --name=/dev/input/event16
- /devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.2/0003:XXXX:YYYY.0009/input/input24/event16
- Linux/dev/sd
- Linux/dev/input
Linux/USBドライブ
- 接続の確認
udevadm info --query=all --name=sdb | grep ID_BUS
- https://unix.stackexchange.com/questions/40143/how-to-know-if-dev-sdx-is-a-connected-usb-or-hdd
help
udevadm info [OPTIONS] [DEVPATH|FILE] Query sysfs or the udev database. -h --help Print this message --version Print version of the program -q --query=TYPE Query device information: name Name of device node symlink Pointing to node path sysfs device path property The device properties all All values -p --path=SYSPATH sysfs device path used for query or attribute walk -n --name=NAME Node or symlink name used for query or attribute walk -r --root Prepend dev directory to path names -a --attribute-walk Print all key matches walking along the chain of parent devices -d --device-id-of-file=FILE Print major:minor of device containing this file -x --export Export key/value pairs -P --export-prefix Export the key name with a prefix -e --export-db Export the content of the udev database -c --cleanup-db Clean up the udev database
例
$ udevadm info -q all -n /dev/input/event0 P: /devices/LNXSYSTM:00/LNXPWRBN:00/input/input0/event0 N: input/event0 E: DEVNAME=/dev/input/event0 E: DEVPATH=/devices/LNXSYSTM:00/LNXPWRBN:00/input/input0/event0 E: ID_INPUT=1 E: ID_INPUT_KEY=1 E: ID_PATH=acpi-LNXPWRBN:00 E: ID_PATH_TAG=acpi-LNXPWRBN_00 E: MAJOR=13 E: MINOR=64 E: SUBSYSTEM=input E: TAGS=:power-switch: E: USEC_INITIALIZED=8821 E: XKBLAYOUT=jp E: XKBMODEL=pc105
# udevadm info -a -n /dev/input/event5 Udevadm info starts with the device specified by the devpath and then walks up the chain of parent devices. It prints for every device found, all possible attributes in the udev rules key format. A rule to match, can be composed by the attributes of the device and the attributes from one single parent device. looking at device '/devices/pci0000:00/0000:00:04.0/input/input6/event5': KERNEL=="event5" SUBSYSTEM=="input" DRIVER=="" looking at parent device '/devices/pci0000:00/0000:00:04.0/input/input6': KERNELS=="input6" SUBSYSTEMS=="input" DRIVERS=="" ATTRS{name}=="VirtualBox mouse integration" ATTRS{phys}=="" ATTRS{uniq}=="" ATTRS{properties}=="0" looking at parent device '/devices/pci0000:00/0000:00:04.0': KERNELS=="0000:00:04.0" SUBSYSTEMS=="pci" DRIVERS=="vboxguest" ATTRS{irq}=="20" ATTRS{subsystem_vendor}=="0x0000" ATTRS{broken_parity_status}=="0" ATTRS{class}=="0x088000" ATTRS{consistent_dma_mask_bits}=="32" ATTRS{dma_mask_bits}=="32" ATTRS{local_cpus}=="00000000,00000000,00000000,00000000,00000000,00000000,00000000,00000001" ATTRS{device}=="0xcafe" ATTRS{enable}=="1" ATTRS{msi_bus}=="" ATTRS{local_cpulist}=="0" ATTRS{vendor}=="0x80ee" ATTRS{subsystem_device}=="0x0000" ATTRS{numa_node}=="-1" ATTRS{d3cold_allowed}=="0" looking at parent device '/devices/pci0000:00': KERNELS=="pci0000:00" SUBSYSTEMS=="" DRIVERS==""
man
udevadm info options Queries the udev database for device information stored in the udev database. It can also query the properties of a device from its sysfs representation to help creating udev rules that match this device. --query=type Query the database for specified type of device data. It needs the --path or --name to identify the specified device. Valid queries are: name, symlink, path, property, all. --path=devpath The devpath of the device to query. --name=file The name of the device node or a symlink to query --root The udev root directory: /dev. If used in conjunction with a name or symlink query, the query returns the absolute path including the root directory. --run The udev runtime directory: /run/udev. --attribute-walk Print all sysfs properties of the specified device that can be used in udev rules to match the specified device. It prints all devices along the chain, up to the root of sysfs that can be used in udev rules. --export Print output as key/value pairs. Values are enclosed in single quotes. --export-prefix=name Add a prefix to the key name of exported values. --device-id-of-file=file Print major/minor numbers of the underlying device, where the file lives on. --export-db Export the content of the udev database. --cleanup-db Cleanup the udev database. --version Print version. --help Print help text.