Previously ioctl.c is a userspace program for chardev2.c and chardev.h [1].
But now, this file is an independent kernel module, and the original code
disappear.
This patch adds back the original userspace code and renames it to
userspace_ioctl.c.
[1] https://tldp.org/LDP/lkmpg/2.4/html/x856.html
Instead of using the old register_chrdev / unregister_chrdev API,
cdev interface which is newer and would be better for new driver programmers
in most cases. This commit is trying to give the brief overview for
this different interface.
This script do mainly 2 things:
1.
Generate file `Contributors` with git log in following format:
Contributor's name,<1-st e-mail>[,<2nd e-mail>][,<3rd e-mail>]...
The 2-nd email and so on are based on file `.mailmap` in the root
directory of the repo.
Note that it will also append contributors in File `Include`; and
will NOT append contributors in File `Exclude`.
If there are new contributors, script will sort `Contributor` after
append new contributors into each file; Otherwise it do nothing.
2.
Generate contrib.tex based on `Contributors` into lib/contrib.tex in
following format:
[name], (reasonable width) % [1-st e-mail]
Which is inspired by The Not So Short Introduction to Latex 2e[1]
We need to maintain `.mailmap`, `Exclude` and `Include` manually.
All Chinese name should be converted into English/Pinyin in `.mailmap`,
otherwise we may need extra pkg for latex to parse Chinese characters.
[1] - https://tobi.oetiker.ch/lshort/lshort.pdfClose#68
The dmesg command allows you to review the messages that are stored in the
ring buffer. Some Linux distributions have strict requirements for
dmesg, and you need to use sudo to use dmesg.
Since Linux v3.14, the read, write and seek operations of "struct file" are
guaranteed for thread safety [1][2]. This patch added an explanation.
Here are the potential problems:
chardev.c:
- Move the "msg_ptr" pointer into the read function to remove unnecessary usage.
- List the clear states of "already_open" by using mnemonic enumeration.
chardev2.c:
- The "buffer" in the write function is user space data. It cannot use in the
kernel space.
- Reduce the redundant type transformation.
- List the states of "already_open". Same as chardev.c.
[1] https://lore.kernel.org/lkml/20140303210359.26624.qmail@science.horizon.com/T/#u
[2] 9c225f2655
Parameters are case-sensitive, so myintArray is different from myintarray, and people who are running the example with copy/paste will find it doesn't work as described in the text.
In file {chardev,chardev2,sleep}.c, the variable to determine
the exclusive access was of integer type, which led to race
condition.
This patch rewrote the above with atomic CAS respectively
to eliminate the race.
Close#93
The term "reference count" would be better than "use count."
In addition, the usage of module_refcount(THIS_MODULE) was appended
for the reference counter query.
The new command \src was introduced for preliminary hyperlink generation
which points to Linux kernel source code. At present, stable/linux.git
was referred:
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
We might switch to specific LTS kernels once requested.
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.
Both <linux/module.h> and <linux/kernel.h> are essential headers, and
LKM should include them. Here, we do not use the fully qualified path
specifying the headers.
This patch enforces the annotations by means of the following:
* \cpp : C/C++ code, functions, variables, macros, symbols
* \sh : commands, executable files
* \verb : path and filenames
The proc_ops structure is defined in <include/linux/proc_fs.h> since
Linux v5.6+.
In older kernels, file_operations structure is used for custom hooks in
/proc file system. However, it contains some members that are unnecessary
in VFS, and every time VFS expands file_operations set, /proc code comes
bloated.
On the other hand, not only the space, but also some operations were
saved by this structure to improve its performance.
For the example module hello_5, the book showed the incorrect output
in corresponding with its execution results.
In addition, this patch changes from myintArray[2] = {-1, -1} to
myintArray[2] = {420, 420}, which help the readers distinguish from
the kernel messages.
This patch generates HTML files with "make4ht" in the "html" directory.
Known issues with "make4ht":
Running "make4ht -suf html5 -d html lkmpg.tex" will cause the following
flaws:
1. The layout was unsatisfying.
2. After parsing TeX, it stoped at "\tableofcontents" with errors.
3. Several unneeded files were generated.
4. No way to specify the destination filename for HTML generation.
Solutions/workaround:
1. Use customized configuration file "html.cfg" to specify the layout style.
2. Turn off the \tableofcontents section when using make4ht. However, this
results in the lack of table of contents in HTML. It can be fixed by
appending "\Configure{tableofcontents*}{chapter,section,subsection}"
to configuration file.
3. The build system removes the temporary files.
4. Use a symbolic link "index.html" to "lkmpg.html".