Assignment 0 - Kernel API¶
- Deadline: Wednesday, 24 March 2021, 23:00
- getting familiar with the qemu setup
- loading/unloading kernel modules
- getting familiar with the list API implemented in the kernel
- have fun :)
Write a kernel module called list (the resulting file must be called list.ko) which stores data (strings) in an internal list.
It is mandatory to start the implementation of the assignment from the code skeleton found in list.c file.
Use the new test infrastructure by running the commands below:
$ git clone https://github.com/linux-kernel-labs/linux.git $ cd linux/tools/labs $ LABS=assignments/0-list make skels $ # The code skeleton will be found in api_assignment/0-list/list.c $ make build $ make copy $ make boot
The module exports a directory named list to procfs. The directory contains two files:
- management: with write-only access; is the interface for transmitting commands to the kernel module
- preview: with read-only access; is the interface through which the internal contents of the kernel list can be viewed.
The code skeleton implements the two procfs files. You will need to create a list and implement support for adding and reading data. Follow the TODOs in the code for details.
To interact with the kernel list, you must write commands (using the echo command) in the /proc/list/management file:
- addf name: adds the name element to the top of the list
- adde name: adds the name element to the end of the list
- delf name: deletes the first appearance of the name item from the list
- dela name: deletes all occurrences of the name element in the list
Viewing the contents of the list is done by viewing the contents of the /proc/list/preview file (use the` cat` command). The format contains one element on each line.
In order to simplify the assignment evaluation process, but also to reduce the mistakes of the submitted assignments, the assignment evaluation will be done automatically with the help of a test script called _checker. The test script assumes that the kernel module is called list.
To increase your chances of getting the highest grade, read and follow the Linux kernel coding style described in the Coding Style document.
Also, use the following static analysis tools to verify the code:
$ linux/scripts/checkpatch.pl --no-tree --terse -f /path/to/your/list.c
$ sudo apt-get install sparse $ cd linux $ make C=2 /path/to/your/list.c
$ sudo apt-get install cppcheck $ cppcheck /path/to/your/list.c
Information about assigments penalties can be found on the General Directions page.
In exceptional cases (the assigment passes the tests by not complying with the requirements) and if the assigment does not pass all the tests, the grade will may decrease more than mentioned above.