[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-hotplug
Subject: Re: cd-tray immediately closed after it has been opened
From: "Kay Sievers" <kay.sievers () vrfy ! org>
Date: 2008-07-31 7:48:30
Message-ID: 3ae72650807310048n379a6aa2pf9503942e6ce6934 () mail ! gmail ! com
[Download RAW message or body]
On Thu, Jul 31, 2008 at 09:31, Christian Krause <chkr@plauener.de> wrote:
> Kay Sievers wrote:
>>
>> On Mon, Jul 28, 2008 at 10:48, Christian Krause <chkr@plauener.de> wrote:
>>
>>>
>>> David Zeuthen wrote:
>>>
>>>>
>>>> On Sun, 2008-07-27 at 21:19 +0200, Christian Krause wrote:
>>>>
>>>>
>>>>>
>>>>> Before this checkin, vol_id was only called for partitioned devices and
>>>>> so the CD tray stayed open.
>>>>>
>>>>>
>>>>
>>>> Probably vol_id needs to use O_NONBLOCK when opening sr devices. Does
>>>> that fix it?
>>>>
>>>>
>>>
>>> Yes, indeed using a patch like this:
>>>
>>> diff --git a/extras/volume_id/vol_id.c b/extras/volume_id/vol_id.c
>>> index 5c4e05d..3dc9f95 100644
>>> --- a/extras/volume_id/vol_id.c
>>> +++ b/extras/volume_id/vol_id.c
>>> @@ -224,7 +224,7 @@ int main(int argc, char *argv[])
>>> goto exit;
>>> }
>>>
>>> - fd = open(node, O_RDONLY);
>>> + fd = open(node, O_RDONLY | O_NONBLOCK);
>>> if (fd < 0) {
>>> fprintf(stderr, "%s: error opening volume\n", node);
>>> rc = 2;
>>>
>>> fixes the problem, too. But it looks like that this is discouraged:
>>>
>>>
>>> http://gitweb.freedesktop.org/?p=hal.git;a=commit;h=2dab6d1b27a160895e99f3a7111a78aff68baff3
>>>
>>
>> Just to check if its the kernel that closes the tray on open(), can you
>> set:
>> /proc/sys/dev/cdrom/autoclose
>> to "0" and try again?
>>
>
> I've tried it out with a small test program which just does an
> open("/dev/sr0", O_RDONLY)
> and additionally with the complete udev/hal/... stack:
>
> If autoclose = 0 then the tray is not closed otherwise it is (without
> O_NONBLOCK).
> If O_NONBLOCK is used, the tray is not closed, even if autoclose = 0. So
> yes, it is the kernel which closes the tray.
Ah, great, thanks for the test. We might just be able to skip optical
drives if cdrom_id did not find a valid media. Does adding this rule
(ID_CDROM_MEDIA_TRACK_COUNT) fix the unwanted tray closing?
Thanks,
Kay
--- a/rules/rules.d/60-persistent-storage.rules
+++ b/rules/rules.d/60-persistent-storage.rules
@@ -52,6 +52,8
# skip unpartitioned removable media devices from drivers which do
not send "change" events
ENV{DEVTYPE}=="disk", KERNEL!="sd*|sr*", ATTR{removable}=="1",
GOTO="persistent_storage_end"
+# skip optical drives without media
+ENV{DEVTYPE}=="disk", KERNEL=="sr*",
ENV{ID_CDROM_MEDIA_TRACK_COUNT}!="?*", GOTO="persistent_storage_end"
--
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic