我正在为debian 6内核编程设备的驱动程序模块,该内核充当FIFO设备,编译非常正确,我使用以下代码创建它:
Major = register_chrdev(0, DEVICE_NAME, &fops); //Major is an integer value
if (Major < 0) {
printk(KERN_ALERT "Registering char device failed with %d\n", Major);
return -Major;
}
/*
* Creation of buffer;
*/
if( (buf = create_cbuffer_t(MAX_BUFFER_SIZE)) == NULL){
printk(KERN_ALERT "Error when creating the FIFO device.");
return -EINVAL;
}
printk(KERN_INFO "Buffer created without error.\n");
签名的主号码是251,我用它创建了它的文件:
sudo mknod /dev/fifodev c 251 0
它工作正常,但当我尝试在终端访问时,这是结果
dsouser@debian:~/Escritorio/Prac3/ParteB$ echo whatever > /dev/fifodev
bash: /dev/fifodev: Permiso denegado **This means:Permission denied**
这也会发生:
dsouser@debian:~/Escritorio/Prac3/ParteB$ cat /dev/fifodev
cat: /dev/fifodev: Argumento inválido
它内部的问题或使其运行的正确方法是什么?
非常感谢
答案 0 :(得分:4)
更改/dev/fifodev
sudo chmod 666 /dev/fifodev