time due | files in the playpen |
---|---|
12:45 PM Tuesday 14 March, 2006 | various system files |
This assignment is very similar to the project Adding a System Call to the Linux Kernel that appears at the end Chapter 2 of the textbook.
In this class, you'll add a system call kernelguru that returns your userid. Type the commmand id on the playpen computer to get your userid. The program will look something like this:
#include <linux/linkage.h> #include <linux/kernel.h> asmlinkage int sys_kernelguru(void) { return YOURID ; }
Use the following user program to call your system call:
#include <linux/errno.h> #include <sys/syscall.h> #include <linux/unistd.h> #include <stdio.h> #include <sys/types.h> #include <pwd.h> _syscall0(int, kernelguru) ; main() { int uid ; struct passwd *pwentry ; uid = kernelguru() ; pwentry = getpwuid(uid) ; if (pwentry == NULL) printf("kernelguru() ==> %d\n", uid) ; else printf("kernelguru ==> %s\n", pwentry->pw_name) ; }
First of all, you should pretty much ignore everything in the book's subsection Building a New Kernel. In Homework 3 you obtained the kernel source and typed the commands to create it.
Now there are some minor problems in the textbook's description of which files need to be edited. However, unless you wait until the last minute to start this assignment, you'll have no problem figuring out what these are. If you wait until the last minute, you'll be in trouble.
Once you have built your kernel, just like you did for Homework 3, you must move the files to the right directory. Since this requires modifying system files, you'll need to use a command sudo which allows you to perform some privileged operations. You'll be set up for sudo next week.
Only two commands are needed to install your kernel:
sudo make modules_install
sudo make install
You should now be able to see your modules within the directory /lib/modules and your kernel within the directory /boot . The file /boot/grub/grub.conf should also allow selection of your kernel.
You'll have to reboot the playpen computer to test your kernel. It would be polite to first use the command w to see if anyone if logged on. Then you can use CTL-ALT-DEL to restart the computer. When the grub screen appears, type a key and then select your kernel.
You'll now need to compile and run the C program stored in testkernelguru.c . You may need to modify /usr/include/bits/syscall.h to get your program to compile.
Add the entry "Successfully modified Linux kernel" to your resume.