我正在尝试写入/dev/simulator 文件。 我使用以下方法创建了此设备:
- # mknod /dev/simulator c 60 0
- # chmod 666 /dev/simulator
- # ls -l /dev/simulator
- crw-rw-rw- 1 root root 60, 0 2012-05-22 19:22 /dev/simulator
我试图打开这个设备并在上面写一些东西,但出现错误:
application: Simulator opening failed
条件是我定义的,为什么我进不了设备? 这是我的代码:
/*
* Some Other Code *
*/
static int simDev;
simDev = open("/dev/simulator", O_RDWR);
if(simDev<0) {
printf("application: Simulator opening failed.\n");
exit (1);
}
else
printf("Device opened successfully.");
signal(SIGIO, signal_handler);
pid_t pid;
pid = getpid();
write(simDev, &pid, 4);
/*
* Some Other Code *
*/
close(simDev);
谁能帮我改正我的错误?
最佳答案
您没有定义该设备另一端的内核模块。
关于linux - 打开设备失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10713956/