LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Kernel Modules Understanding (https://www.linuxquestions.org/questions/linux-software-2/kernel-modules-understanding-217084/)

druisgod 08-13-2004 06:28 AM

Kernel Modules Understanding
 
Ok. I just want to make sure I've got this straight. I've kinda been hanging my head in shame. I've used linux for about 5 years now, and I just now made some sense out of the /etc/modprobe and how it relates to the kernel. (Don't we all have those unexplored basic areas?) Don't get me wrong, I understand that you have to put modules you want loaded in there. Here's what I think I've properly learned. Feel free to expand upon if you wish.

The kernel makes a call to a numeric reference. Say, device 80, 0. Then if its built into the kernel, the device is loaded as configured, automatically. If not - /etc/modprobe or /etc/modules.conf, depending on your kernel version is read for an alias to that device. From that it detemines the device driver to load. The device driver with its node number, 80, 0, is then used. So the userspace program for ex, would link to the device file or refernce, say /dev/video, which links to the module that is loaded by the kernel, say nv.ko which was figured out by /etc/modprobe, if it was a module. The module then interprets calls from the userspace program and interprets them into device calls, and vice-versa. Dependencies for the module were sorted out by /lib/modules/kernelversion/moddepwhatever. The mod dep file in /lib/modules/* also loaded any prior requirements for that module to be loaded. Phew. Have I got it, or am I off? I know its not a requirement to understand this, but the lower level I understand, the more I can manipulate what is really going on in my computer.


Thanks for any input.


Druisgod

foo_bar_foo 08-13-2004 10:17 AM

yep you got it
the only thing that sticks out at me is:

basically user space programs only write directly to character devices
(devices that read write data in a serial stream like a sound card for instance)

block devices -- like a hard drive for instance reads write data in fixed size blocks and provide random access to those blocks -- only the kernel code that implements the filesystem itself can write to that.
user space programms use the a library function or kernel system calls directly request the kernel to do that stuff for them. Whle it is possible to write directly to a hard drive anyone can tell you who has written a filesystem it's a very easy way to destroy the hard drive and have to through it in the trash.


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