Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am using linux kernel 2.4.26. I created a special character file using
in dev directory as mknod /dev/test c 50 0. Command is successful n i can see the file created in /dev/test.
Then I tried to open the file using open the file as
result = open("/dev/test", I_RDWR);
but it fails i get the error as Device not found and it comes as error Number 19 i.e. ENODEV.
I can not change my kernel(version). Kindly let me know if any other thing is missing. Anybody faced the similar problem.
"I created a special character file using in dev directory as mknod /dev/test c 50 0."
50 0 must correspond to a device driver in the kernel. Did you create a kernel device driver for 50 0?
"i get the error as Device not found and it comes as error Number 19 i.e. ENODEV."
This error probably means that there is no kernel device driver which corresponds to 50 0.
"Then I tried to open the file using open the file as
result = open("/dev/test", I_RDWR);"
I think that this statement should be:
result = open("/dev/test", O_RDWR);
but that is not your problem and it should have resulted in a compile error.
If so, did you register the device with major number 50 and minor number 0?
Use the following code to register the device with a major and minor number. Note the 0 will automatically assign major number. In your case use 50. The DEVICE_NAME is a string with the name of your device. fops is a file_operations struct.
int major = register_chrdev(0, DEVICE_NAME, &fops);
If not, how do you know the device is using major number 50 and minor number 0?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.