440 likes | 718 Views
Linux Project 1. 中央大學資工系 碩士二年級 江瑞敏. Outline. Install fedora on Virtualbox How to compile linux kernel How to add a system call Project hint Solution. Install Fedora. Ftpes://140.115.53.23 Username: linux Password: vm3zj4cl4. Install Fedora. 新增一個 Virtual Machine (1/9). 點選「下一步」.
E N D
Linux Project 1 中央大學資工系 碩士二年級 江瑞敏
Outline Install fedora on Virtualbox How to compile linux kernel How to add a system call Project hint Solution
Install Fedora Ftpes://140.115.53.23 Username: linux Password: vm3zj4cl4
新增一個Virtual Machine (1/9) 點選「下一步」
新增一個Virtual Machine(2/9) 輸入自訂的Virtual Machine名稱 作業系統選擇Linux,版本選擇Fedora
新增一個Virtual Machine (3/9) 允許的話就設定512MB以上,之後的OS安裝時是圖形介面
新增一個Virtual Machine (4/9) 建立新的虛擬硬碟來存放所有的檔案
新增一個Virtual Machine (5/9) 點選「下一步」
新增一個Virtual Machine (6/9) 點選「下一步」
新增一個Virtual Machine (7/9) 選擇虛擬硬碟要存放的位置及大小 硬碟大小要選至少10GB以上,以免編Kernel編到沒空間
新增一個Virtual Machine (8/9) 點選「建立」
新增一個Virtual Machine (9/9) 點選「建立」,這樣就完成Virtual Machine的建立
安裝Fedora (1/18) 點選「下一步」
安裝Fedora (2/18) 選擇剛剛下載下來的ISO檔案
安裝Fedora (3/18) 點選「開始」
安裝Fedora (4/18) 按Enter開始圖形介面安裝
安裝Fedora (5/18) 選擇「Skip」跳過ISO檔的完整度檢查
安裝Fedora (6/18) 點選「Next」
安裝Fedora (7/18) 點選「Next」
安裝Fedora (8/18) 點選「Next」
安裝Fedora (9/18) 目前虛擬硬碟上都沒有資料也沒有格式化 點選「Yes」
安裝Fedora (10/18) 選擇系統預設的硬碟配置 點選「Next」
安裝Fedora (11/18) 點選「Yes」
安裝Fedora (12/18) 網路設定VirtualBox都幫我們弄好了 點選「Next」
安裝Fedora (13/18) 選擇「Asia/Taipei」時區 點選「Next」
安裝Fedora (14/18) 設定root的密碼,之後編譯Kernel完安裝時要用到這組密碼 點選「Next」
安裝Fedora (15/18) 一定記得要勾選「Software Development」,不然不能夠編譯Kernel
安裝Fedora (16/18) 等系統設定完Dependencies完後,點選「Next」開始安裝
安裝Fedora (17/18) 安裝中,大概需要10~20分鐘左右,請稍後…
安裝Fedora (18/18) 安裝完成,點選「Reboot」
Compile Linux Kernel • ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.bz2 • http://mike820324.blogspot.tw/2013/01/linux-kernel-1-how-to-compile-linux.html
Compile Linux Kernel 1. make oldconfig 2. make –j[n] 3. make modules_install 4. make installl 5. reboot
Add a System call http://in1.csie.ncu.edu.tw/~hsufh/COURSES/FALL2007/syscall.html
Add a System Call 1. cd $kernel_src 2. cd arch/i386/kernel/syscall_table.S 3. …. .long sys_tee /* 315 */.long sys_vmsplice.long sys_move_pages.long sys_project /* 318 */
Add a System Call cd linux/include/asm/unistd.h #define __NR_vmsplice 316#define __NR_move_pages 317#define __NR_project 318#ifdef __KERNEL__#define NR_syscalls 319
Add a System Call cd linux/include/linux/syscalls.h asmlinkagelong sys_set_robust_list(structrobust_list_head __user *head,size_tlen);asmlinkage long sys_project( inti );#endif
Add a System Call cd linux/kernel touch project.c Makefile obj-y = project.osched.ofork.oexec_domain.opanic.oprintk.oprofile.o
Add a System Call Project.c #include <linux/linkage.h>#include <linux/kernel.h>asmlinkage long sys_project( inti ){printk( "Success!! -- %d\n", i ); return 0;}
Add a System Call(optional) /usr/include/asm/unistd.h #define __NR_vmsplice 316#define __NR_move_pages 317#define __NR_project 318#endif /* _ASM_I386_UNISTD_H_ */
Add a System Call Recompile linux kernel Reboot Create a new file “test.c” #include<syscall.h>int main(){syscall( __NR_project, 2 ); /* 如果沒有做步驟 5, 就用syscall( 318, 2 ); 代替 */return 0;}
Project Hint How to find the process you want? How to find Virtual Address that is being used by the current process? How to transfer Virtual Address to Physical Address? Good luck!!
Solution http://pastebin.com/wEVLaQyg