Commit Graph

258 Commits

Author SHA1 Message Date
Jim Huang
63ac35dd4f CI: Bump dependency versions 2022-04-28 19:19:29 +08:00
Jim Huang
96e522cb36
Merge pull request #150 from asas1asas200/zeng-feat-attributes
Add description of sysfs attribute
2022-04-19 03:22:04 +08:00
asas1asas200
04465b1a44 Add description of sysfs attribute
The description of the attribute was added in sysfs section and referenced in vinput section.

In vinput section, just described the class_attribute and some macros about sysfs class.

Add file name at vinput-related examples begin.
2022-04-19 01:54:24 +08:00
Jim Huang
565a599342
Merge pull request #149 from linD026/master
Fix potential concurrent problems in chardev2.c
2022-04-17 02:52:15 +08:00
linD026
beb1ff1595 Fix potential concurrent problems in chardev2.c
After forking, Each file descriptor in the child refers to the same
open file description as the parent. So when calling open() before
fork(), the child can access the device file without checking by
exclusive access in device_open(). It may cause race conditions
in device_ioctl().

Because of that, it is unnecessary to check the multiple access
in device_open(). It just needs check in device_ioctl(), since
read(), write(), seek() system call are atomic [1][2].

Related discussion:
- https://github.com/sysprog21/lkmpg/issues/148

[1] https://lore.kernel.org/lkml/53022DB1.4070805@gmail.com/
[2] https://www.kernel.org/doc/html/latest/filesystems/files.html

Close #148
2022-04-17 02:41:25 +08:00
Jim Huang
aa4b5d7421
Merge pull request #147 from linD026/master
Fix wrong regular expression of clang-format
2022-04-10 22:59:12 +08:00
linD026
9f92fe4d6a Fix wrong regular expression of clang-format 2022-04-10 22:51:59 +08:00
Jim Huang
afc4f6bf56
Merge pull request #146 from linD026/master
Fix typo
2022-04-10 21:38:52 +08:00
linD026
6e7eda6398 Fix typo 2022-04-10 20:31:19 +08:00
Jim Huang
3beae490ee
Merge pull request #145 from linD026/master
Introduce Virtual Input Device Driver
2022-04-08 18:15:57 +08:00
linD026
636c1e702d Introduce Virtual Input Device Driver
Add the new section of input device driver, vinput[1].

Also, update the Acknowledgements.

[1] https://github.com/sysprog21/vinput
2022-04-06 17:13:29 +08:00
Jim Huang
413c7d54cd
Merge pull request #144 from henrybear327/improvement/latexmk
Use latexmk instead of pdflatex for PDF generation
2022-03-18 20:20:41 +01:00
Chun-Hung Tseng
16fe2e9eb0 Update README and Makefile for the latexmk existence check
Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2022-03-18 20:16:02 +01:00
Jim Huang
d78afd22ac Tweak the style of sudoers file 2022-03-19 02:26:43 +08:00
Chun-Hung Tseng
d27d2c2301 Update .gitignore files to ignore latexmk tmp files
Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2022-03-18 19:10:23 +01:00
Chun-Hung Tseng
adb2d21af2 Fix the pdf generation code in Makefile
The current Makefile is missing one more pdflatex pass.

The correct steps are : pdflatex -> bibtex -> pdflatex -> pdflatex [1]. Otherwise, bib items will not be showing properly.

[1] https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#latex-recipes

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2022-03-18 19:10:23 +01:00
Jim Huang
60bed94bad
Merge pull request #143 from linD026/master
Improve the description of finding syscall table
2022-03-17 08:13:26 +08:00
linD026
85ee0ec67b Improve the description of finding syscall table
Presently, the representation of showing which version will use the
method to find out the system call table is vague.

