1 / 44

Linux Project 1

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). 點選「下一步」.

troy-meyer
Download Presentation

Linux Project 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linux Project 1 中央大學資工系 碩士二年級 江瑞敏

  2. Outline Install fedora on Virtualbox How to compile linux kernel How to add a system call Project hint Solution

  3. Install Fedora Ftpes://140.115.53.23 Username: linux Password: vm3zj4cl4

  4. Install Fedora

  5. 新增一個Virtual Machine (1/9) 點選「下一步」

  6. 新增一個Virtual Machine(2/9) 輸入自訂的Virtual Machine名稱 作業系統選擇Linux,版本選擇Fedora

  7. 新增一個Virtual Machine (3/9) 允許的話就設定512MB以上,之後的OS安裝時是圖形介面

  8. 新增一個Virtual Machine (4/9) 建立新的虛擬硬碟來存放所有的檔案

  9. 新增一個Virtual Machine (5/9) 點選「下一步」

  10. 新增一個Virtual Machine (6/9) 點選「下一步」

  11. 新增一個Virtual Machine (7/9) 選擇虛擬硬碟要存放的位置及大小 硬碟大小要選至少10GB以上,以免編Kernel編到沒空間

  12. 新增一個Virtual Machine (8/9) 點選「建立」

  13. 新增一個Virtual Machine (9/9) 點選「建立」,這樣就完成Virtual Machine的建立

  14. 安裝Fedora (1/18)

  15. 安裝Fedora (1/18) 點選「下一步」

  16. 安裝Fedora (2/18) 選擇剛剛下載下來的ISO檔案

  17. 安裝Fedora (3/18) 點選「開始」

  18. 安裝Fedora (4/18) 按Enter開始圖形介面安裝

  19. 安裝Fedora (5/18) 選擇「Skip」跳過ISO檔的完整度檢查

  20. 安裝Fedora (6/18) 點選「Next」

  21. 安裝Fedora (7/18) 點選「Next」

  22. 安裝Fedora (8/18) 點選「Next」

  23. 安裝Fedora (9/18) 目前虛擬硬碟上都沒有資料也沒有格式化 點選「Yes」

  24. 安裝Fedora (10/18) 選擇系統預設的硬碟配置 點選「Next」

  25. 安裝Fedora (11/18) 點選「Yes」

  26. 安裝Fedora (12/18) 網路設定VirtualBox都幫我們弄好了 點選「Next」

  27. 安裝Fedora (13/18) 選擇「Asia/Taipei」時區 點選「Next」

  28. 安裝Fedora (14/18) 設定root的密碼,之後編譯Kernel完安裝時要用到這組密碼 點選「Next」

  29. 安裝Fedora (15/18) 一定記得要勾選「Software Development」,不然不能夠編譯Kernel

  30. 安裝Fedora (16/18) 等系統設定完Dependencies完後,點選「Next」開始安裝

  31. 安裝Fedora (17/18) 安裝中,大概需要10~20分鐘左右,請稍後…

  32. 安裝Fedora (18/18) 安裝完成,點選「Reboot」

  33. 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

  34. Compile Linux Kernel 1. make oldconfig 2. make –j[n] 3. make modules_install 4. make installl 5. reboot

  35. Add a System call http://in1.csie.ncu.edu.tw/~hsufh/COURSES/FALL2007/syscall.html

  36. 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 */

  37. 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

  38. 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

  39. Add a System Call cd linux/kernel touch project.c Makefile obj-y = project.osched.ofork.oexec_domain.opanic.oprintk.oprofile.o

  40. 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;}

  41. 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_ */

  42. 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;}

  43. 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!! 

  44. Solution http://pastebin.com/wEVLaQyg

More Related