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.
cs134submit to submit the following
Makefilefor your project,
scpto 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:
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.
Makefileto make your module compile. However, your compilation flags must include:
-O2 -D__KERNEL__ -DMODULEat a minimum. The
-O2is 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
<linux/proc_fs.h>in the module.
/procis 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;
insmodis privileged, you'll need to use
sudoto execute it:
sudo insmod proc_clock.oIf it complains about a version mismatch, specify the
/proj/HMC_CS134/usr/src/linux. There are tags files for both
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
insmodcomplaint, which is just a nuisance). I'll patch the sources up to 2.4.2-2 when I get a chance.
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):