LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-24-2011, 01:45 AM   #1
NagaManjunath
LQ Newbie
 
Registered: Nov 2011
Posts: 7

Rep: Reputation: Disabled
insmod & mknod usage


why mknod is needed when we do insmod of device driver?

bcoz anyways insmod will call register_chrdev which will register the char dev with major number in the system.

So why below command is needed:

mknod \dev\chardev c 254 0

pls kindly answer me
 
Old 11-24-2011, 01:52 AM   #2
dbudbu
LQ Newbie
 
Registered: Nov 2011
Posts: 7

Rep: Reputation: Disabled
Under normal circumstances, 'mknod' should not be necessary. Infact, if you load the kenel module for a device driver that is associated with a device node if its /dev/ inode does not simply _appear_, odds are that it has failed to load or initialize properly.

Hint: do a
# dmesg | tail

after your insmod.

If it is your own driver that is at issue, then you're missing a few steps in the register_*_chrdev_ calls during your _init. There are quite a few varations on how to do it, but lots of samples down in {kernel}/drivers/char/.
 
Old 11-24-2011, 01:58 AM   #3
NagaManjunath
LQ Newbie
 
Registered: Nov 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by dbudbu View Post
Under normal circumstances, 'mknod' should not be necessary. Infact, if you load the kenel module for a device driver that is associated with a device node if its /dev/ inode does not simply _appear_, odds are that it has failed to load or initialize properly.

Hint: do a
# dmesg | tail

after your insmod.

If it is your own driver that is at issue, then you're missing a few steps in the register_*_chrdev_ calls during your _init. There are quite a few varations on how to do it, but lots of samples down in {kernel}/drivers/char/.
Hello dbudbu,

That means you mean to say if insmod works fine there is no need of executing mknod??

can you pls give me clarity

Thank you
 
Old 11-24-2011, 02:09 AM   #4
dbudbu
LQ Newbie
 
Registered: Nov 2011
Posts: 7

Rep: Reputation: Disabled
If 'insmod' works, that means the _init() entry point of the driver has returned 0 for success, that is all it means. It is up the driver writer to make sure that during _init() the appriate device creation calls are made, and that they succeed.

Please search the web for LDDK (Linux Device Driver Kit) documentation if writing your own driver.
 
Old 11-24-2011, 02:26 AM   #5
NagaManjunath
LQ Newbie
 
Registered: Nov 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
Question

Quote:
Originally Posted by dbudbu View Post
If 'insmod' works, that means the _init() entry point of the driver has returned 0 for success, that is all it means. It is up the driver writer to make sure that during _init() the appriate device creation calls are made, and that they succeed.

Please search the web for LDDK (Linux Device Driver Kit) documentation if writing your own driver.
let us assume my insmod is successful & my register_chrdev fn returned success (0)

then i mknod \dev\chardev c 254 0 from the shell

will this mknod command changes the major number which was assigned by register_chrdev fn by insmod??
 
Old 11-24-2011, 02:32 AM   #6
dbudbu
LQ Newbie
 
Registered: Nov 2011
Posts: 7

Rep: Reputation: Disabled
if your device node /dev/chardev is not present after _init() then you're missing a step. register_chrdev alone is not enough... see the LDDK

You should not have to mknod. If no /dev/ entry shows up, then its unlikely you've gotten the plumbing to your file_operations correctly attatched to the node.

For simplified char dev, search for 'miscdev'.
 
Old 11-24-2011, 02:37 AM   #7
NagaManjunath
LQ Newbie
 
Registered: Nov 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by dbudbu View Post
if your device node /dev/chardev is not present after _init() then you're missing a step. register_chrdev alone is not enough... see the LDDK

You should not have to mknod. If no /dev/ entry shows up, then its unlikely you've gotten the plumbing to your file_operations correctly attatched to the node.

For simplified char dev, search for 'miscdev'.
I didnt found correct LDDK in web,can you send me the url pls
 
Old 11-24-2011, 03:26 AM   #8
Karl Godt
Member
 
Registered: Mar 2010
Location: Kiel , Germany
Distribution: once:SuSE6.2,Debian3.1, aurox9.2+3,Mandrake?,DSL? then:W7st,WVHB, #!8.10.02,PUPPY4.3.1 now:Macpup
Posts: 314

Rep: Reputation: 45
Quote:
Originally Posted by NagaManjunath View Post
let us assume my insmod is successful & my register_chrdev fn returned success (0)

then i mknod \dev\chardev c 254 0 from the shell

will this mknod command changes the major number which was assigned by register_chrdev fn by insmod??
Yes !
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Power & Memory Usage Of GNOME, KDE, LXDE & Xfce LXer Syndicated Linux News 0 03-08-2010 08:12 PM
When are insmod and mknod not enough? kerneluser Linux - Newbie 3 01-21-2010 03:21 PM
I need ttyS4 & 5, there's no MAKEDEV ans mknod doesn't work DavidHB Slackware 16 10-22-2006 06:08 PM
Device drivers : How to insmod and mknod through an application program? shendeswanand Linux - Newbie 0 02-08-2006 12:28 PM
Controlling CPU usage & memory usage Saravana babu Linux - Software 0 02-18-2004 06:55 AM


All times are GMT -5. The time now is 02:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration