
PS/2 또는 게임 포트 연결 장치에 대한 규칙을 작성할 때 udev는 속성과 일치하지 않지만 환경 값과 일치합니다. 이 문제의 원인은 아래 출력에서 확인할 수 있습니다. 주어진 환경 값은 다소 불특정하고 규칙에서 어떤 장치가 참조되는지 명확하지 않은 반면, 속성 값은 실제 장치 이름을 통해 매우 명확합니다. 특히 내 Gravis GamePad는 매우 난해한 ENV 값을 가지고 있는데 ATTR 이름이 "Gravis GamePad Pro"입니다.
이것은 작동합니다:
ENV{XKBMODEL}=="pc105", RUN+="keymap $name microsoft-internet-keyboard"
이것은 실제로아니요일하다:
ATTR{name}=="AT Translated Set 2 keyboard", RUN+="keymap $name microsoft-internet-keyboard"
다음을 실행하여 환경 값을 얻습니다.
udevadm info -q all -n /dev/input/event0
P: /devices/pci0000:00/0000:00:1e.0/0000:02:04.0/gameport0/input/input5/js0
N: input/js0
S: input/by-path/pci-0000:02:04.0-joystick
E: DEVLINKS=/dev/input/by-path/pci-0000:02:04.0-joystick
E: DEVNAME=/dev/input/js0
E: DEVPATH=/devices/pci0000:00/0000:00:1e.0/0000:02:04.0/gameport0/input/input5/js0
E: ID_INPUT=1
E: ID_INPUT_JOYSTICK=1
E: ID_PATH=pci-0000:02:04.0
E: ID_PATH_TAG=pci-0000_02_04_0
E: ID_SERIAL=noserial
E: MAJOR=13
E: MINOR=0
E: SUBSYSTEM=input
E: UDEV_LOG=3
E: USEC_INITIALIZED=3244030793
런타임 시 속성 값은 다음과 같습니다.
udevadm info -n /dev/input/event0 --attribute-walk
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/platform/i8042/serio0/input/input0/event0':
KERNEL=="event0"
SUBSYSTEM=="input"
DRIVER==""
looking at parent device '/devices/platform/i8042/serio0/input/input0':
KERNELS=="input0"
SUBSYSTEMS=="input"
DRIVERS==""
ATTRS{name}=="AT Translated Set 2 keyboard"
ATTRS{phys}=="isa0060/serio0/input0"
ATTRS{uniq}==""
ATTRS{properties}=="0"
looking at parent device '/devices/platform/i8042/serio0':
KERNELS=="serio0"
SUBSYSTEMS=="serio"
DRIVERS=="atkbd"
ATTRS{description}=="i8042 KBD port"
ATTRS{bind_mode}=="auto"
ATTRS{extra}=="0"
ATTRS{force_release}=="369-370"
ATTRS{scroll}=="0"
ATTRS{set}=="2"
ATTRS{softrepeat}=="0"
ATTRS{softraw}=="1"
ATTRS{err_count}=="0"
looking at parent device '/devices/platform/i8042':
KERNELS=="i8042"
SUBSYSTEMS=="platform"
DRIVERS=="i8042"
looking at parent device '/devices/platform':
KERNELS=="platform"
SUBSYSTEMS==""
DRIVERS==""
규칙을 만들 때 주로 다음 조언을 따랐습니다.이 웹사이트이는 오래된 것일 수 있습니다. 특히 제가 우려하는 부분은 다음과 같습니다.
...관련 장치와 단일 상위 장치의 속성을 결합하는 것은 합법적입니다. 여러 상위 장치의 속성을 혼합하고 일치시킬 수는 없습니다. 규칙이 작동하지 않습니다.
답변1
udev 맨페이지( man 7 udev
)에 따르면 속성 일치는 두 가지 다른 형식으로 제공됩니다.
ATTR{filename}
Match sysfs attribute values of the event device. Trailing
whitespace in the attribute values is ignored unless the specified
match value itself contains trailing whitespace.
그리고
ATTRS{filename}
Search the devpath upwards for a device with matching sysfs
attribute values. If multiple ATTRS matches are specified, all of
them must match on the same device. Trailing whitespace in the
attribute values is ignored unless the specified match value itself
contains trailing whitespace.
name
이는 상위 노드의 속성이므로 두 번째 형식, 즉
ATTRS{name}=="AT Translated Set 2 keyboard"
바꾸다
ATTR{name}=="AT Translated Set 2 keyboard"