Messages in this thread | | | Date | Thu, 27 May 1999 09:20:02 +0200 | From | Harald Hoyer <> | Subject | IDE-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] | |