在我的系统上,如果我在从相机播放时断开 USB 相机的连接,则并非所有删除事件都会发生。当关联的设备名称 (/dev/input/event*) 被另一个设备重复使用时,这会导致问题。
最终,如果你在玩的时候拔掉相机,然后插上键盘,键盘就不起作用了。我对大多数可以避免此问题的解决方案感到满意。我真的不明白为什么 hald 不发出删除事件,因为它正在清理 /dev 条目。
系统:CentOS 6,最新内核和hal包:
kernel-2.6.32-696.16.1.el6.i686
hal-0.5.14-14.el6.i686
相机是 e-con See3CAM_11CUG 或 Philips SPC 900NC。两者都是 UVC USB 相机,其 e-con 比飞利浦新得多。
连接 e-con 并在不使用时移除时的 lshal -m 输出:
11:42:02.190: usb_device_2560_c112_22268801 added
11:42:02.192: usb_device_2560_c112_22268801_if2 added
11:42:02.292: usb_device_2560_c112_22268801_if0 added
11:42:02.296: usb_device_2560_c112_22268801_if1 added
11:42:02.324: usb_device_2560_c112_22268801_if0_video4linux added
11:42:02.331: usb_device_2560_c112_22268801_if0_logicaldev_input added
11:44:48.563: usb_device_2560_c112_22268801_if0_video4linux removed
11:44:48.567: usb_device_2560_c112_22268801_if0_logicaldev_input removed
11:44:48.575: usb_device_2560_c112_22268801_if1 removed
11:44:48.576: usb_device_2560_c112_22268801_if0 removed
11:44:48.577: usb_device_2560_c112_22268801_if2 removed
11:44:48.577: usb_device_2560_c112_22268801 removed
这是通过 mplayer 播放时 e-con 断开连接时的 lshal -m 输出 ( mplayer tv:// -tv driver=v4l2:noaudio:device=/dev/video0
)
11:47:34.230: usb_device_2560_c112_22268801 added
11:47:34.237: usb_device_2560_c112_22268801_if0 added
11:47:34.240: usb_device_2560_c112_22268801_if1 added
11:47:34.241: usb_device_2560_c112_22268801_if2 added
11:47:34.245: usb_device_2560_c112_22268801_if0_video4linux added
11:47:34.261: usb_device_2560_c112_22268801_if0_logicaldev_input added
11:48:00.417: usb_device_2560_c112_22268801_if1 removed
11:48:00.419: usb_device_2560_c112_22268801_if0_video4linux removed
11:48:00.419: usb_device_2560_c112_22268801_if0 removed
11:48:00.420: usb_device_2560_c112_22268801_if2 removed
11:48:00.420: usb_device_2560_c112_22268801 removed
是if0_logicaldev_input
没有获得删除事件的那个。 Xorg 认为这是一个键盘,当它没有被删除时,它决定进一步添加该 /dev/input/event?名称无效并忽略它们。
lsof 表明 hald-addon-input 和 Xorg 都仍然打开旧的 /dev/input/event*,即使它已被删除:
lsof | grep deleted
hald-addo 2484 root 12r CHR 13,77 0t0 24238 /dev/input/event13 (deleted)
Xorg 2678 root 35u CHR 13,77 0t0 23881 /dev/input/event13 (deleted)
我在 /etc/sysconfig/haldaemon 中添加了“--verbose=yes --use-syslog”,这是在玩游戏时进行删除时来自 /var/log/messages 的片段:
Feb 12 08:47:58 Kohne-C22 kernel: usb 4-1: USB disconnect, device number 4
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.723 [I] osspec.c:256: SEQNUM=2497, ACTION=remove, SUBSYSTEM=usb, DEVPATH=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.1, DEVNAME=, IFINDEX=0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.723 [D] hotplug.c:478: checking REMOVE event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.1
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.723 [D] hotplug.c:397: event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.1: skip ourselves and all later events
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.723 [I] hotplug.c:121: /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.1 is a device (store)
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.723 [I] device.c:5083: remove_dev: subsys=usb sysfs_path=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.1
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.723 [I] device.c:4864: Remove callouts completed udi=/org/freedesktop/Hal/devices/usb_device_2560_c112_22268801_if1
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.723 [D] device_store.c:528: removing 0x8dd2380 from (linux.sysfs_path,/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.1)
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.723 [I] hald.c:143: Removed device from GDL; udi=/org/freedesktop/Hal/devices/usb_device_2560_c112_22268801_if1
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:500: events queued = 0, events in progress = 0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [I] osspec.c:256: SEQNUM=2499, ACTION=remove, SUBSYSTEM=hidraw, DEVPATH=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2/0003:2560:C112.0006/hidraw/hidraw0, DEVNAME=/dev/hidraw0, IFINDEX=0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:478: checking REMOVE event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2/0003:2560:C112.0006/hidraw/hidraw0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:397: event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2/0003:2560:C112.0006/hidraw/hidraw0: skip ourselves and all later events
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [I] device.c:5083: remove_dev: subsys=hidraw sysfs_path=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2/0003:2560:C112.0006/hidraw/hidraw0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [W] device.c:5087: Error removing device
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:500: events queued = 0, events in progress = 0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [I] osspec.c:256: SEQNUM=2498, ACTION=remove, SUBSYSTEM=usb, DEVPATH=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2/usb/hiddev1, DEVNAME=/dev/usb/hiddev1, IFINDEX=0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:478: checking REMOVE event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2/usb/hiddev1
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:397: event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2/usb/hiddev1: skip ourselves and all later events
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [I] device.c:5083: remove_dev: subsys=usb sysfs_path=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2/usb/hiddev1
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [W] device.c:5087: Error removing device
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:500: events queued = 0, events in progress = 0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [I] osspec.c:256: SEQNUM=2500, ACTION=remove, SUBSYSTEM=hid, DEVPATH=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2/0003:2560:C112.0006, DEVNAME=, IFINDEX=0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:478: checking REMOVE event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2/0003:2560:C112.0006
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:397: event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2/0003:2560:C112.0006: skip ourselves and all later events
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [I] device.c:5083: remove_dev: subsys=hid sysfs_path=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2/0003:2560:C112.0006
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [W] device.c:5087: Error removing device
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:500: events queued = 0, events in progress = 0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [I] osspec.c:256: SEQNUM=2495, ACTION=remove, SUBSYSTEM=video4linux, DEVPATH=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0/video4linux/video0, DEVNAME=/dev/video0, IFINDEX=0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:478: checking REMOVE event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0/video4linux/video0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.724 [D] hotplug.c:397: event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0/video4linux/video0: skip ourselves and all later events
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] hotplug.c:121: /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0/video4linux/video0 is a device (store)
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] device.c:5083: remove_dev: subsys=video4linux sysfs_path=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0/video4linux/video0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] device.c:4864: Remove callouts completed udi=/org/freedesktop/Hal/devices/usb_device_2560_c112_22268801_if0_video4linux
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] device_store.c:528: removing 0x8db1820 from (linux.sysfs_path,/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0/video4linux/video0)
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] hald.c:143: Removed device from GDL; udi=/org/freedesktop/Hal/devices/usb_device_2560_c112_22268801_if0_video4linux
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] hotplug.c:500: events queued = 0, events in progress = 0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] osspec.c:256: SEQNUM=2501, ACTION=remove, SUBSYSTEM=usb, DEVPATH=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2, DEVNAME=, IFINDEX=0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] hotplug.c:478: checking REMOVE event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] hotplug.c:397: event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2: skip ourselves and all later events
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] hotplug.c:121: /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2 is a device (store)
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] device.c:5083: remove_dev: subsys=usb sysfs_path=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] device.c:4864: Remove callouts completed udi=/org/freedesktop/Hal/devices/usb_device_2560_c112_22268801_if2
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] device_store.c:528: removing 0x8dbf560 from (linux.sysfs_path,/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.2)
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] hald.c:143: Removed device from GDL; udi=/org/freedesktop/Hal/devices/usb_device_2560_c112_22268801_if2
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] hotplug.c:500: events queued = 0, events in progress = 0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] osspec.c:256: SEQNUM=2496, ACTION=remove, SUBSYSTEM=usb, DEVPATH=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0, DEVNAME=, IFINDEX=0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] hotplug.c:478: checking REMOVE event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] hotplug.c:397: event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0: skip ourselves and all later events
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] hotplug.c:121: /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0 is a device (store)
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] device.c:5083: remove_dev: subsys=usb sysfs_path=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] device.c:4864: Remove callouts completed udi=/org/freedesktop/Hal/devices/usb_device_2560_c112_22268801_if0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] device_store.c:528: removing 0x8d7edd0 from (linux.sysfs_path,/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1/4-1:1.0)
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] hald.c:143: Removed device from GDL; udi=/org/freedesktop/Hal/devices/usb_device_2560_c112_22268801_if0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] hotplug.c:500: events queued = 0, events in progress = 0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] osspec.c:256: SEQNUM=2502, ACTION=remove, SUBSYSTEM=usb, DEVPATH=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1, DEVNAME=/dev/bus/usb/004/004, IFINDEX=0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] hotplug.c:478: checking REMOVE event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [D] hotplug.c:397: event /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1: skip ourselves and all later events
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] hotplug.c:121: /sys/devices/pci0000:00/0000:00:14.0/usb4/4-1 is a device (store)
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.725 [I] device.c:5083: remove_dev: subsys=usb sysfs_path=/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.726 [I] device.c:4864: Remove callouts completed udi=/org/freedesktop/Hal/devices/usb_device_2560_c112_22268801
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.726 [D] device_store.c:528: removing 0x8d905b0 from (linux.sysfs_path,/sys/devices/pci0000:00/0000:00:14.0/usb4/4-1)
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.726 [I] hald.c:143: Removed device from GDL; udi=/org/freedesktop/Hal/devices/usb_device_2560_c112_22268801
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.726 [D] hotplug.c:500: events queued = 0, events in progress = 0
Feb 12 08:47:58 Kohne-C22 hald[2418]: 08:47:58.726 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
Feb 12 08:47:59 Kohne-C22 put: Listening on /dev/input/event12 /dev/input/event1 /dev/input/event3 /dev/input/event0 /dev/input/event4: [2476]: 08:47:59.665 [D] addon-input.c:319: Input device '/org/freedesktop/Hal/devices/usb_device_2560_c112_22268801_if0_logicaldev_input' destroyed, free data.
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.666 [I] osspec.c:256: SEQNUM=2503, ACTION=remove, SUBSYSTEM=input, DEVPATH=/sys/4-1:1.0/input/input15/event4, DEVNAME=/dev/input/event4, IFINDEX=0
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.666 [D] hotplug.c:478: checking REMOVE event /sys/4-1:1.0/input/input15/event4
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.666 [D] hotplug.c:397: event /sys/4-1:1.0/input/input15/event4: skip ourselves and all later events
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.666 [I] device.c:5083: remove_dev: subsys=input sysfs_path=/sys/4-1:1.0/input/input15/event4
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.666 [W] device.c:5087: Error removing device
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.666 [D] hotplug.c:500: events queued = 0, events in progress = 0
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.666 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.674 [I] osspec.c:256: SEQNUM=2504, ACTION=remove, SUBSYSTEM=input, DEVPATH=/sys/4-1:1.0/input/input15, DEVNAME=, IFINDEX=0
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.674 [D] hotplug.c:478: checking REMOVE event /sys/4-1:1.0/input/input15
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.674 [D] hotplug.c:397: event /sys/4-1:1.0/input/input15: skip ourselves and all later events
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.674 [I] device.c:5083: remove_dev: subsys=input sysfs_path=/sys/4-1:1.0/input/input15
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.674 [W] device.c:5087: Error removing device
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.674 [D] hotplug.c:500: events queued = 0, events in progress = 0
Feb 12 08:47:59 Kohne-C22 hald[2418]: 08:47:59.674 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress