You should have completed the following before attempting this in-class exercise. - created/got access to a machine for learning VM (mfl-vm) - downloaded and compiled kernel version 4.12.4 - started the mfl-vm with newly build kernel Kernel modification ------------------- objective - understand how to modify kernel code - profiling/debugging with printk - targeted profiling task steps 1. Add a printk statement to print the filename in the beginning of the function do_sys_open in file fs/open.c line# 1040. 2. Compile the kernel. No need to recompile everything, rebuild only the kernel (no modules). Copy the newly built kernel to /boot and reboot. 3. After reboot execute dmesg or see /var/log/kern.log 4. Modify the code to log the file path relative to the user's home directory (a fixed path, can be hard coded) only if the file is under the directory sub-tree of user's home. Example: (i) if /home/user/X/Y.txt is opened, log line should be X/Y.txt (ii) if /etc/abc.txt is opened, no output Repeat steps 2 and 3. 5. Write a user program that opens a file passed as command line argument to test correctness of your kernel implementation. (demo required) 6. Revert the changes. Kernel module ------------- objective - understand kernel modules - use module parameters - design kernel features with minimal intrusion to core-kernel code task steps 1. Write a simple module which prints "hello kernel" on module load and "bye kernel" on module unload. 2. Pass an integer parameter to the module, log "negative", "zero" or "positive" depending on the parameter value. 3. Export a function pointer from fs/open.c, which is executed if its value is not NULL. Recompile the kernel and reboot. 4. Modify the module to add an implementation for the exported function pointer (a.k.a. the call-back function). Set the value of exported function pointer to your function on module load and reset it to NULL on module unload. 5. Modify the module to accept path to a directory as parameter. The call-back function should print the file (opened from user space) only if it belongs to the directory subtree of the path parameter. Test the correctness. (demo required)