Kernel Mysyslog Project
by: burt rosenberg
at: university of miami
date: 22 sep 2021
NAME
my_syslog -- kernel syslog system call
mysyslog -- command line interface to my_syslog
SYNOPSIS
takes a string argument, and kernel syslogs the string
DESCRIPTION
The my_syslog takes a string argument, and kernel syslogs the argument.
It always returns 0.
The mysyslog command calls my_syslog on the first argument.
HISTORY
Introduced as Project 2 in CSC521 session 131.
Made a separate project in csc421 session 191.
BUGS
Goals
The goals of this project are:
- To build a custom Linux kernel.
- To learn the syscall interface, and to add a system call.
- To interface to the system calls by user programs and libraries.
The M1/M2 Mac
Virtual box does not run on the M1/M2 macs. Use QEMU is an alternative.
Install qemu using brew:
brew install qemu
brew install wget
Make an empty virtual image:
qemu-img create myimage.img 32G
Get the ISO from:
wget https://releases.ubuntu.com/16.04/ubuntu-16.04.6-server-i386.iso
and install it:
qemu-system-i386 -drive file=myimage.img,format=raw,index=0,media=disk -cdrom ubuntu-16.04.6-server-i386.iso -boot d -m 2048
then control-C and restart without the cdrom,
qemu-system-i386 -drive file=myimage.img,format=raw,index=0,media=disk -m 2048
(Note: previously qemu-system-i386 -hda myimage.img -cdrom ubuntu-16.04.6-server-i386.iso -boot d -m 2048)
However this is very slow. Please allow hours of time for your initial kernel build.
Specific steps: Build the Linux Kernel
- Build the linux kernel. Here are instructions.
- Note: The build takes at least two hours.
- Rebuild and reboot on the new kernel.
- Ascertain you are on your new kernel by looking for tag in the output of "uname -r"
- Make sure you have changed the name of your kernel, and are booted on the new kernel.
- Copy [repo]/class/proj2/Makefile to your proj2 directory.
- Run "make uname-out" to confirm you have the right kernel.
Specific steps: Add a Syscall to the Linux Kernel
- Modify the kernel files to introduce the system calls. Here
are hints.
- Rebuild and reboot on the new kernel.
- Test mysyslog. The evidence.tar file will be created.
- Modify the Makefile, adding a myevidence target. This target will create
an evidence.out file that contains the exit status of mysyslog when
run with message "Captain Kernel has arrived", the line from the syslog showing
the syslog'ed Captain Kernel message, and the output of uname -r, in that
order.
- svn add evidence.tar and myevidence.out, and commit.
Notes about the syscall entries
When you modify the syscall table, the entire kernel will be rebuilt. This is because everything
depends on the syscall table. I have shown modifications that in this iteration of kernel modification
include four new syscalls, but we are right now only concerned with the first of these four.
You can include all four now, saving a long kernel build later, but you must satisfy external
dependencies by providing stub programs that have the name of the yet unimplemented
syscalls, that just return with a default -1 value. Or you might ignore this for now,
but do that consistently among all the files involved.
Testing and submission
Test-mysyslog
sends the string "hello kernel!" to the system log.
It then saves the return value of mysyslog and the most recent occurence of a
syslog message containing "hello kernel!" to a mysyslog.out file.
Because the output can vary, there is no mysyslog.ref file. The file mysyslog.out will be judged informally.
Please read the makefile and understand what is going on.
You will submit "evidence" that your project ran, as well as the sources so that we can
reproduce your project.
The makefile target evidence collects the evidence into an evidence.tar file, which
you will add and commit to the repository.
The evidence includes of the 5 kernel files and the output file:
- kernel/mysyscalls.h
- kernel/mysyscalls.c
- entry/syscalls/syscall_32.tbl
- linux/syscalls.h
- kernel/Makefile
- evidence.out
You will then modify the makefile to create a myevidence target. This target will
build mysyslog if needed (what should be the dependency of the target?) and run it
with argument "Captain Kernel has arrived". A myevidence.out file is created with,
- mysyslog's exit status
- the line from the syslog file that shows the syslog'ed message "Captain Kernel has arrived"
- the result from the uname -r command.
You must add and commit the complete set of sources that built and tested your project:
- Makefile (modified)
- mysyslog.c (modified)
- mysyslog.h (can be unmodified)
- evidence.tar (created)
- myevidence.out (created)