From mboxrd@z Thu Jan 1 00:00:00 1970 From: Martin Pitt Date: Tue, 21 Apr 2009 07:25:09 +0000 Subject: CD-ROM tray closes automatically after eject due to random Message-Id: <20090421072509.GF3973@piware.de> MIME-Version: 1 Content-Type: multipart/mixed; boundary="HG+GLK89HZ1zG0kk" List-Id: To: linux-hotplug@vger.kernel.org --HG+GLK89HZ1zG0kk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello udev developers, https://launchpad.net/bugs/356631 reported that many people still have the problem that after ejecting a CD, the CD-ROM tray automatically closes again, causing the killing of fingers and CDs (or small pets :-) ) This problem came up a while ago already, and was solved with introducing this into /lib/udev/rules.d/60-persistent-storage.rules: # probe filesystem metadata of optical drives which have a media inserted KERNEL=3D=3D"sr*", ENV{ID_CDROM_MEDIA_TRACK_COUNT}=3D=3D"?*", IMPORT{prog= ram}=3D"vol_id --export --skip-raid --offset=3D$env{ID_CDROM_MEDIA_SESSION_= LAST_OFFSET} $tempnode" =20 However, this rule (and the corresponding code in cdrom_id [1]) relies on the track/session counts being zero if there is no CD in the drive. However, at least with kernel 2.6.28.8 the affected people get something like ID_CDROM_MEDIA_STATE=3Dblank ID_CDROM_MEDIA_SESSION_NEXT=3D2894 ID_CDROM_MEDIA_SESSION_COUNT=3D19194 ID_CDROM_MEDIA_TRACK_COUNT=3D47323 In other words, if ID_CDROM_MEDIA_STATE=3Dblank, the session/track counts are not reliable. Arguably this could/should be fixed in the kernel, to fix these values to 0 if there is no CD in the drive, or it is blank. However, I wondered if the udev rules should be more robust in that regard, and not even ask for the number of tracks if there is no/empty CD. Affected people verified that adding this rule before the one from above makes things work: KERNEL=3D=3D"sr*", ENV{ID_CDROM_MEDIA_STATE}=3D=3D"blank", GOTO=3D"persis= tent_storage_end" Thanks, Martin [1] if (cd_media_track_count > 0) printf("ID_CDROM_MEDIA_TRACK_COUNT=3D%d\n", cd_media_track_= count); --=20 Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) --HG+GLK89HZ1zG0kk Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkntdNUACgkQDecnbV4Fd/J7IQCg5GuHKGKCVOJO7HRQ8Yj7KggV frkAoKKQ5rfT7MGyf7NrmNX3C8Awi1al =poju -----END PGP SIGNATURE----- --HG+GLK89HZ1zG0kk--