there is a way to get information in c
int test = (ioctl(fdcdrom, CDROM_DRIVE_STATUS));
but it's limited like it won't just open an empty drive
try this and look at linux/cdrom.h for the rest of the possible return values
i don't think you will get much farther than this -- i tried once -- but i might be wrong
Code:
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/cdrom.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <stdlib.h>
int main() {
int test = 0;
int fdcdrom = open("/dev/cdrom", O_RDONLY);
test = (ioctl(fdcdrom, CDROM_DRIVE_STATUS));
// if it's open close it
if (test == 2) {
ioctl(fdcdrom, CDROMCLOSETRAY);
close(fdcdrom);
return 0;
} else {
// i think here it will only eject if there is a disk !
ioctl(fdcdrom, CDROMEJECT);
close(fdcdrom);
return 0;
}
}