diff --git a/index.html b/index.html index 7ebbf25..15dcef1 100644 --- a/index.html +++ b/index.html @@ -296,7 +296,7 @@ module. 18} 19 20MODULE_LICENSE("GPL"); -

Now you will need a Makefile. If you copy and paste this, change the indentation +

Now you will need a Makefile. If you copy and paste this, change the indentation to use tabs, not spaces.

@@ -412,8 +412,8 @@ needed to include module_init and module_exit - macros. These macros are defined in linux/init.h. The only requirement is that -your init and cleanup functions must be defined before calling the those + macros. These macros are defined in include/linux/init.h. The only requirement +is that your init and cleanup functions must be defined before calling the those macros, otherwise you’ll get compilation errors. Here is an example of this technique:

@@ -456,13 +456,14 @@ is as simple as this: -

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

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

@@ -482,9 +483,9 @@ like __init , has no effect for loadable modules. 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. -

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

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

1/* 
@@ -529,7 +530,7 @@ module license 'unspecified' taints kernel.
 

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

To reference what license you’re using a macro is available called MODULE_LICENSE . This and a few other macros describing the module are illustrated in the below @@ -843,11 +844,11 @@ tree: cp /boot/config- 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. 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. Then, examine your linux/Makefile, +slight difference in the version magic could be possible, and it is sufficient to +prevent insertion of the module into the kernel. 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. Then, examine your Makefile, and make sure that the specified version information matches exactly the one used for your current kernel. For example, you makefile could start as follows: @@ -1267,8 +1268,8 @@ syscalls is commonly named fops.

0.6.2 The file structure

-

Each device is represented in the kernel by a file structure, which is defined -in linux/fs.h. Be aware that a file is a kernel level structure and +

Each device is represented in the kernel by a file structure, which is defined in +include/linux/fs.h. Be aware that a file is a kernel level structure and never appears in a user space program. It is not the same thing as a FILE , which is defined by glibc and would never appear in a kernel space function. Also, diff --git a/lkmpg-for-ht.html b/lkmpg-for-ht.html index 7ebbf25..15dcef1 100644 --- a/lkmpg-for-ht.html +++ b/lkmpg-for-ht.html @@ -296,7 +296,7 @@ module. 18} 19 20MODULE_LICENSE("GPL");

-

Now you will need a Makefile. If you copy and paste this, change the indentation +

Now you will need a Makefile. If you copy and paste this, change the indentation to use tabs, not spaces.

@@ -412,8 +412,8 @@ needed to include module_init
and module_exit - macros. These macros are defined in linux/init.h. The only requirement is that -your init and cleanup functions must be defined before calling the those + macros. These macros are defined in include/linux/init.h. The only requirement +is that your init and cleanup functions must be defined before calling the those macros, otherwise you’ll get compilation errors. Here is an example of this technique:

@@ -456,13 +456,14 @@ is as simple as this: -

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

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

@@ -482,9 +483,9 @@ like __init , has no effect for loadable modules. 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. -

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

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

1/* 
@@ -529,7 +530,7 @@ module license 'unspecified' taints kernel.
 

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

To reference what license you’re using a macro is available called MODULE_LICENSE . This and a few other macros describing the module are illustrated in the below @@ -843,11 +844,11 @@ tree: cp /boot/config- 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. 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. Then, examine your linux/Makefile, +slight difference in the version magic could be possible, and it is sufficient to +prevent insertion of the module into the kernel. 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. Then, examine your Makefile, and make sure that the specified version information matches exactly the one used for your current kernel. For example, you makefile could start as follows: @@ -1267,8 +1268,8 @@ syscalls is commonly named fops.

0.6.2 The file structure

-

Each device is represented in the kernel by a file structure, which is defined -in linux/fs.h. Be aware that a file is a kernel level structure and +

Each device is represented in the kernel by a file structure, which is defined in +include/linux/fs.h. Be aware that a file is a kernel level structure and never appears in a user space program. It is not the same thing as a FILE , which is defined by glibc and would never appear in a kernel space function. Also,