#include #include #include #include #include #include int main(void) { int fd = open("/dev/sr0", O_RDONLY | O_NONBLOCK); int ret; if (fd < 0) { perror("open"); return 1; } ret = ioctl(fd, CDROM_DRIVE_STATUS, 0); printf("ioctl result %d\n", ret); switch(ret) { case CDS_NO_INFO: printf("CDS_NO_INFO\n"); break; case CDS_NO_DISC: printf("CDS_NO_DISC\n"); break; case CDS_TRAY_OPEN: printf("CDS_TRAY_OPEN\n"); break; case CDS_DRIVE_NOT_READY: printf("CDS_DRIVE_NOT_READY\n"); break; case CDS_DISC_OK: printf("CDS_DISC_OK\n"); break; default: printf("Unknown\n"); break; } return 0; }