歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> Linux文化 >> Kernel source code的介紹

Kernel source code的介紹

日期:2017/2/27 12:21:23   编辑:Linux文化

首先, 我們來看看, kernel source code 中有哪些目錄:

69 ./fs/ext
26 ./fs/msdos
86 ./fs/proc
79 ./fs/minix
68 ./fs/isofs
142 ./fs/nfs
150 ./fs/ext2
76 ./fs/xiafs
133 ./fs/umsdos
69 ./fs/hpfs
101 ./fs/sysv
143 ./fs/smbfs
93 ./fs/fat
42 ./fs/vfat
95 ./fs/ncpfs
41 ./fs/ufs
95 ./fs/affs
1867 ./fs
26 ./init
174 ./kernel
53 ./lib
171 ./mm
1 ./include/linux/modules
1085 ./include/linux
4 ./include/asm-generic
197 ./include/asm-i386
265 ./include/asm-mips
198 ./include/asm-alpha
255 ./include/asm-m68k
344 ./include/asm-sparc
107 ./include/net
109 ./include/asm-ppc
11 ./include/scsi
2576 ./include
38 ./net/unix
30 ./net/802
68 ./net/appletalk
147 ./net/ax25
114 ./net/core
12 ./net/ethernet
620 ./net/ipv4
61 ./net/ipx
91 ./net/netrom
2 ./net/decnet
2 ./net/ipv6
55 ./net/bridge
1314 ./net
69 ./ipc
3031 ./drivers/net
814 ./drivers/block
348 ./drivers/char/ftape
1792 ./drivers/char
3063 ./drivers/scsi
1000 ./drivers/sound
35 ./drivers/pci
628 ./drivers/cdrom
80 ./drivers/isdn/icn
219 ./drivers/isdn/teles
104 ./drivers/isdn/pcbit
721 ./drivers/isdn
205 ./drivers/sbus/char
218 ./drivers/sbus
11305 ./drivers
1 ./modules
21 ./arch/i386/boot/compressed
8 ./arch/i386/boot/tools
96 ./arch/i386/boot
14 ./arch/i386/mm
369 ./arch/i386/math-emu
9 ./arch/i386/lib
185 ./arch/i386/kernel
684 ./arch/i386
9 ./arch/alpha/boot/tools
22 ./arch/alpha/boot
25 ./arch/alpha/lib
10 ./arch/alpha/mm
198 ./arch/alpha/kernel
48 ./arch/alpha/math-emu
316 ./arch/alpha
13 ./arch/sparc/boot
369 ./arch/sparc/kernel
81 ./arch/sparc/lib
139 ./arch/sparc/mm
40 ./arch/sparc/prom
652 ./arch/sparc
3 ./arch/mips/boot
12 ./arch/mips/mm
190 ./arch/mips/kernel
5 ./arch/mips/lib
224 ./arch/mips
35 ./arch/ppc/mm
156 ./arch/ppc/kernel
4 ./arch/ppc/boot
216 ./arch/ppc
263 ./arch/m68k/amiga
195 ./arch/m68k/atari
33 ./arch/m68k/boot/amiga
34 ./arch/m68k/boot/atari
69 ./arch/m68k/boot
533 ./arch/m68k/ifpsp060
208 ./arch/m68k/kernel
15 ./arch/m68k/lib
44 ./arch/m68k/mm
502 ./arch/m68k/fpsp040
314 ./arch/m68k/console
3 ./arch/m68k/tools/amiga
4 ./arch/m68k/tools
2163 ./arch/m68k
4256 ./arch
80 ./scripts/lxdialog
228 ./scripts
34 ./Documentation/filesystems
192 ./Documentation/networking
178 ./Documentation/cdrom
74 ./Documentation/isdn
917 ./Documentation
23049 .

這是 du 我的 /usr/src/linux (1.99.7) 所看到的。
以下我們來分析各子目錄。


這些是 Linux 所支援的 file systems:

* ext2 : 這在 Linux 中是最重要的檔案系統。
一般來講 Linux 現在均使用它為主要的檔案系統。

* ext, xiafs : 雖說這是 Linux 中很基本的檔案系統, 但
這兩個已經沒什麽人在用了。

* proc : 這個是 Linux 依照 SysV 的 proc file system
來做的, 其中有一堆 processes information。

Root@Henry:/proc# ls
1/ 12263/ 12514/ 1893/ 3369/ kmsg
107/ 12264/ 12527/ 1909/ 4943/ ksyms
11007/ 12387/ 126/ 191/ 4944/ loadavg
11008/ 12389/ 132/ 1910/ 6/ locks
11009/ 12413/ 136/ 196/ 709/ mdstat
11010/ 12414/ 138/ 199/ 8906/ meminfo
11011/ 12415/ 141/ 2/ 8907/ misc
11176/ 12418/ 143/ 200/ 9886/ modules
11177/ 12423/ 146/ 201/ 9887/ mounts
112/ 12428/ 148/ 205/ 9889/ net/
116/ 12429/ 156/ 206/ cmdline pci
120/ 12473/ 160/ 208/ cpuinfo rtc
12004/ 12479/ 162/ 209/ devices scsi/
12030/ 12481/ 163/ 212/ dma self@
12031/ 12482/ 187/ 3/ filesystems stat
12139/ 12504/ 188/ 3066/ interrupts sys/
12141/ 12505/ 189/ 3296/ ioports uptime
122/ 12513/ 1891/ 3368/ kcore version

在此我們看個例子:

