All of lore.kernel.org
 help / color / mirror / Atom feed
* CD-ROM tray closes automatically after eject due to random
@ 2009-04-21  7:25 Martin Pitt
  2009-04-21  8:52 ` Kay Sievers
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Martin Pitt @ 2009-04-21  7:25 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 1821 bytes --]

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=="sr*", ENV{ID_CDROM_MEDIA_TRACK_COUNT}=="?*", IMPORT{program}="vol_id --export --skip-raid --offset=$env{ID_CDROM_MEDIA_SESSION_LAST_OFFSET} $tempnode"
  
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=blank
  ID_CDROM_MEDIA_SESSION_NEXT=2894
  ID_CDROM_MEDIA_SESSION_COUNT=19194
  ID_CDROM_MEDIA_TRACK_COUNT=47323

In other words, if ID_CDROM_MEDIA_STATE=blank, 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=="sr*", ENV{ID_CDROM_MEDIA_STATE}=="blank", GOTO="persistent_storage_end"

Thanks,

Martin

[1]         if (cd_media_track_count > 0)
                printf("ID_CDROM_MEDIA_TRACK_COUNT=%d\n", cd_media_track_count);
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CD-ROM tray closes automatically after eject due to random
  2009-04-21  7:25 CD-ROM tray closes automatically after eject due to random Martin Pitt
@ 2009-04-21  8:52 ` Kay Sievers
  2009-04-21  9:14 ` Martin Pitt
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kay Sievers @ 2009-04-21  8:52 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Apr 21, 2009 at 09:25, Martin Pitt <martin.pitt@ubuntu.com> wrote:
> 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=blank
>  ID_CDROM_MEDIA_SESSION_NEXT(94
>  ID_CDROM_MEDIA_SESSION_COUNT\x19194
>  ID_CDROM_MEDIA_TRACK_COUNTG323
>
> In other words, if ID_CDROM_MEDIA_STATE=blank, the session/track
> counts are not reliable.

Nice hardware! :)

> 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="sr*", ENV{ID_CDROM_MEDIA_STATE}="blank", GOTO="persistent_storage_end"

The problem is that there are other devices which report a blank media
for non-blank ones, so this rule would break these.

We changed it yesterday to use an ID_CDROM_MEDIA key:
  http://git.kernel.org/?p=linux/hotplug/udev.git;a=commit;hù07449eee3f58fafafee0658e80578b1dbb2722

Would be good to know, if that works in the case you see the wrong values.

Thanks,
Kay

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CD-ROM tray closes automatically after eject due to random
  2009-04-21  7:25 CD-ROM tray closes automatically after eject due to random Martin Pitt
  2009-04-21  8:52 ` Kay Sievers
@ 2009-04-21  9:14 ` Martin Pitt
  2009-04-22 13:34 ` Martin Pitt
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Martin Pitt @ 2009-04-21  9:14 UTC (permalink / raw)
  To: linux-hotplug

Hallo Kay,

Kay Sievers [2009-04-21 10:52 +0200]:
> We changed it yesterday to use an ID_CDROM_MEDIA key:
>   http://git.kernel.org/?p=linux/hotplug/udev.git;a=commit;hù07449eee3f58fafafee0658e80578b1dbb2722
> 
> Would be good to know, if that works in the case you see the wrong values.

Thanks! I'll build a test package for these folks to try, will report
back.

Martin
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CD-ROM tray closes automatically after eject due to random
  2009-04-21  7:25 CD-ROM tray closes automatically after eject due to random Martin Pitt
  2009-04-21  8:52 ` Kay Sievers
  2009-04-21  9:14 ` Martin Pitt
@ 2009-04-22 13:34 ` Martin Pitt
  2009-04-22 22:16 ` Kay Sievers
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Martin Pitt @ 2009-04-22 13:34 UTC (permalink / raw)
  To: linux-hotplug

Hello Kay,

Kay Sievers [2009-04-21 10:52 +0200]:
> Nice hardware! :)

If only it was real!

> The problem is that there are other devices which report a blank media
> for non-blank ones, so this rule would break these.

Ah, understood. Yay buggy CD-ROM firmware.

> We changed it yesterday to use an ID_CDROM_MEDIA key:
>   http://git.kernel.org/?p=linux/hotplug/udev.git;a=commit;hù07449eee3f58fafafee0658e80578b1dbb2722
> 
> Would be good to know, if that works in the case you see the wrong values.

I got a reply from two testers, unfortunately it doesn't see to help
at all. With the patch, he gets this on eject:

