Untitled
public text v1 · immutable#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <linux/cdrom.h>
#define CDDEVICE "/dev/cdrom" /* CDROM device */
int main(int argc,char **argv)
{
int cdrom;
if ((cdrom = open(CDDEVICE,O_RDONLY | O_NONBLOCK)) < 0) {
perror("open");
exit(1);
}
/* Use ioctl to send the CDROMEJECT command to the device
*/
if (ioctl(cdrom,CDROMEJECT,0)<0) {
perror("ioctl");
exit(1);
}
close(cdrom);
}