root@Henry:/proc# cat interrupts
0: 5862172 timer
1: 153446 keyboard
2: 0 cascade
3: 0 + serial
4: 156449 + serial
5: 5 SoundBlaster
8: 0 + rtc
9: 1172 aha1542
10: 613417 + aic7xxx
11: 371123 + eata_dma
12: 1540252 DE434/5 (eth0)
13: 1 math error
14: 3182 + ide0
15: 340720 + ide1

就可以知道 interrupts 0~15 的狀態。很多 ps 類的程式
都是以此為基礎來得知一些 processes information。

* msdos, fat, vfat : 可以使用 DOS/Windows95 用的檔案系統。

* smbfs : 是 samba protocol, 可以使用 Windows Work Groups
export 出來的 file system。

* ncpfs : 是 NCP protocol, 可以 mount novell 的 volumn。

* nfs : 這是 Unix 上用的 network file system。

* isofs : 使用 iso file system, CDROM 的。

* minix : 現今 Linux 也很常用, 但是都用在軟碟。

* sysv : System V and Coherent filesystem

* affs : Amiga FFS filesystem

* ufs : UFS filesystem (readonly) 為 BSD 及 SunOS 使用。

* hpfs : OS/2 HPFS filesystem

* umsdos: Unix like fs on top of std MSDOS FAT fs

除了這些 fs/ 下的子目錄外, 有一些檔案也是很重要的,
例如在 file system 中把一個檔案載入要執行時, 會先
分辨出它是那一種執行格式 (a.out, elf, java, script)
再使用對應的執行方式。 或例如處理 dcache, buffer, fifo,
fcntl, file locks, quota, iotcl 等等和檔案有關的控制。


再來看看 net/ 下有有些什麽。

* unix : AF_UNIX
* ipv4 : 就是 Linux 中的 TCP/IP 羅, 包括了 icmp, igmp, ip alias,
ip forward, route, arp, rarp.......等等。
* core : 包括了 multicast、firewall
* 802 : The 802.x protocol
* ethernet : ethernet & ethernet II
* ipx : The IPX protocol
* appletalk : Appletalk DDP
* ax25 : Amateur Radio AX.25 Level 2
* netrom : Amateur Radio NET/ROM
* bridge : Bridging (實驗中)
* ipv6 及 decnet 尚在發展中

這就是我們硬體方面的重頭戲了。

* net : 一堆網路卡的 drivers, 主要有 ne2000, D-link (DEC),
AMD 的、HP 的......等等, 甚至連 ArcNET 都支援。

* scsi : 這就是我們多工作業系統中的最愛了。
它所支援的類別有 Disk, Tape, CDROM, 及一般類。
卡 (host) 主要支援的有 AHA-152X/1542/1740/274X~294X/
3940/3985/2940U/UW、BusLogic、AdvanSys、DPT、NCR53c810
等常見的卡, 其中以 DPT 的穩定度最為人津津樂道, 而現在
的 2940 driver 也漸漸令人感到滿意。 NCR 及 AMD 則令人
覺得便宜又大碗 (Tekram 390 有一型是用 AMD 的 chip)

* isdn : Linux 終於也開始支援 ISDN 的卡了, 這些 drivers 主要
是由一群德國人所發展的, 所以卡也是歐陸規格的, 計有:
ICN 2B and 4B、PCBIT-D、Teles/NICCY1016PC/Creatix。
而 synchronous PPP、VJ-compression with synchronous PPP、
generic MP (RFC 1717) 及 audio via ISDN 這些功能也做了。

* block : 這□主要是 IDE 類的 drivers, 包括了各類 ide chip,
ide-cd, ide-tape, floppy, 及 /dev/ 下各種 block
special device 的控制。

* cdrom : 這□放的是除了 SCSI 及 IDE 的 CDROM 外, 需要專用界
面及 drivers 的光碟機, 這些都是較舊的機型, 例如一票
單速、倍速的 AT-BUS 光碟機。

* sound : 這是音效卡的支援 drivers, 例如 SB16, UltraSound 這些
常見的都有支援, 但 PnP 類的卡都尚未支援。

* char : 這些是 character special device 類的 driver, 包括了
console, keyboard, pty/tty, 一些 mouse driver, real
time clock, lp 等等。 現今 Linux 已支援 256 個 pty
了 (但還要改 telnetd、rlogind 及 mknod 出新的 ptys)

* sbus : 是 Sun Sparc 的 sbus, 在此不介紹。


最後剩下這些我們一次介紹完。

* init : 就只有 main.c 及 version.c 這兩個程式而已.

* kernel : □頭主要是 fork, exec, exit, sched, signal
等等 kernel 的 resource control

* lib : 包括 ctype, errno, inflate(壓縮、解壓),
string, vsprintf 等工具。

* mm : Memory Management 類的東西, 包括了 filemap, mmap,
kmalloc, mlock, memory, page_io, swap 等等。

* ipc : Inter-Process Communications, 包括了 messages,
semaphores, share memory 等等。

* include : 一堆 include 檔。

* arch : 機器(平台) 相關度很高的程式, 包括了 alpha, i386,
m68k, mips, ppc 及 sparc。

* script : 一些 compile 及 config 時要用到的工具 scripts。

* Documentation 最近放了很新、很值得一看的文件, 其中包括了重要的
注意事項 (例如 libc 換新), 各類 drivers 的說明等。

* modules : 這是在 make modules 後所放的 *.o 檔, 爾後再打
make modules_install 後就可以安裝在 /lib/modules
下了。

大略上來說, kernel source code 就是這麽回事。
--
Hanky@FruitTea1


Copyright © Linux教程網 All Rights Reserved