光ディスクを使用するソフトウェアを配布していますが、デフォルトのフルスピードではノイズが多すぎて許容できません。私の目標は、ioctl を使用してディスクの速度を下げることですが、/Volumes/MyDisk/Application から /dev/disk(n) を見つける方法がわかりません。
以下は私がこれまでに持っているものですが、ディスクパスをハードコーディングしたくありません。
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <IOKit/storage/IOCDMediaBSDClient.h>
int main () {
// ------------------------------------
// Open Drive
// ------------------------------------
int fd = open("/dev/disk1",O_RDONLY);
if (fd == -1) {
printf("Error opening drive \n");
exit(1);
}
// ------------------------------------
// Get Speed
// ------------------------------------
unsigned int speed;
if (ioctl(fd,DKIOCCDGETSPEED,&speed)) {
printf("Must not be a CD \n");
}
else {
printf("CD Speed: %d KB/s \n",speed);
}
// ------------------------------------
// Close Drive
// ------------------------------------
close(fd);
return 0;
}