LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   insmod & mknod usage (https://www.linuxquestions.org/questions/linux-newbie-8/insmod-and-mknod-usage-915261/)

NagaManjunath 11-24-2011 12:45 AM

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

dbudbu 11-24-2011 12:52 AM

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/.

NagaManjunath 11-24-2011 12:58 AM

Quote:

Originally Posted by dbudbu (Post 4532493)
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

dbudbu 11-24-2011 01:09 AM

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.

NagaManjunath 11-24-2011 01:26 AM

Quote:

Originally Posted by dbudbu (Post 4532506)
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??

dbudbu 11-24-2011 01:32 AM

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'.

NagaManjunath 11-24-2011 01:37 AM

Quote:

Originally Posted by dbudbu (Post 4532528)
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

Karl Godt 11-24-2011 02:26 AM

Quote:

Originally Posted by NagaManjunath (Post 4532521)
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 !


All times are GMT -5. The time now is 12:07 PM.