#include /* Standard librares */ #include #include #include /* The magic ioctl function */ #include /* For open(3) */ #include #include #include /* Human-readable cdrom ioctls */ #ifndef CDROM_SELECT_SPEED #define CDROM_SELECT_SPEED 0x5322 /* Set the CD-ROM speed */ #endif #ifndef CDC_SELECT_SPEED #define CDC_SELECT_SPEED 0x8 /* programmable speed */ #endif int main(int argc, char *argv[]) { int cdrom, speed, ret = 0; cdrom = open("/dev/cdrom", O_RDONLY | O_NONBLOCK); if(cdrom == -1) { fprintf(stderr,"\nUm, I can't seem to open the cd device. Make the link\n" "to the device to open.\n" "Example: \"ln -s /dev/hdb /dev/cdrom\"\n"); return 1; } if (argc == 1) { fprintf(stderr, "Type speed\n"); close(cdrom); return 1; } speed = atoi(argv[1]); ret = ioctl(cdrom, CDROM_SELECT_SPEED, speed); if (ret < 0) { fprintf(stderr, "Something is wrong\n"); close(cdrom); return 2; } close(cdrom); return 0; }