The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
PART 1
Create a Kernel Module “simple”.
– Create a program named simple.c (prints appropriate messages when the kernel module is loaded and unloaded).
– Create a Makefile for compiling the program.
|
simple.c #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> /* This cis called when the module is loaded. */int simple_init(void) { printk(KERN_INFO "Loading Modulen"); return 0;} /* This function is called when the module is removed. */ void simple_exit(void) { printk(KERN_INFO "Removing Modulen"); } |
| Makefile obj-m += simple.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.c |
1.Compile kernel module simple.c $make Note: if the compiling succeeds, several files are produced.
2.Load Kernel Module $sudo insmod simple.ko Check out contents in kernel log buffer. $dmesg
3.Remove Kernel Module $sudo rmmod simple Check out contents in kernel log buffer. $dmesg
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
-----------