Kernel Exercise 5 Brandon Cline Stuart Fischer Rachel Langhans Brian Minter Adam Stasio
Problem Statement Add a new function of return type “int” to the Linux kernel called “pedagogictime(int flag, struct timeval *thetime)” This function should return the current system time using a reference parameter If the “flag” parameter is TRUE, the function should print the system time using stdout. Function should return TRUE if successful, FALSE otherwise. Create a user-space program to test the new system call
Why Modify the Kernel? Changing the kernel allows a user to customize the OS for his or her individual needs. Kernel functions execute in kernel mode and have direct access to kernel variables and hardware I/O but can be initiated in user space. An effectively modified kernel/OS can enhance the productivity of a company or organization.
Modified Files /usr/src/linux /arch/i386/kernel/entry.S /usr/src/linux /include/asm/unistd.h /usr/src/linux /kernel/Makefile
entry.S At the end of the list of.long SYMBOL_NAME(…) statements, we added the entry for our system call.long SYMBOL_NAME(sys_pedagogictime)
unistd.h At the end of the list of #define __NR_…### We added: #define __NR_pedagogictime191
Makefile O_TARGET := kernel.o O_OBJS = …pedagogictime.o
Created Files /usr/src/linux /include/linux/pedagogictime.h –The header file for the system call’s operational code /usr/src/linux /kernel/pedagogictime.c –The system call’s operational code /mytest.c –The program used to test the new system call
Process for Rebuilding the Kernel make clean make oldconfig make dep OR make depend make make install reboot
Difficulties Encountered Creation of the stub using the syscall2() reference Instructions in the exercise book were geared towards mandrake Figuring out how to reference external variables Correct de-referencing of passed structs Make sometimes unable to locate files that we did not modify and were correctly placed. This was fixed by altering the associated #include statements. Some group members unfamiliar with C
Summary… What we learned How to modify the Linux kernel. Alterations to the kernel can improve productivity Versions of Linux are often different from one another requiring different methods of modification. Making changes to the Linux kernel is a fairly simple process, though it does take a while to learn to do effectively.