Книга: Embedded Linux Primer: A Practical, Real-World Approach

4.1.1. Kernel Versions

4.1.1. Kernel Versions

You can obtain the source code for a Linux kernel and complementary components in numerous places. Your local bookstore might have several versions as companion CD-ROMs in books about Linux. You also can download the kernel itself or even complete Linux distributions from numerous locations on the Internet. The official home for the Linux kernel is found at www.kernel.org. You will often hear the terms mainline source or mainline kernel referring to the source trees found at kernel.org.

As this book is being written, Linux Version 2.6 is the current version. Early in the development cycle, the developers chose a numbering system designed to differentiate between kernel source trees intended for development and experimentation and source trees intended to be stable, production-ready kernels. The numbering scheme contains a major version number, a minor version number, and then a sequence number. Before Linux Version 2.6, if the minor version number is even, it denotes a production kernel; if it is odd, it denotes a development kernel. For example:

Linux 2.4. x Production kernel

Linux 2.5. x Experimental (development)

Linux 2.6. x Production kernel

Currently, there is no separate development branch of the Linux 2.6 kernel. All new features, enhancements, and bug fixes are funneled through a series of gatekeepers who ultimately filter and push changes up to the top-level Linux source trees maintained by Andrew Morton and Linus Torvalds.

It is easy to tell what kernel version you are working with. The first few lines of the top-level makefile[25] in a kernel source tree detail the exact kernel version represented by a given instance. It looks like this for the 2.6.14 production kernel:

NAME=Affluent Albatross

Later in the same makefile, these macros are used to form a version-level macro, like this:


This macro is used in several places in the kernel source tree to indicate the kernel version. In fact, version information is used with sufficient frequency that the kernel developers have dedicated a set of macros derived from the version macros in the makefile. These macros are found in …/include/linux/version.h[26] [2] in the Linux kernel source tree. They are reproduced here as Listing 4-1.

Listing 4-1. Kernel include File:…/include/linux/version.h

#define UTS_RELEASE "2.6.14"
#define LINUX_VERSION_CODE 132622
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

You can check the kernel version from a command prompt on a running Linux system like this:

$ cat /proc/version
Linux version 2.6.13 (chris@pluto) (gcc version 4.0.0 (DENX ELDK 4.0 4.0.0)) #2
Thu Feb 16 19:30:13 EST 2006

One final note about kernel versions: You can make it easy to keep track of the kernel version in your own kernel project by customizing the EXtrAVERSION field.

For example, if you were developing enhancements for some new kernel feature, you might set EXtrAVERSION to something like this:


Later, when you use cat /proc/version, you would see Linux version 2.6.13-foo, and this would help you distinguish between development versions of your own kernel.

Оглавление книги

Оглавление статьи/книги

Генерация: 0.035. Запросов К БД/Cache: 0 / 0
Вверх Вниз