나는 다음 규칙에 따라 CD-ROM 이벤트를 캡처합니다.
ACTION!="remove", SUBSYSTEM=="block", KERNEL=="sr[0-9]*", ENV{DEVTYPE}=="disk", RUN+="/bin/bash -c '/bin/echo cdrom1-%k-%E{ACTION}-%E{ID_CDROM_MEDIA_BD}>> /tmp/cdrom.event'"
CD-ROM 장착/제거시 1회 동작으로 3번 연속으로 동일한 이벤트가 발생합니다. 삽입된 드라이브와 꺼낸 드라이브를 구별하기 위해 규칙을 어떻게 수정합니까?
CD-ROM 이벤트 자체는 다음과 같습니다.
UDEV [1499340281.456105] change
/devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0 (scsi)
UDEV_LOG=3
ACTION=change
DEVPATH=/devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0
SUBSYSTEM=scsi
SDEV_MEDIA_CHANGE=1
DEVTYPE=scsi_device
DRIVER=sr
MODALIAS=scsi:t-0x05
SEQNUM=2243
UDEV [1499340281.587415] change /devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0/block/sr0 (block)
UDEV_LOG=3
ACTION=change
DEVPATH=/devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0/block/sr0
SUBSYSTEM=block
DEVNAME=/dev/sr0
DEVTYPE=disk
SEQNUM=2244
MPATH_SBIN_PATH=/sbin
ID_CDROM=1
ID_CDROM_CD_R=1
ID_CDROM_CD_RW=1
ID_CDROM_DVD=1
ID_CDROM_DVD_R=1
ID_CDROM_DVD_RAM=1
ID_SCSI=1
ID_VENDOR=hp
ID_VENDOR_ENC=hp\x20\x20\x20\x20\x20\x20
ID_MODEL=DVD-RAM_GHC0N
ID_MODEL_ENC=DVD-RAM\x20GHC0N\x20\x20\x20
ID_REVISION=RL05
ID_TYPE=cd
ID_BUS=scsi
ID_PATH=pci-0000:00:1f.2-scsi-2:0:0:0
LVM_SBIN_PATH=/sbin
ACL_MANAGE=1
GENERATED=1
UDISKS_PRESENTATION_NOPOLICY=0
MAJOR=11
MINOR=0
DEVLINKS=/dev/block/11:0 /dev/scd0 /dev/disk/by-path/pci-0000:00:1f.2-scsi- 2:0:0:0 /dev/cdrom /dev/cdrw /dev/dvd /dev/dvdrw