Related discussion:
* sysprog21/lkmpg: https://github.com/sysprog21/lkmpg/pull/142
2022-03-17 07:51:59 +08:00
Jim Huang
19521bc60a Refine wording on module loading
Close #134
2022-03-16 14:32:08 +08:00
Jim Huang
356723c824
Merge pull request #141 from steven1lung/master
Fix grammar and typo
2022-03-09 14:23:17 +08:00
Steven Lung
d771c50166 Fix grammar 2022-03-09 14:14:08 +08:00
Jim Huang
ef2939ef61
Merge pull request #140 from steven1lung/master
Fix typo, grammar and remove duplicated words
2022-03-07 17:11:05 +08:00
Steven Lung
5ca9b642a4 Fix typo, grammar and remove duplicated words
Replaced 'a' with 'an' since a vowel sound is after.
2022-03-07 16:56:13 +08:00
Bob Lee
844beed5d7
Fix a logic error in examples/ioctl.c (#137)
Change the "alloc_ret" and "cdev_ret" initial values to non-zero.
According to the source code, "alloc_chrdev_region" and "cdev_add"
return zero on success, and negative code on failure.

So, if the "alloc_chrdev_region" failed, the if condition becomes true,
then we will jump to the label "error" by goto, checking each return
value whether is a success state from both functions mentioned above
and dealing with it properly for exiting the process.

However, it checks the success state by comparing the return value
with zero (means success), and we got "cdev_ret == 0" is true from
the initial value zero, while we didn't execute "cdev_add" yet.
Hence, there was a logic error when the initial value is zero.

Co-authored-by: NOVBobLee <defru04002@gamil.com>
2022-02-21 00:58:47 +08:00
linD026
d8216ff7b6
Fix incoherent ioctl examples (#139)
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
2022-02-21 00:53:29 +08:00
Ching-Hua (Vivian) Lin
fb15882377
Add book cover (#136)
Both PDF and HTML generation are supported.
2022-01-09 20:26:07 +08:00
萌新阿岩
5c0f9b0abc
Update Makefile and Add explanation (#133)
Add `PWD := $(CURDIR)` in Makefile and the explanation about `sudo make`
when only having `PWD`.
2021-12-28 20:45:50 +08:00
Jim Huang
785c2fe600
Merge pull request #135 from RinHizakura/master
Revise chardev registration
2021-12-25 14:48:13 +08:00
RinHizakura
2cc4264f72 Introduce the new method for chardev registration
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.
2021-12-23 21:12:14 -08:00
Jim Huang
e4016013b2 modinfo does not require superuser permission 2021-12-04 16:13:22 +00:00
Jim Huang
b4ba4cfc9b
Merge pull request #130 from lyctw/master
Fix typo
2021-11-16 16:01:56 +08:00
lyctw
e2a6fcdae9 Fix typo 2021-11-16 14:50:01 +08:00
Jim Huang
17162018fe
Merge pull request #128 from sudoliyang/patch-2
Fix typo
2021-11-08 22:30:20 +08:00
Jim Huang
19b4d4bd22
Merge pull request #127 from sudoliyang/patch-1
Fix typo
2021-11-08 22:14:16 +08:00
Liyang Zhang
f07d5d564d
Fix typo 2021-11-08 22:10:21 +08:00
Liyang Zhang
f5600a4ead
Fix typo 2021-11-08 22:07:08 +08:00
Jim Huang
d88d0cd227
Merge pull request #123 from fennecJ/patch
Generate contributor list as a modular inclusion
2021-11-08 12:07:57 +08:00
manbing
07a9741f79
Adjust the position of Figure 1 (#126) 2021-11-08 12:06:19 +08:00
fennecJ
af09a8a1e5 Add script to gen contributor list and contrib.tex
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.pdf

Close #68
2021-11-03 19:32:48 +08:00
linD026
6b6b6635cf
CI: Introduce Smatch for static analysis (#125)
Smatch[1][2] is a pluggable static analysis for C. It may help us find
out the potential problem of the example code.

Doing with smatch, if set the --file-output flag, it will generate the
{}.c.smatch report for each c file. This will make a little bit
complicated to collect all the report messages. So, here we stay at the
default setting, stdout for the smatch messages.

For more information, see:
- https://lwn.net/Articles/696624/
- https://elinux.org/images/d/d3/Bargmann.pdf

Also, fix the warning from Smatch:

Smatch failed: 1 warning(s), 1 error(s)
lkmpg/examples/procfs2.c:57 procfile_write() error: buffer overflow 'procfs_buffer' 1024 <= 1024
lkmpg/examples/kbleds.c:58 kbleds_init() warn: argument 5 to %lx specifier is cast from pointer

Furthermore, the effect of the write operation in procfs2.c is too
implied. So after writing, print the buffer every time.

Close #122

[1] https://github.com/error27/smatch
[2] https://repo.or.cz/w/smatch.git
2021-11-01 08:20:41 +08:00
demonsome
67149719a4
Explain inode at the first occurrence (#115)
The explanation of "inode" should appear at the first occurrence to which readers
can refer.
2021-10-25 22:46:02 +08:00
Jim Huang
28018227fc Remove out-of-date syscall information
Close #121
2021-10-14 20:51:09 +08:00
Jim Huang
151a91ecf4 Fix wording 2021-10-10 21:45:12 +08:00
Kellegram
dbac3869c7
Add Manrope variable font (#118)
Manrope is an open-source modern sans-serif font family.
2021-10-10 21:34:25 +08:00
Jim Huang
1cb35ac976
Merge pull request #120 from linD026/master
CI: Introduce GCC static analysis
2021-10-08 20:58:52 +08:00
linD026
d6e1044aa7 CI: introduce GCC static analysis
Since GCC version 10, there has been a new option -fanalyzer for
static analysis. It can make the CI pipeline more comprehensive.

Also, the static analysis updates in GCC 11, but we cannot install
the GCC 11 in ubuntu 20.04 straightforwardly right now, which is
the GitHub workflow environment (see status-check.yaml).
For this reason, we stay at the GCC 10.

Close #117

Reference
- https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Static-Analyzer-Options.html
- https://developers.redhat.com/blog/2020/03/26/static-analysis-in-gcc-10
- https://lwn.net/Articles/870290/
- https://developers.redhat.com/blog/2021/01/28/static-analysis-updates-in-gcc-11
- 7d73c3e9c5
2021-10-08 19:41:22 +08:00
Jim Huang
b0bbe0121f
Merge pull request #119 from marconi1964/master
Improve grammar
2021-09-29 22:20:49 +08:00
Marconi Jiang
89755e146a Correct English gramma 2021-09-29 06:41:31 -07:00
Jim Huang
0a176fbb19 Simplify the epilog 2021-09-25 19:53:13 +08:00
Jim Huang
707e193cbe Always run "dmesg" with sudo
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.
2021-09-25 02:09:13 +08:00