Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Unbutu + Linux + VirtualBox I am working on an operating systems' assignment and need to cross-check my work. I need this quickly. Please

Using Unbutu + Linux + VirtualBox

I am working on an operating systems' assignment and need to cross-check my work. I need this quickly. Please show the original kernel source code without any modification and the kernel source code you modified. Also please show a screenshot of "$ dmesg | grep hello" and result1.txt, result2.txt, result3.txt,.... Thanks!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

In this assignment, we add a simple system call helloworld to the Linux kernel. The system call prints out a hello world message to the syslog. You need to implement the system call in the kernel and write a user-level program to test your new system call. Go the kernel source code folder. Step 1: register your system call $ vim arch/x86/entry/syscalls/syscall_64.tbl 1. vim /home/sys_admin/Downloads/linux-5.1 (ssh), X vim /home/sys_admin... 91 328 64 pwritev2 _-_x64_sys_pwritev2 329 common pkey_mprotect _-_x64_sys_pkey_mprotect 330 common pkey_alloc __x64_sys_pkey_alloc 331 common pkey_free __x64_sys_pkey_free common statx _-_x64_sys_statx 333 common io_pgetevents ___x64_sys_io_pgetevents common rsea -_x64_sys_rseg # Projecti: new system call 335 common helloworld __x64_sys_helloworld 332 334 Step 2: declare your system call in the header file $ vim include/linux/syscalls.h 1. vim /home/sys_admin/Downloads/linux-5.1 (ssh) X vim /home/sys_admin... #1 unsigned mask, struct statx __user *buffer); asmlinkage long sys_rseq(struct rseq __user *rseq, uint32_t rseq_len, int flags, uint32_t sig); asmlinkage long sys_pidfd_send_signal(int pidfd, int sig, siginfo_t __user *info, unsigned int flags); // Projecti: new system call asmlinkage long sys_helloworld(void); Step 3: implement your system call $ vim kernel/sys.c 2. vim /home/sys_admin/Downloads/linux-5.1 (ssh), X vim /home/sys_admin... X1 do_sysinfo(&val); if (copy_to_user(info, &val, sizeof(struct sysinfo)) return -EFAULT; return 0; // Projecti: new system call SYSCALL_DEFINE@Chelloworld) printk("helloworld"); return 0; Repeat step 3 and 4 in assignment 0 to re-compile the kernel and reboot to the new kernel. Step 4: write a user-level program to test your system call Go to your home directory and create a test program test_syscall.c 2. vim /home/sys_admin/Downloads/test (ssh) X vim /home/sys_admin... 41 #include #include #include #include #include #define __NR_helloworld 335 int main(int argc, char *argv[]) syscall(__NR_helloworld); return 0; Compile the user level program: $ gcc test_syscall.c-o test_syscall Test the new system call by running: $ sudo ./test_syscall The test program will call the new system call and output a helloworld message at the tail of the output of dmesg. $ dmesg | grep hello 2. fish /home/sys_admin/Downloads/test (ssh) X fish /home/sys_admin... #1 sys_admin@R640-2 ~/D/test> dmesg | grep hello [ 128.626914] helloworld 141 fish /Users/ksuo/Desktop/kernel ksuo@ltksup50143mac ~/D/kernel> ls linux-5.1 linux-5.1-modified linux-5.1.tar.gz Please use diff command to highlight your modification (Here the original_file.c refers the file or file path of the original file source code; the modified_file.c refers the file or file path of the file source code you have modified): $ diff -u original_file.c modified file.c>result.txt For example, to show the difference between file include/linux/syscalls.h, just use the command below: fish /Users/ksuo/Desktop/kernel 141 ksuo@ltksup50143mac ~/D/kernel> diff -u ./linux-5.1/include/linux/syscalls.h /linux-5.1-modified/include/linux/sysc alls.h> result.txt For the kernel code, please do not add the entire kernel source code. Just add your modification code, e.g., result1.txt, result2.txt, result3.txt, ... In this assignment, we add a simple system call helloworld to the Linux kernel. The system call prints out a hello world message to the syslog. You need to implement the system call in the kernel and write a user-level program to test your new system call. Go the kernel source code folder. Step 1: register your system call $ vim arch/x86/entry/syscalls/syscall_64.tbl 1. vim /home/sys_admin/Downloads/linux-5.1 (ssh), X vim /home/sys_admin... 91 328 64 pwritev2 _-_x64_sys_pwritev2 329 common pkey_mprotect _-_x64_sys_pkey_mprotect 330 common pkey_alloc __x64_sys_pkey_alloc 331 common pkey_free __x64_sys_pkey_free common statx _-_x64_sys_statx 333 common io_pgetevents ___x64_sys_io_pgetevents common rsea -_x64_sys_rseg # Projecti: new system call 335 common helloworld __x64_sys_helloworld 332 334 Step 2: declare your system call in the header file $ vim include/linux/syscalls.h 1. vim /home/sys_admin/Downloads/linux-5.1 (ssh) X vim /home/sys_admin... #1 unsigned mask, struct statx __user *buffer); asmlinkage long sys_rseq(struct rseq __user *rseq, uint32_t rseq_len, int flags, uint32_t sig); asmlinkage long sys_pidfd_send_signal(int pidfd, int sig, siginfo_t __user *info, unsigned int flags); // Projecti: new system call asmlinkage long sys_helloworld(void); Step 3: implement your system call $ vim kernel/sys.c 2. vim /home/sys_admin/Downloads/linux-5.1 (ssh), X vim /home/sys_admin... X1 do_sysinfo(&val); if (copy_to_user(info, &val, sizeof(struct sysinfo)) return -EFAULT; return 0; // Projecti: new system call SYSCALL_DEFINE@Chelloworld) printk("helloworld"); return 0; Repeat step 3 and 4 in assignment 0 to re-compile the kernel and reboot to the new kernel. Step 4: write a user-level program to test your system call Go to your home directory and create a test program test_syscall.c 2. vim /home/sys_admin/Downloads/test (ssh) X vim /home/sys_admin... 41 #include #include #include #include #include #define __NR_helloworld 335 int main(int argc, char *argv[]) syscall(__NR_helloworld); return 0; Compile the user level program: $ gcc test_syscall.c-o test_syscall Test the new system call by running: $ sudo ./test_syscall The test program will call the new system call and output a helloworld message at the tail of the output of dmesg. $ dmesg | grep hello 2. fish /home/sys_admin/Downloads/test (ssh) X fish /home/sys_admin... #1 sys_admin@R640-2 ~/D/test> dmesg | grep hello [ 128.626914] helloworld 141 fish /Users/ksuo/Desktop/kernel ksuo@ltksup50143mac ~/D/kernel> ls linux-5.1 linux-5.1-modified linux-5.1.tar.gz Please use diff command to highlight your modification (Here the original_file.c refers the file or file path of the original file source code; the modified_file.c refers the file or file path of the file source code you have modified): $ diff -u original_file.c modified file.c>result.txt For example, to show the difference between file include/linux/syscalls.h, just use the command below: fish /Users/ksuo/Desktop/kernel 141 ksuo@ltksup50143mac ~/D/kernel> diff -u ./linux-5.1/include/linux/syscalls.h /linux-5.1-modified/include/linux/sysc alls.h> result.txt For the kernel code, please do not add the entire kernel source code. Just add your modification code, e.g., result1.txt, result2.txt, result3.txt

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+Explain the key responsibilities of each social media role

Answered: 1 week ago