200 likes | 363 Views
Trace Linux Kernel Source. Spring, 2008. Outline. Introduction Kernel Source Resources for Tracing Linux How to compile Linux Kernel Presentation. Original UNIX System Structure. system programs. kernel. hardware. Outline. Introduction Kernel Source Resources for Tracing Linux
E N D
Trace Linux Kernel Source Spring, 2008
Outline • Introduction • Kernel Source • Resources for Tracing Linux • How to compile Linux Kernel • Presentation
Original UNIX System Structure system programs kernel hardware
Outline • Introduction • Kernel Source • Resources for Tracing Linux • How to compile Linux Kernel • Presentation
Kernel Source • Source code web site: • http://www.kernel.org • Source code version: • X.Y.Z • 2.2.17 • 2.4.0 • 2.6.24 • Distributions: • ftp://linux.cis.nctu.edu.tw/distributions/iso • RED HAT , Debian, Mandrake…
Source Code Organization • init • ipc • lib • mm • kernel • net • fs • include • arch • drivers • Document
Outline • Introduction • Kernel Source • Resources for Tracing Linux • How to compile Linux Kernel • Presentation
Resources for Tracing Linux • E-Books • KernelAnalysis-HOWTO: • http://www.linux.org/docs/ldp/howto/KernelAnalysis-HOWTO.html • The Linux Kernel: • http://www.tldp.org/LDP/tlk/tlk.html • Linux Kernel 2.4 Internals: • http://www.moses.uklinux.net/patches/lki.html • LinuxHQ: • http://www.linuxhq.com
Resources for Tracing Linux • Books • Understanding the Linux Kernel, 3nd Edition D. P. Bovet and M. Cesati, O'Reilly & Associates. • Linux Core Kernel – Commentary, In-Depth Code Annotation, S. Maxwell, Coriolis Open Press, 1999. • The Linux Kernel, Version 0.8-3, D. A Rusling, 1998. • Linux Kernel Internals, 2nd edition, M. Beck et al., Addison-Wesley, 1998. • Linux Kernel, R. Card et al., John Wiley & Sons, 1998. • Linux Device Drivers, 2nd Edition: O’Reilly/歐萊禮(中文) • Linux 核心研究篇:學貫
Resources for Tracing Linux • Windows下工具 • UltraEdit • 基礎工具 • VisualStudio • Source Browser, find in files • Unix下工具 • grep: “grep [option] …pattern… [file] ” • ex : grep –ri return rtlcore.c • 無敵的指令,雖然可能找很久 • ctags: “find -name ‘*.[ch]’ | xargs ctags” • 這樣檔案tags裡就有各種關鍵字的索引了 • cflow: “cflow –r fun_name *.c” • 產生call graph • c2html: “c2html < file.c > file.html”
Resources for Tracing Linux • Source code browser • cscope (http://cscope.sourceforge.net/) • GNU Global • http://www.gnu.org/software/global/) • LXR • Source code navigator http://lxr.linux.no/source/ • function, struct, macro
Resources for Tracing Linux • 結構圖繪制工具 • Jude • http://objectclub.esm.co.jp/Jude/
Outline • Introduction • Kernel Source • Resources for Tracing Linux • How to compile Linux Kernel • Presentation
How to compile Linux Kernel • make mrproper • 刪除一些以前留下來的 .o 檔案 • make menuconfig(make xconfig、make gconfig) • 建立 Makefile (挑選核心參數)
How to compile Linux Kernel • make clean • 將以前曾經進行過的 *.o 檔案刪除掉 • make bzImage • 製作出核心檔案 • make modules • 製作出模組相關的檔案 • make modules_install • 開始安裝模組 • /lib/modules • cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.24-x • 移動新核心到 /boot 裡面 • Edit /etc/lilo.conf to reflect the boot image • Reflect to the loader
How to compile Linux Kernel • http://linux.vbird.org/linux_basic/0540kernel.php#compile
Outline • Introduction • Kernel Sourc • Reference • Trace tool • Presentation
Presentation • 基礎知識介紹 • 主要的 data structure • 重要的 function • related system call • 版本比較
File system • Filesystem 1 : • basic concept • important data structure • file • inode • dentry • Vfsmount • Nameidata • function • path_walk • Filesystem 2: • function • ext2_new_block • system call • ext2 vs ext3