lkml.org 
[lkml]   [1999]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectIDE-CDROM tray locking
Hi,

writing a programm that automatically mounts CDROMs, that are inserted, I
discovered a double tray locking in the IDE-CDROM / Uniform interface.
If you don't lock the tray upon mounting, you are able to remove the media. This
works with the SCSI-CDROM driver, but not with the IDE one without the attached
patch.
BTW, how can I check if the media is removed without actively polling the
status?
Currently I am doing:

for(;;) {
if (ioctl(cdromfd, CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK) {
if(ioctl(cdromfd, CDROM_MEDIA_CHANGED, CDSL_CURRENT) > 0) {
/* A new media was inserted */
}
else {
/* The old media is inserted */
}
}
else {
/* No media is inserted */
}
usleep(/* Some time */);
}

Instead of actively polling and sleeping, I would prefer the following:

select(cdromfd+1, 0, 0, fdset, NULL);

--
» Harald Hoyer ««»» mailto:hoyer@hot.spotline.de ««»» http://hot.spotline.de ««
···············································································
A formal parsing algorithm should not always be used.
-- D. Gries

[unhandled content-type:application/octet-stream]
\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.562 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site