The following steps will help you compile your own versions of the kernel, read the class notes, and search in the kernel source.
These notes assume that you are using the MultiLab, where you have access to my copy of the Linux source. If not, you need to modify the instructions appropriately.
You will create a User-Mode Linux (UML) kernel, which is a full-featured Linux kernel that runs as an ordinary process within a Linux installation.
gcc --versionYou only want to make links to, not real copies of, the Linux source files we have downloaded from the web:
mkdir MYLINUX cd MYLINUX lndir /u/joa-d1/SCRATCH/linux/linux-4.4.108To compile the kernel:
make defconfig ARCH=um make menuconfig ARCH=um (You can just save the original configuration.) make ARCH=um (You can accept the default values for UML)
cd MYLINUX ./linux rootfstype=hostfs rw mem=128M init=/bin/bash (or /bin/tcsh or other shell)You are now running the shell in your UML, and the current directory is / on the host operating system. All files you write are written with your permissions and ownership, and you can only read files that your permissions permit, even though UML thinks the shell is running as root.
mount -t proc proc /proc
su - YOURLOGINNAME
limit coredumpsize 0 (csh, tcsh) ulimit -c 0 (bash, dash)
I recommend you use the Vim text editor for reading class notes, although you may certainly choose some other tool. Vim can use a tags file to quickly jump to the file and line that defines a given identifier.
The following code runs find to list all the files in the Linux source, ctags to create a set of tags from those files, and grep to remove tags that you really aren't interested in, primarily platform-dependent tags for other platforms, as well as device-driver files. The tags file will be about 60MB. Better yet, just grab and gunzip the tags file from http://www.cs.uky.edu/~raphael/courses/CS585/tags.gz (9 MB).
cat > badtags << BADEND /alpha/ /arc/ /arm/ /arm64/ /avr32/ /blackfin/ /c6x/ /cris/ /frv/ /h8300/ /hexagon/ /ia64/ /m32r/ /m68k/ /metag/ /microblaze/ /mips/ /mn10300/ /nios2/ /openrisc/ /parisc/ /powerpc/ /s390/ /score/ /sh/ /sparc/ /tile/ /um/ /unicore32/ /xtensa/ /drivers/ BADEND
find MYLINUX -not \( -type d \) \ \( -name '*.c' -o -name '*.S' -o -name '*.h' \) -print | \ /bin/grep -v -F -f badtags | \ /usr/bin/ctags \ --regex-Asm='/.* LIST_HEAD\((.*)\)/\1/l/' \ --regex-Asm='/ENTRY\((.*)\)/\1/l/' \ -w -L - -f tags
To get fancy syntax coloration in Vim for my class notes, put the file http://www.cs.uky.edu/~raphael/courses/CS585/linux.vim in directory ~/.vim/syntax/linux.vim.
Place the following command in your startup file (~/.vimrc is a good place):
:syntax onTo jump via a tag, move the cursor to the tag, then type <control>]. To jump to another location with the same tag, type :tn<enter>. To pop the stack of tags, type <control>T.
|M-x visit-tags-table||prompts for the tag file to be loaded. The default filename used by etags is TAGS.|
|M-.||prompts for the tag to be searched and finds the first occurrence.|
|C-u M-.||goes to the next occurrence of the tag.|
|M-*||goes to the previous occurrence of the tag.|
|C-x 4 .||prompts for the tag to be searched and displays the first occurrence of the tag in another window.|
|M-x tags-apropos||searches for all tags that match a regular expression in the tag table.|
|M-x tags-search||searches for text "other than tags" across all files in the current tag table.|
|M-,||repeats the last tags-search command.|
|M-x tags-query-replace||prompts for a search string (not a regular expression) and a replacement string and then calls the query-replace function on all files in the current tag table.|
|M-x list-tags||prompts for a filename and then displays all the tags defined within the file in another window.|