#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>
#include <linux/cdrom.h>
#include <fcntl.h>
int main() {
int fd = open("/dev/cdrom",O_RDONLY | O_NONBLOCK);
if(fd < 0){
printf(" open error\n");
return -1;
}
if(!ioctl(fd,CDROMEJECT,NULL)){
printf("out cdrom\n");
}
close(fd);
return 0;
}
#include <stdio.h>
#include <unistd.h>
#include <linux/cdrom.h>
#include <fcntl.h>
int main() {
int fd = open("/dev/cdrom",O_RDONLY | O_NONBLOCK);
if(fd < 0){
printf(" open error\n");
return -1;
}
if(!ioctl(fd,CDROMEJECT,NULL)){
printf("out cdrom\n");
}
close(fd);
return 0;
}