Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
After i create device file by calling device_create:
device_create(test_class, parent, devt, test_dev, "%s", "test") 

i can list test file device when using ls command
# ls -l /dev/test
but when i using command:
# cat /dev/test
i get an error:
couldn't found '/dev/test' or address

Please explain for me how to solve that problem, thank so much!
Posted
Updated 2-Jul-12 20:33pm
v3
Comments
Richard MacCutchan 3-Jul-12 4:17am    
Please show the actual output of the ls and cat commands, not your interpretation of what you think they said.
mot sach 4-Jul-12 3:42am    
sorry, this is out put:
# ls -l /dev/test
output:
/dev/test

# cat /dev/test
output:
cat: can't open '/dev/test': No such device or address

i really don't understand difference between calling device_create function and mknod command
Richard MacCutchan 4-Jul-12 4:05am    
If that is all you are getting from ls -l then there is something wrong as your device has no connection to anything, it's just a name. If you do not understand device_create then I recommend reading the man pages and doing some Google research.
mot sach 8-Jul-12 23:54pm    
this is my source code:

#define DBG_MSG(msg) printk(KERN_INFO "[test] %s %s\n", __FUNCTION__, msg)

struct class* test_class;
dev_t devt;
struct device* dev;
static int __init test_init(void)
{
DBG_MSG("enter");
test_class = class_create(THIS_MODULE, "test_class");
if ( IS_ERR(test_class) ) {
printk ( "can't create test class\n" );
class_destroy(test_class);
return PTR_ERR(test_class);
}
//register test device
major = register_chrdev(FPGA_DYNAMIC_MAJOR, "test", &test_fops);
printk ( "[test] %d\n", major );
devt = MKDEV(major, 0);
dev = device_create(test_class, NULL, devt, NULL, "test");
device_register(dev);
DBG_MSG("exit succesfull");
return 0;
}


after installed modules, and called mdev -s command, i can read /sys/class/test_class/test/dev, but i can't read /dev/test. Could you help me solve this problem? Thank so much!
Richard MacCutchan 9-Jul-12 4:10am    
I already told you: /dev/test does not have a proper entry in the device table - you need to correct it so it is linked to a real device.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900