* Re: cd-tray immediately closed after it has been opened
2008-07-27 19:19 cd-tray immediately closed after it has been opened Christian Krause
@ 2008-07-27 23:35 ` David Zeuthen
2008-07-28 8:48 ` Christian Krause
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: David Zeuthen @ 2008-07-27 23:35 UTC (permalink / raw)
To: linux-hotplug
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?
David
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: cd-tray immediately closed after it has been opened
2008-07-27 19:19 cd-tray immediately closed after it has been opened Christian Krause
2008-07-27 23:35 ` David Zeuthen
@ 2008-07-28 8:48 ` Christian Krause
2008-07-28 16:23 ` David Zeuthen
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Christian Krause @ 2008-07-28 8:48 UTC (permalink / raw)
To: linux-hotplug
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-ab6d1b27a160895e99f3a7111a78aff68baff3
;-)
Best regards,
Christian
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: cd-tray immediately closed after it has been opened
2008-07-27 19:19 cd-tray immediately closed after it has been opened Christian Krause
2008-07-27 23:35 ` David Zeuthen
2008-07-28 8:48 ` Christian Krause
@ 2008-07-28 16:23 ` David Zeuthen
2008-07-30 17:27 ` Kay Sievers
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: David Zeuthen @ 2008-07-28 16:23 UTC (permalink / raw)
To: linux-hotplug
On Mon, 2008-07-28 at 10:48 +0200, Christian Krause wrote:
> fixes the problem, too. But it looks like that this is discouraged:
>
> http://gitweb.freedesktop.org/?p=hal.git;a=commit;h-ab6d1b27a160895e99f3a7111a78aff68baff3
I remember something funky about that; so we probably need to special
case vol_id to do something similar, e.g. first check for media and if
there is media make vol_id open it without O_NONBLOCK. And probably only
do the media check for optical drives.
David
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: cd-tray immediately closed after it has been opened
2008-07-27 19:19 cd-tray immediately closed after it has been opened Christian Krause
` (2 preceding siblings ...)
2008-07-28 16:23 ` David Zeuthen
@ 2008-07-30 17:27 ` Kay Sievers
2008-07-31 7:31 ` Christian Krause
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2008-07-30 17:27 UTC (permalink / raw)
To: linux-hotplug
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-ab6d1b27a160895e99f3a7111a78aff68baff3
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?
Thanks,
Kay
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: cd-tray immediately closed after it has been opened
2008-07-27 19:19 cd-tray immediately closed after it has been opened Christian Krause
` (3 preceding siblings ...)
2008-07-30 17:27 ` Kay Sievers
@ 2008-07-31 7:31 ` Christian Krause
2008-07-31 7:48 ` Kay Sievers
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Christian Krause @ 2008-07-31 7:31 UTC (permalink / raw)
To: linux-hotplug
Hi Kay,
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-ab6d1b27a160895e99f3a7111a78aff68baff3
>>
>
> 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.
Best regards,
Christian
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: cd-tray immediately closed after it has been opened
2008-07-27 19:19 cd-tray immediately closed after it has been opened Christian Krause
` (4 preceding siblings ...)
2008-07-31 7:31 ` Christian Krause
@ 2008-07-31 7:48 ` Kay Sievers
2008-08-01 19:23 ` David Zeuthen
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2008-07-31 7:48 UTC (permalink / raw)
To: linux-hotplug
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-ab6d1b27a160895e99f3a7111a78aff68baff3
>>>
>>
>> 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"
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: cd-tray immediately closed after it has been opened
2008-07-27 19:19 cd-tray immediately closed after it has been opened Christian Krause
` (5 preceding siblings ...)
2008-07-31 7:48 ` Kay Sievers
@ 2008-08-01 19:23 ` David Zeuthen
2008-08-03 17:38 ` Christian Krause
2008-08-04 6:52 ` Kay Sievers
8 siblings, 0 replies; 10+ messages in thread
From: David Zeuthen @ 2008-08-01 19:23 UTC (permalink / raw)
To: linux-hotplug
On Thu, 2008-07-31 at 09:48 +0200, Kay Sievers wrote:
> 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?
Your patch fixes the problem for me. Thanks!
David
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: cd-tray immediately closed after it has been opened
2008-07-27 19:19 cd-tray immediately closed after it has been opened Christian Krause
` (6 preceding siblings ...)
2008-08-01 19:23 ` David Zeuthen
@ 2008-08-03 17:38 ` Christian Krause
2008-08-04 6:52 ` Kay Sievers
8 siblings, 0 replies; 10+ messages in thread
From: Christian Krause @ 2008-08-03 17:38 UTC (permalink / raw)
To: linux-hotplug
Hi Kay,
Kay Sievers wrote:
> 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"
>
>
Sorry for the late answer. I've tried out the patch and it solves the
problem for me. Thanks!
Best regards,
Christian
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: cd-tray immediately closed after it has been opened
2008-07-27 19:19 cd-tray immediately closed after it has been opened Christian Krause
` (7 preceding siblings ...)
2008-08-03 17:38 ` Christian Krause
@ 2008-08-04 6:52 ` Kay Sievers
8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2008-08-04 6:52 UTC (permalink / raw)
To: linux-hotplug
On Sun, Aug 3, 2008 at 19:38, Christian Krause <chkr@plauener.de> wrote:
> Kay Sievers wrote:
>>
>> 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"
>>
>
> Sorry for the late answer. I've tried out the patch and it solves the
> problem for me. Thanks!
It's part of udev 126. Thanks a lot for your help.
Kay
^ permalink raw reply [flat|nested] 10+ messages in thread