UDEV  [1240402978.959576] change   /devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr1 (block)
ACTION=change
SUBSYSTEM=block
DEVTYPE=disk
ID_CDROM=1
ID_CDROM_DVD=1
ID_CDROM_MEDIA=1
ID_CDROM_MEDIA_DVD=1
ID_CDROM_MEDIA_STATE=blank
ID_CDROM_MEDIA_SESSION_NEXTF336
ID_CDROM_MEDIA_SESSION_COUNT3024
ID_CDROM_MEDIA_TRACK_COUNTX368
[...]

(full log in the Launchpad bug)

Thanks,

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CD-ROM tray closes automatically after eject due to random
  2009-04-21  7:25 CD-ROM tray closes automatically after eject due to random Martin Pitt
                   ` (2 preceding siblings ...)
  2009-04-22 13:34 ` Martin Pitt
@ 2009-04-22 22:16 ` Kay Sievers
  2009-04-23  7:35 ` Martin Pitt
  2009-04-23 13:19 ` Kay Sievers
  5 siblings, 0 replies; 7+ messages in thread
From: Kay Sievers @ 2009-04-22 22:16 UTC (permalink / raw)
  To: linux-hotplug

On Wed, Apr 22, 2009 at 15:34, Martin Pitt <martin.pitt@ubuntu.com> wrote:

>> We changed it yesterday to use an ID_CDROM_MEDIA key:
>>   http://git.kernel.org/?p=linux/hotplug/udev.git;a=commit;hù07449eee3f58fafafee0658e80578b1dbb2722
>>
>> Would be good to know, if that works in the case you see the wrong values.
>
> I got a reply from two testers, unfortunately it doesn't see to help
> at all. With the patch, he gets this on eject:
>
> UDEV  [1240402978.959576] change   /devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sr1 (block)
> ACTION=change
> SUBSYSTEM=block
> DEVTYPE=disk
> ID_CDROM=1
> ID_CDROM_DVD=1
> ID_CDROM_MEDIA=1

Hmm, so we need to find a more reliable way to check for a media. We
probably need to ask the kernel with some cdrom ioctl() instead of
just talking SG_IO here. In the hope, the ioctls do more checks, to
support broken hardware like this.

Kay

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CD-ROM tray closes automatically after eject due to random
  2009-04-21  7:25 CD-ROM tray closes automatically after eject due to random Martin Pitt
                   ` (3 preceding siblings ...)
  2009-04-22 22:16 ` Kay Sievers
@ 2009-04-23  7:35 ` Martin Pitt
  2009-04-23 13:19 ` Kay Sievers
  5 siblings, 0 replies; 7+ messages in thread
From: Martin Pitt @ 2009-04-23  7:35 UTC (permalink / raw)
  To: linux-hotplug

Hello Kay,

Kay Sievers [2009-04-23  0:16 +0200]:
> Hmm, so we need to find a more reliable way to check for a media. We
> probably need to ask the kernel with some cdrom ioctl() instead of
> just talking SG_IO here.

Indeed I was wondering about that; do you plan to use the
CDROM_DISC_STATUS ioctl? I found that quite reliable, and it would
keep the fiddly bits in one place in the kernel.

Thanks!

Martin
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: CD-ROM tray closes automatically after eject due to random
  2009-04-21  7:25 CD-ROM tray closes automatically after eject due to random Martin Pitt
                   ` (4 preceding siblings ...)
  2009-04-23  7:35 ` Martin Pitt
@ 2009-04-23 13:19 ` Kay Sievers
  5 siblings, 0 replies; 7+ messages in thread
From: Kay Sievers @ 2009-04-23 13:19 UTC (permalink / raw)
  To: linux-hotplug

On Thu, Apr 23, 2009 at 09:35, Martin Pitt <martin.pitt@ubuntu.com> wrote:
> Kay Sievers [2009-04-23  0:16 +0200]:
>> Hmm, so we need to find a more reliable way to check for a media. We
>> probably need to ask the kernel with some cdrom ioctl() instead of
>> just talking SG_IO here.
>
> Indeed I was wondering about that; do you plan to use the
> CDROM_DISC_STATUS ioctl? I found that quite reliable, and it would
> keep the fiddly bits in one place in the kernel.

Ok, let's try:
  http://git.kernel.org/?p=linux/hotplug/udev.git;a=commitdiff;h÷f0b22d574c6a5e5f3430be3fc619d4b2f46cd5

to check the DRIVE, if we should look for a media at all. If that's
still not enough, we will need to try the DISC ioctl.

Thanks a lot,
Kay
--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-04-23 13:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-21  7:25 CD-ROM tray closes automatically after eject due to random Martin Pitt
2009-04-21  8:52 ` Kay Sievers
2009-04-21  9:14 ` Martin Pitt
2009-04-22 13:34 ` Martin Pitt
2009-04-22 22:16 ` Kay Sievers
2009-04-23  7:35 ` Martin Pitt
2009-04-23 13:19 ` Kay Sievers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.