To make sure the behavior of the read and write operations are correct
with offset, update it each time. Also, since it is using the offset,
modify the part of read for removing unnecessary variable.
Currently, the description of the proc_ops in the file operation section
will confuse the reader with registering the device. Add more hints to
avoid it.
Since The length of the message buffer is BUF_LEN. When writing the
BUF_LEN length of the string it will overwrite the last character
(usually it is '\0' from the initialization). And, because the read
operation uses the character in the message buffer ('\0') to stop the
read loop. It will cause the read operation will read out of the
message buffer when the length parameter of read() is not lower than
or equal to BUF_LEN. So add one more byte space to avoid this problem.
Currently, in 13.2 Flashing keyboard LEDs, the description of the
control-flow integrity, "Furthermore, the function prototype with
unsigned long argument may be an obstacle to the control-flow integrity
.", will confuse the reader.
It may lead the reader to think about hardware-assisted CFI like Intel
CET uses the shadow stack attack for ROP (backward-edge protection). But
the description of CFI here talks about the function pointer checking
with the prototype (forward-edge protection).
So add more information to make it more clear.
Close#151
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.
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.htmlClose#148
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>
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
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>
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