* hello-1.c - The simplest kernel module. We have a lot to cover before addressing this relatively high-level issue. But this will have to wait for a future chapter. Which depend on other modules (we calling this `stacking modules'). There's a bit more to the story if you want to write your own modules Now you know how modules get into the kernel. Users should not need to careĪbout the details, as long as they're running recent versions of those tools. In parallel and do the right thing in order to be able to deal with 2.4 and 2.6 kernels. Some distros also set up some wrappers that allow both packages to be installed Linux distros provide modprobe, insmod and depmod as a package called module-init-tools. In the right order, while modprobe just takes the name, without any extension, and figures outĪll it needs to know by parsing /lib/modules/version/p. What we've seen here is: insmod requires you to pass it the full pathname and to insert the modules Insmod /lib/modules/2.6.11/kernel/fs/msdos/msdos.ko So for example, if you wanted to load the msdos module, you'd have to either run: insmod /lib/modules/2.6.11/kernel/fs/fat/fat.ko Knows how to figure out the dependencies and load the modules in the right order. Intended to be fairly dumb about the location of modules, whereas modprobe is aware of the default location of modules, Modprobe directs insmod to /lib/modules/version/, the standard directory for modules. Lastly, modprobe uses insmod to first load any prerequisite modules into the kernel, and then the requested module. Symbols (variables or functions) that the requested module uses. The requested module has a dependency on another module if the other module defines For example, msdos.ko requires the fat.ko module This file is created by depmod -a andĬontains module dependencies. Must be loaded before the requested module may be loaded. Next, modprobe looks through the file /lib/modules/version/p, to see if other modules It knows that the generic identifier refers to the module softdog.ko. If it finds an alias line like: alias char-major-10-30 softdog If modprobe is handed a generic identifier, it first looks for that string in the file modprobe is passed a string in one of two forms:Ī more generic identifier like char-major-10-30. Kernel, the kernel module daemon kmod execs modprobe to load the module in. How do these modules find their way into the kernel? When the kernel needs a feature that is not resident in the Information by reading the file /proc/modules. You can see what modules are already loaded into the kernel by running lsmod, which gets its Talking to Device Files (writes and IOCTLs) 8. Manage /proc file with standard filesystem 5.4. Building modules for a precompiled kernel 3. Passing Command Line Arguments to a Module 2.7. Hello World (part 4): Licensing and Module Documentation 2.6. Hello World (part 3): The _init and _exit Macros 2.5. Hello, World (part 1): The Simplest Module 2.2. If you have questions or comments, please If you publish or distribute this book commercially, donations, royalties, and/or printed copies are greatlyĪppreciated by the author and the Linux Documentation Project (LDP).Ĭontributing in this way shows your support for free software and the LDP. This will allow for the merging of updates and provideĬonsistent revisions to the Linux community. Please make revisions and updates available directly to the document Source code available for your revisions. If you have contributed new material to this book, you must make the material and Of this book in any medium, physical or electronic.ĭerivative works and translations of this document must be placed under the Open Software License, and the originalĬopyright notice must remain intact. No explicit permission is required from the author for reproduction In summary, you may copy andĭistribute this book free of charge or for a profit. Notice remains intact and the method adheres to the provisions of the Open Software License. The author encourages wide distribution of this book for personal or commercial use, provided the above copyright Of merchantability or fitness for a particular purpose. This book is distributed in the hope it will be useful, but without any warranty, without even the implied warranty You can obtain a copy of this license at. The Linux Kernel Module Programming Guide is a free book you may reproduce and/or modify it under the terms of the
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |