Exploring The Linux Kernel - Part 3
Here is a short post on the history of the Linux kernel.
The Linux kernel is one of the largest open source kernels that exists today. It is constantly evolving with the help of thousands of contributors who spend their free time giving back to the open source community.
Like all open source projects, the Linux kernel source code is available to download in it's entirety. It can be found on kernel.org where you can download it, make changes to it, and experiment with it as you see fit. The source code can also be found on GitHub although this is simply a mirror and development does not take place through Github.
In this post we'll discuss the structure of the Linux kernel source tree. As of the writing of this post the Linux kernel is broken up into 22 subfolders. Not all of these files are source code. There are many documents and tools also stored in the source tree.
- Documentation
- arch
- block
- certs
- crypto
- drivers
- firmware
- fs
- include
- init
- ipc
- kernel
- lib
- mm
- net
- samples
- scripts
- security
- sound
- tools
- usr
- virt
Documentation
The documentation directory contains exactly as you'd assume, documentation. In this folder you can find the file 00-INDEX which contains an alphabetical list of all the documentation that you can find in this directory as well as a one-line description of what each file documents. There is also a 00-INDEX in most subdirectories as well. The files contain everything from descriptions of how to build the kernel, to instructions for anyone wanting to personally contribute to kernel development.
arch
The arch directory contains kernel code that is specific to particular architecture. This directory is further subdivided into directories for each platform, such as arm and x86. The code here is generally non portable and handles aspects of the kernel such as interrupt handlers and low-level memory access.
block
The block directory contains generic code for the block drivers. Linux I/O block allow for the utilization of block devices such as hard disk drives or other slow access memory devices. The device specific block driver code can be found in the drivers directory.
certs
This directory contains the certificate and key files needed for module signature verification. The kernel is not configured by default to build with module signature verification support, however enabling it is as simple as changing a couple of configuration flags. There is also support for using your own key pairs if needed.
crypto
The crypto directory contains the implementation of the Linux cryptographic API. This API is used by both consumers of the cryptographic services and programs requesting data transformations such as ciphers. Alternatively the crypto API allows for compression transformations as well.
drivers
This directory contains code for specific device drivers. The directories are broken up further into types of drivers. For example all the Serial Peripheral Interface (SPI) drivers can be found in the SPI directory which is further divided into directories for each specific architecture.
There is another very important directory within drivers called staging (or driver staging tree). This directory contains drivers which are not quite ready to be merged into the main kernel source tree but are made accessible because of historic difficulties providing users access to these in-development drivers.
There is another very important directory within drivers called staging (or driver staging tree). This directory contains drivers which are not quite ready to be merged into the main kernel source tree but are made accessible because of historic difficulties providing users access to these in-development drivers.
firmware
The firmware directory contains device firmware that is needed to use certain drivers. In the source tree this directory only contains a single makefile to generate some configuration files.
fs
The fs directory contains all the code related to handling different types of filesystems. This directory is further subdivided into directories for each supported file system type. It also contains generic filesystem code that is used between different file system implementations like files.c which implements file descriptor management.
include
The include directory contains the majority of the file includes (.h files) needed during the kernel building process. There is also a directory called asm that contains architecture specific include files.
init
The init directory contains the initialization code for the kernel. There are also several other miscellaneous files such as version.c which defines the structure of the version string.
ipc
the ipc (inter-process communication) directory contains code implementing inter-process communication such as semaphores and other methods of handling shared memory in the system.
kernel
This directory contains miscellaneous kernel code that doesn't quite fit anywhere else. This includes things such as the function printk() which allows writing out character strings in kernel space, as well as pid.c which contains code that handles the assignment of pids (process identification number) to processes.
lib
The lib directory contains the kernel modules and library images needed to boot the system. This directory also contains files that need to be included for certain functionality, for example a C preprocessor would require the inclusion of /lib/cpp
mm
This directory contains system agnostic memory management code implementing things such as virtual memory. The code for implementing platform specific memory management operations like kalloc can be found in the arch directory.
net
The net directory contains the high level networking code. This code receives packets from the network drivers to either use within the kernel or send to userspace applications. This directory is further divided into directories containing different network protocol implementations.
samples
The samples directory contains examples of kernel modules. It also contains code illustrating the used of functions from other parts of the kernel. This directory is not necessary when compiling the Linux kernel.
scripts
This directory contains configuration and build scripts used when building the kernel, Nothing in this directory is compiled directly into the kernel itself, Instead it is used for keeping the scripts generated for or by tools.
security
This directory contains the implementation of different security models.
sound
This directory contains implementation of sound card drivers and code related to handling system sound functions.
tools
This directory contains tools that are useful for testing and interacting with the kernel. This includes things such as tools for testing SPI drivers. As well as programs for demonstrating functionality like leds/uledmon; a userspace program for demonstrating LED use. These tools are not built with the kernel by default.
usr
This directory contains code that builds the initial root filesystem that will be used in the early userspace.
virt
This directory currently contains code related to the KVM (Kernel-based Virtual Machine). The KVM allows you to use multiple virtual machines running Linux or Windows. All virtual machines have private virtualized hardware.
| . |
This is a blog series on the linux kernel; why it's important, what it does it, and how it does it.
The first post in this series can be found here Part 1 - The Kernel
The next post in this series can be found here
No comments:
Post a Comment