Skip to content

Commit da3dd34

Browse files
committed
Revise the path of Linux kernel headers
This patch uses the relative path to Linux kernel headers in source tree rather than what they are usually inclused in LKM. It would be great to introduce \href with appropriate hyperlinks to Linux kernel tree.
1 parent e551c98 commit da3dd34

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lkmpg.tex

+8-8
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ \subsection{The Simplest Module}
206206

207207
\samplec{examples/hello-1.c}
208208

209-
Now you will need a Makefile. If you copy and paste this, change the indentation to use \textit{tabs}, not spaces.
209+
Now you will need a \verb|Makefile|. If you copy and paste this, change the indentation to use \textit{tabs}, not spaces.
210210

211211
\begin{code}
212212
obj-m += hello-1.o
@@ -307,7 +307,7 @@ \subsection{The Simplest Module}
307307
\subsection{Hello and Goodbye}
308308
\label{hello_n_goodbye}
309309
In early kernel versions you had to use the \cpp|init_module| and \cpp|cleanup_module| functions, as in the first hello world example, but these days you can name those anything you want by using the \cpp|module_init| and \cpp|module_exit| macros.
310-
These macros are defined in \verb|linux/init.h|.
310+
These macros are defined in \verb|include/linux/init.h|.
311311
The only requirement is that your init and cleanup functions must be defined before calling the those macros, otherwise you'll get compilation errors.
312312
Here is an example of this technique:
313313

@@ -326,11 +326,11 @@ \subsection{Hello and Goodbye}
326326
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
327327
\end{code}
328328

329-
Now have a look at \verb|linux/drivers/char/Makefile| for a real world example.
329+
Now have a look at \verb|drivers/char/Makefile| for a real world example.
330330
As you can see, some things get hardwired into the kernel (\verb|obj-y|) but where are all those \verb|obj-m| gone?
331331
Those familiar with shell scripts will easily be able to spot them.
332332
For those not, the \verb|obj-$(CONFIG_FOO)| entries you see everywhere expand into \verb|obj-y| or \verb|obj-m|, depending on whether the \verb|CONFIG_FOO| variable has been set to y or m.
333-
While we are at it, those were exactly the kind of variables that you have set in the \verb|linux/.config| file, the last time when you said make menuconfig or something like that.
333+
While we are at it, those were exactly the kind of variables that you have set in the \verb|.config| file in the top-level directory of Linux kernel source tree, the last time when you said make menuconfig or something like that.
334334

335335
\subsection{The \_\_init and \_\_exit Macros}
336336
\label{init_n_exit}
@@ -344,7 +344,7 @@ \subsection{The \_\_init and \_\_exit Macros}
344344
The \cpp|__exit| macro causes the omission of the function when the module is built into the kernel, and like \cpp|__init|, has no effect for loadable modules.
345345
Again, if you consider when the cleanup function runs, this makes complete sense; built-in drivers do not need a cleanup function, while loadable modules do.
346346

347-
These macros are defined in \verb|linux/init.h| and serve to free up kernel memory.
347+
These macros are defined in \verb|include/linux/init.h| and serve to free up kernel memory.
348348
When you boot your kernel and see something like Freeing unused kernel memory: 236k freed, this is precisely what the kernel is freeing.
349349

350350
\samplec{examples/hello-3.c}
@@ -361,7 +361,7 @@ \subsection{Licensing and Module Documentation}
361361

362362
You can use a few macros to indicate the license for your module.
363363
Some examples are "GPL", "GPL v2", "GPL and additional rights", "Dual BSD/GPL", "Dual MIT/GPL", "Dual MPL/GPL" and "Proprietary".
364-
They are defined within \verb|linux/module.h|.
364+
They are defined within \verb|include/linux/module.h|.
365365

366366
To reference what license you're using a macro is available called \cpp|MODULE_LICENSE|.
367367
This and a few other macros describing the module are illustrated in the below example.
@@ -521,7 +521,7 @@ \subsection{Building modules for a precompiled kernel}
521521

522522
Let's focus again on the previous error message: a closer look at the version magic strings suggests that, even with two configuration files which are exactly the same, a slight difference in the version magic could be possible, and it is sufficient to prevent insertion of the module into the kernel.
523523
That slight difference, namely the custom string which appears in the module's version magic and not in the kernel's one, is due to a modification with respect to the original, in the makefile that some distribution include.
524-
Then, examine your \verb|linux/Makefile|, and make sure that the specified version information matches exactly the one used for your current kernel.
524+
Then, examine your \verb|Makefile|, and make sure that the specified version information matches exactly the one used for your current kernel.
525525
For example, you makefile could start as follows:
526526

527527
\begin{verbatim}
@@ -831,7 +831,7 @@ \subsection{The file\_operations Structure}
831831
\subsection{The file structure}
832832
\label{sec:file_struct}
833833

834-
Each device is represented in the kernel by a file structure, which is defined in \verb|linux/fs.h|.
834+
Each device is represented in the kernel by a file structure, which is defined in \verb|include/linux/fs.h|.
835835
Be aware that a file is a kernel level structure and never appears in a user space program.
836836
It is not the same thing as a \cpp|FILE|, which is defined by glibc and would never appear in a kernel space function.
837837
Also, its name is a bit misleading; it represents an abstract open `file', not a file on a disk, which is represented by a structure named inode.

0 commit comments

Comments
 (0)