On Fri, 2005-01-07 at 17:38 -0500, Alan Cox wrote: > > we indeed get the slowdown. Hence, the kernel does something when the > > last > > closer closes the device - dunno what to do here from userspace short of > > just not poll. > > We unlock the door, that makes the drive power management kick in. If > we leave the door locked you can't take a CD out 8) > I forgot to mention that the device is of course opened O_NONBLOCK, which if I understand correctly, is interpreted as a non-data open for CD drives. For polling, one needs to do that otherwise the user can never put a CD into the drive :-) Now, would it be totally insane to skip the lock/unlock door parts for fd's opened with O_NONBLOCK? That would solve the issue; just an idea, not sure about the ramifications.. > > https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=144036 > > > > which I completely fail to understand. Long term it looks like hald > > should be > > using MMC commands to detect media if available - any idea of where I > > can find > > documentation/code for this? > > The standard. You'll want a magic circle, some runes, a wand, a pointy > hat and a heart of steel. I don't know of anything else that covers it. > OK, I did something like that http://people.redhat.com/davidz/test-mmc.c Asynchronous notification doesn't work on any on my drives, see [1]. The spec does say "In asynchronous mode, the Initiator should issue a single GET EVENT/STATUS NOTIFICATION command with an IMMED (immediate) bit of 0 requested. If the Logical Unit does not support Asynchronous Mode, the command shall fail as an illegal request. If the Initiator requests Asynchronous Mode using a request that is not queued or overlapped, the command shall fail as an illegal request." I'm not sure if I need to do something special to make SG_IO use queued or overlapped requests; maybe that's why it's failing, maybe it's just because I got crappy drives. Don't know. Thanks, David [1] : [davidz@daxter mmc]$ ./test-mmc /dev/cdrom poll Using device /dev/cdrom and polling Sending command... Got reply; size 6 bytes data: 0x00 0x06 0x04 0x5e 0x00 0x00 Media Present: 0 Door or Tray Open : 0 [davidz@daxter mmc]$ ./test-mmc /dev/cdrom notif Using device /dev/cdrom and notification Sending command... Sending command failed: Invalid argument [davidz@daxter mmc]$