301 lines
6.8 KiB
HTML
301 lines
6.8 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Differences Between Versions Of Linux</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
|
REL="HOME"
|
|
TITLE="Linux Loadable Kernel Module HOWTO"
|
|
HREF="index.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Writing Your Own Loadable Kernel Module"
|
|
HREF="x839.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Copyright Considerations With LKMs"
|
|
HREF="copyright.html"></HEAD
|
|
><BODY
|
|
CLASS="SECT1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
SUMMARY="Header navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Linux Loadable Kernel Module HOWTO</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x839.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
></TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="copyright.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="LINUXVERSIONS"
|
|
></A
|
|
>12. Differences Between Versions Of Linux</H1
|
|
><P
|
|
>One thing that deserves mention in this section is the variety of
|
|
Linux versions that exist in the world and what we call them. Unlike
|
|
a proprietary software product where one company carefully controls
|
|
the name and creates a small number of well defined releases,
|
|
variations of Linux are developed by lots of different independent
|
|
people and all of them are called Linux.</P
|
|
><P
|
|
>The most basic Linux releases are controlled by Linus Torvalds and
|
|
distributed by kernel.org as the main Linux releases. They are the
|
|
only releases that can properly by called "Linux 2.4," "Linux 2.6.6,"
|
|
etc.</P
|
|
><P
|
|
>But hardly anybody uses those releases. Instead, people start with
|
|
those releases and make modifications. People often sloppily refer to
|
|
a Linux based on Linux 2.6.6 as Linux 2.6.6 itself. But to be
|
|
correct, you have to add something -- usually a hyphen and a suffix.
|
|
Red Hat versions of Linux, which you see a lot, unfortunately use just
|
|
a plain number for that suffix, e.g. Linux 2.6.6-12. (It would be
|
|
better if they used something more explicitly Red Hat, such as Linux
|
|
2.6.6-rh12).</P
|
|
><P
|
|
>Remember that in this document, "Linux" means the kernel;
|
|
when we consider the operating systems called "Linux", the
|
|
situation gets even more complicated.</P
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="AEN911"
|
|
></A
|
|
>12.1. Linux 2.4 - Linux 2.6</H2
|
|
><DIV
|
|
CLASS="SECT3"
|
|
><H3
|
|
CLASS="SECT3"
|
|
><A
|
|
NAME="AEN913"
|
|
></A
|
|
>12.1.1. Linking Done In Kernel</H3
|
|
><P
|
|
>The biggest change to LKMs between Linux 2.4 and Linux 2.6 is an
|
|
internal one: LKMs get loaded much differently. Most people
|
|
won't see any difference except that the suffix on a file containing
|
|
an LKM has changed, because they use high level tools to manage
|
|
the LKMs and the interface to those tools hasn't changed.</P
|
|
><P
|
|
>Before Linux 2.6, a user space program would interpret the ELF object
|
|
(.o) file and do all the work of linking it to the running kernel,
|
|
generating a finished binary image. The program would pass that image
|
|
to the kernel and the kernel would do little more than stick it in
|
|
memory. In Linux 2.6, the kernel does the linking. A user space
|
|
program passes the contents of the ELF object file directly to the
|
|
kernel. For this to work, the ELF object image must contain
|
|
additional information. To identify this particular kind of ELF
|
|
object file, we name the file with suffix ".ko"
|
|
("kernel object") instead of ".o" For example,
|
|
the serial device driver that in Linux 2.4 lived in the file
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>serial.o</TT
|
|
> in Linux 2.6 lives in the file
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>serial.ko</TT
|
|
>.</P
|
|
><P
|
|
>So there is a whole new <SPAN
|
|
CLASS="APPLICATION"
|
|
>modutils</SPAN
|
|
> package
|
|
for use with Linux 2.6. In it, <B
|
|
CLASS="COMMAND"
|
|
>insmod</B
|
|
> is a trivial
|
|
program, as compared to the full blown linker of the Linux 2.4
|
|
version.</P
|
|
><P
|
|
>Also, the procedure to build an LKM is somewhat harder. To make a .ko
|
|
file, you start with a regular .o file. You run the program <B
|
|
CLASS="COMMAND"
|
|
>modpost</B
|
|
> (which comes with the Linux source code) on it to
|
|
create a C source file that describes the additional sections the .ko
|
|
file needs. We'll call this the .mod file because you conventionally
|
|
include ".mod" in the file name.</P
|
|
><P
|
|
>You compile the .mod file and link the result with the original .o
|
|
file to make a .ko file.</P
|
|
><P
|
|
>The .mod object file contains the name that the LKM instance will have
|
|
when you load the LKM. You set that name with a -D compile option
|
|
(when you compile the .mod file) that sets the KBUILD_MODNAME macro.</P
|
|
><P
|
|
>This change means some things are decidedly harder -- choosing the name for
|
|
the LKM instance, for example. In Linux 2.4, the name was one of the
|
|
inputs to the kernel. <B
|
|
CLASS="COMMAND"
|
|
>insmod</B
|
|
> decided on the name
|
|
and passed it to the kernel. <B
|
|
CLASS="COMMAND"
|
|
>insmod</B
|
|
>'s -o option
|
|
told it explicitly what to use for the LKM instance name. But in 2.6,
|
|
there is no such parameter on the system call and hence no -o option
|
|
on <B
|
|
CLASS="COMMAND"
|
|
>insmod</B
|
|
>. The name is part of the ELF object (.o
|
|
file) that you pass to the kernel. The default name is built into the
|
|
ELF object, but if you want to load it with some other name, you must
|
|
edit the ELF image before passing it to <B
|
|
CLASS="COMMAND"
|
|
>insmod</B
|
|
>.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT3"
|
|
><H3
|
|
CLASS="SECT3"
|
|
><A
|
|
NAME="AEN931"
|
|
></A
|
|
>12.1.2. No Module Busy Function</H3
|
|
><P
|
|
>In Linux 2.6 <TT
|
|
CLASS="VARNAME"
|
|
>can_unload</TT
|
|
> (see <A
|
|
HREF="x839.html#USECOUNT"
|
|
>Section 11.4</A
|
|
>) is gone.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT3"
|
|
><H3
|
|
CLASS="SECT3"
|
|
><A
|
|
NAME="AEN936"
|
|
></A
|
|
>12.1.3. CONFIG_MODULE_UNLOAD</H3
|
|
><P
|
|
>You can configure the kernel build to build a kernel that does not
|
|
allow unloading of modules at all, thus sidestepping any problems with
|
|
modules that get unloaded while still in use. See <A
|
|
HREF="x839.html#USECOUNT"
|
|
>Section 11.4</A
|
|
>.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="SECT3"
|
|
><H3
|
|
CLASS="SECT3"
|
|
><A
|
|
NAME="AEN940"
|
|
></A
|
|
>12.1.4. Reference Counting</H3
|
|
><P
|
|
>The interface that the code of an LKM uses to manipulate its reference
|
|
count has been replaced.</P
|
|
></DIV
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x839.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
ACCESSKEY="H"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="copyright.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Writing Your Own Loadable Kernel Module</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Copyright Considerations With LKMs</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |