This assignment consists of doing the "Modules" project in Chapter 4 of the handout selected from Gary Nutt, Linux Kernel Projects.
You may do the work on your own Linux box or on Emulab. However, if you use your own box and it's not running the 2.4 kernel, you might find that the documentation here differs from how your kernel works. That's your problem, not mine.
Please note that getting an Emulab account takes time, since I must approve you before you can begin work. Don't wait until the last minute; I don't promise to approve accounts promptly at any time, but especially on the weekend.
Please use cs134submit
to submit the following
files:
Makefile
for your project,
script.txt
, containing:
scp
to download those files onto
Turing before you can submit them.
There were two class sessions related to this project. You should have gotten handouts there. However, to save myself from requests from people who should know better, here are links to the handouts:
procfs
Guide.
Some of the information in the book and the handout is incorrect or outdated. In particular:
sys_gettimeofday
. You will have to
find that function yourself. You'll also discover that you
need to dig further than simply looking at that function.
Makefile
to make your
module compile. However, your compilation flags must include:
-O2 -D__KERNEL__ -DMODULEat a minimum. The
-O2
is necessary or you'll get
"undefined symbol" errors when you try to insert the module.
-I/proj/HMC_CS134/usr/src/linux/includeat the end of your
CFLAGS
, you'll be technically
more correct, but you'll have some minor problems when you do
the insmod
(see below).
<linux/proc_fs.h>
in
the module.
/proc
is much easier
than it used to be. I
used the following code:
#include <linux/proc_fs.h> static int clock_read_proc(char *page, char **start, off_t off, int count, int *eof, void *data); ... if (create_proc_read_entry("clock", 0, NULL, clock_read_proc, NULL) == NULL) return -ENOMEM;
/proc
device, use:
remove_proc_entry("clock", NULL);
insmod
is privileged, you'll need to use
sudo
to execute it:
sudo insmod proc_clock.oIf it complains about a version mismatch, specify the
-f
switch to insmod
.
/proj/HMC_CS134/usr/src/linux
. There are
tags files for both vi
and emacs
.
You will need to learn to find your way around the kernel.
Note that stuff that is specific to the Pentium architecture
is in the subtree arch/i386
.
insmod
complaint, which is just a nuisance).
I'll patch the sources up to 2.4.2-2 when I get a chance.
insmod
:
Warning: loading foo.o will taint the kernel: no licenseyou safely ignore it, it's just the GNU people trying to control the world. If you really want to suppress it, add the following to your module source (after the #include stuff):
MODULE_LICENSE("GPL");