[home] :: Reading the Linux Kernel
0 products in your
Reading the Linux Kernel
Some Linux enthusiasts are very much interested in the Linux kernel, however some of them do not know where and how to start learning it. This article is going to introduce some initial methods for learning Linux kernel source code, but not to explain the complex kernel mechanism of Linux.
1. File organization of the kernel source programs
1.1 Kernel source programs of Linux are usually installed in the directory “/usr/src/linux”, they share a very simple numbering stipulation: a even version number (like 2.0.30) refers to a steadily published kernel, while an odd number (2.1.42 for example) refers to a kernel that is being developed. This article is based on the steady 2.2.5 source code. The implementation platform in Part 2 is Redhat Linux 6.0.
1.2 The files of kernel source programs are organized in tree-like framework. At the top of the tree you will see these directories:
2. Field Combating: to add a system call to your kernel
1.1 Kernel source programs of Linux are usually installed in the directory “/usr/src/linux”, they share a very simple numbering stipulation: a even version number (like 2.0.30) refers to a steadily published kernel, while an odd number (2.1.42 for example) refers to a kernel that is being developed. This article is based on the steady 2.2.5 source code. The implementation platform in Part 2 is Redhat Linux 6.0.
1.2 The files of kernel source programs are organized in tree-like framework. At the top of the tree you will see these directories:
Arch: the “arch” directory contains all the kernel codes related to system architecture, each subdirectory in the arch directory indicates one supported architecture. For example, the i386 is a subdirectory related to intel CPU and its compatible system architectures.
Include: the “include” subdirectory contains most of the header files needed for compiling the kernel. Platform-independent header files are located in the subdirectory “include/linux”, intel CPU-related header files are in the “include/asm-i386” subdirectory, and scsi device-related header files are in “include/scsi”
Init: This directory contains the initialization codes of the kernel (P.S: NOT the guidance codes of system), it contains two files: “main.c” and “Version.c”. It is a good starting point for studying the kernel.
Mm: It contains all the memory management codes that independent to CPU architecture. While the architecture-realted memory management codes reside in the directory “arch/*/mm”.
Kernel: Contains the kernel code. Files in this directory realize most of the kernel functions of the Linux system. Among these files, the most important one is “sched.c”. Architecture-realted codes are located in directory “arch/*/kernel”
Drivers: Contains all the device drivers. Each subdirectory contains one kind of drivers, for example, the subdirectory “/block” includes the drivers for block devices, such as ide (ide.c).
Others: Lib contains kernel-located library code;
Include: the “include” subdirectory contains most of the header files needed for compiling the kernel. Platform-independent header files are located in the subdirectory “include/linux”, intel CPU-related header files are in the “include/asm-i386” subdirectory, and scsi device-related header files are in “include/scsi”
Init: This directory contains the initialization codes of the kernel (P.S: NOT the guidance codes of system), it contains two files: “main.c” and “Version.c”. It is a good starting point for studying the kernel.
Mm: It contains all the memory management codes that independent to CPU architecture. While the architecture-realted memory management codes reside in the directory “arch/*/mm”.
Kernel: Contains the kernel code. Files in this directory realize most of the kernel functions of the Linux system. Among these files, the most important one is “sched.c”. Architecture-realted codes are located in directory “arch/*/kernel”
Drivers: Contains all the device drivers. Each subdirectory contains one kind of drivers, for example, the subdirectory “/block” includes the drivers for block devices, such as ide (ide.c).
Others: Lib contains kernel-located library code;
Net contains kernel and network related codes;
Ipc contains codes that used for the communication between processes;
Fs contains all filesystem codes and all types of file operation codes, each subdirectory in this directory supports one file system
Script contains all script files that used for configuring the kernel.
Ipc contains codes that used for the communication between processes;
Fs contains all filesystem codes and all types of file operation codes, each subdirectory in this directory supports one file system
Script contains all script files that used for configuring the kernel.
Generally, every directory contains one “.depend” file and one “Makefile” file, reading these two files can be greatly helpful for learning the connection and dependence relationship among all files. Moreover, in some directories there are “Readme” files, which give explaination to the files in the directories, they can also help us to understand the kernel source codes.
2. Field Combating: to add a system call to your kernel