彈出光驅
#include
#include
#include
#include
#include
#define DEVICE "/dev/cdrom"
int fd = open(DEVICE, O_RDONLY|O_NONBLOCK);
if (fd < 0) {
perror("unable to open "DEVICE);
exit(1);
}
if (ioctl(fd, CDROMEJECT) != 0) {
perror("CDROMEJECT ioctl failed");
exit(1);
}
if (close(fd) != 0) {
perror("unable to close "DEVICE);
exit(1);
}
收回光驅
#include
#include
#include
#include
#include
#define DEVICE "/dev/cdrom"
int fd = open(DEVICE, O_RDONLY|O_NONBLOCK);
if (fd < 0) {
perror("unable to open "DEVICE);
exit(1);
}
if (ioctl(fd, CDROMCLOSETRAY,0) != 0) {
perror("CDROMCLOSETRAY ioctl failed");
exit(1);
}
if (close(fd) != 0) {
perror("unable to close "DEVICE);
exit(1);it