Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: CLinuxKernel
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 2-Jul-12 20:04pm
Edited 2-Jul-12 20:33pm
v3
Comments
Richard MacCutchan at 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 at 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 at 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 at 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 at 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.
mot sach at 10-Jul-12 21:51pm
   
yeah, could you suggest for me how to solve that (sorry because i am newbie), ^_^.
Richard MacCutchan at 11-Jul-12 3:03am
   
Probably by the ln (link) command; it's a while since I did this on Linux. You say you are a newbie, in which case, I strongly suggest you get hold of a good book on Linux and study the subject you are working on. You will never get to be an expert by asking piecemeal questions on forums like this.

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 940
1 OriginalGriff 543
2 Abhinav S 253
3 thatraja 245
4 Emre Ataseven 200
0 Sergey Alexandrovich Kryukov 8,282
1 OriginalGriff 4,750
2 Peter Leow 3,784
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid