PS / 2とゲームポートのudevルールはattrで一致せず、envでのみ一致します。

PS / 2とゲームポートのudevルールはattrで一致せず、envでのみ一致します。

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)によると、属性の一致は2つの異なる形式で提供されています。

   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これは親ノードの属性なので、2番目の形式、つまり

ATTRS{name}=="AT Translated Set 2 keyboard"

変える

ATTR{name}=="AT Translated Set 2 keyboard" 

おすすめ記事