Re: Need help tracing regular write activity in 5 s interval

Padraig Brady
2002-06-05T22:21:58Z

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

Padraig Brady wrote:
> Owen Taylor wrote:
>
>> Padraig Brady <padraig@antefacto.com> writes:
>>
>>> I'm sure it will :-)
>>>
>>> However this it just masking the "problem"
>>
>>
>> Well, the question is, "what is the problem"?
>> Your problem is that a debug message is being output by the kernel and
>> filling your logs. If the debug message doesn't do anybody any good
>> (and it doesn't) then removing the debug message is a fine way of
>> solving the problem.
>
>
> True. But I thought there might be (future) side affects of
> cdrom_media_changed() always returning true. Why is it there at all?

I had a quick look at this and basically cdrom_media_changed()
is only valid when there is a disc in the drive. If the drive
is open or empty then it always returns true. There are a couple
of comments saying it's like this to catch buggy drives, but
hence the interface is broken IMHO and should be removed/fixed?

The attached test program illustrates the problem.

Padraig.

[-- Attachment #2: tcd.c --]
[-- Type: text/plain, Size: 939 bytes --]

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/ioctl.h>
#include <linux/cdrom.h>

/* drives have capabilities (CDC*) like CDC_MEDIA_CHANGED.
These done with CDROM_SET_OPTIONS ioctl. perhaps magicdev
should turn this off as it doesn't use anyway? */

int main(void) {
int cd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK); /* This causes VFS: disk change ... */
while(1) {
//int cd = open("/dev/cdrom", O_RDONLY|O_NONBLOCK);
printf ("media changed[%d]\n", ioctl(cd, CDROM_MEDIA_CHANGED, CDSL_CURRENT));
/*
switch (ioctl(cd, CDROM_DRIVE_STATUS, CDSL_CURRENT)) {
case CDS_DISC_OK: printf("DISK_OK\n"); break;
case CDS_TRAY_OPEN: printf("TRAY_OPEN\n"); break;
case CDS_DRIVE_NOT_READY: printf("DRIVE_NOT_READY\n"); break;
default: printf("default\n"); break;
}
*/
//close(cd);
sleep(2);
}
}