PART 2  Create a Kernel Module “simple-solution”.  Create a program named simple-solution.c....

PART 2 Create a Kernel Module “simple-solution”. Create a program named simple-solution.c....

PART 2

Create a Kernel Module “simple-solution”.

Create a program named simple-solution.c.

- In the module entry point, create a linked list containing five struct birthday elements and traverse the linked list.

-The name of first struct birthday element should be Alex

-In the module exit point, remove the elements from the linked list and return the free memory back to the kernel

– Create a Makefile for compiling the program

simple-solution.c (incomplete version )

#include <linux/init.h

#include <linux/module.h

#include <linux/kernel.h

#include <linux/list.h

#include <linux/slab.h

struct birthday

{

int month;

int day;

int year;

char *name;

struct list_head list;

};

static LIST_HEAD(birthday_list);

int simple_init(void)

{
 

Makefile

obj-m += simple-solution.o

all:

make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:

make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean

Note: Makefile should be in the same directory as simple_solution.c
For Part II: – Add codes in simple-solution.c based on the instruction in Part 2

-Compile simple-solution.c and then try to load and remove kernel module.

-Use dmesg to check out the kernel log content right after loading and removing kernel module.

- Save the kernel log contents into screenshots.

What's needed?

-A complete version of simple-solution.c

-Report including required screenshots and source code of simple-solution.c
Powered by