<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../general.ent">
  %general-entities;
]>

<sect1 id="ch-system-kmod" role="wrap">
  <?dbhtml filename="kmod.html"?>

  <sect1info condition="script">
    <productname>kmod</productname>
    <productnumber>&kmod-version;</productnumber>
    <address>&kmod-url;</address>
  </sect1info>

  <title>Kmod-&kmod-version;</title>

  <indexterm zone="ch-system-kmod">
    <primary sortas="a-Kmod">Kmod</primary>
  </indexterm>

  <sect2 role="package">
    <title/>

    <para>Kmod 软件包包含用于加载内核模块的库和工具。</para>

    <segmentedlist>
      <segtitle>&buildtime;</segtitle>
      <segtitle>&diskspace;</segtitle>

      <seglistitem>
        <seg>&kmod-ch6-sbu;</seg>
        <seg>&kmod-ch6-du;</seg>
      </seglistitem>
    </segmentedlist>

  </sect2>

  <sect2 role="installation">
    <title>安装 Kmod</title>

    <para>准备安装 Kmod：</para>

<screen><userinput remap="configure">./configure --prefix=/usr          \
            --bindir=/bin          \
            --sysconfdir=/etc      \
            --with-rootlibdir=/lib \
            --with-xz              \
            --with-zlib</userinput></screen>

    <variablelist>
      <title>配置选项的含义：</title>

      <varlistentry>
        <term><parameter>--with-xz, --with-zlib</parameter></term>
        <listitem>
          <para>它们允许 Kmod 处理压缩过的内核模块。</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term><parameter>--with-rootlibdir=/lib</parameter></term>
        <listitem>
          <para>该选项保证一些和库有关的文件被放置在正确的目录中。</para>
        </listitem>
      </varlistentry>

    </variablelist>

    <para>编译该软件包：</para>

<screen><userinput remap="make">make</userinput></screen>

    <para>该软件包不包含能在 LFS chroot 环境下运行的测试套件。
		测试套件至少需要 git 程序的支持，且有些测试在 git 仓库外不会运行。
	</para>

<!--
    <para>运行以下命令以测试编译结果：</para>

<screen><userinput remap="test">make check</userinput></screen>
-->
    <para>安装该软件包，并创建与 Module-Init-Tools （曾经用于处理 Linux
        内核模块的软件包）兼容的符号链接：</para>

<screen><userinput remap="install">make install

for target in depmod insmod lsmod modinfo modprobe rmmod; do
  ln -sfv ../bin/kmod /sbin/$target
done

ln -sfv kmod /bin/lsmod</userinput></screen>

  </sect2>

  <sect2 id="contents-kmod" role="content">
    <title>Kmod 的内容</title>

    <segmentedlist>
      <segtitle>安装的程序</segtitle>
      <segtitle>安装的库</segtitle>

      <seglistitem>
        <seg>depmod (到 kmod 的链接), insmod (到 kmod 的链接), kmod, 
        lsmod (到 kmod 的链接), modinfo (到 kmod 的链接), modprobe (到 kmod 的链接),
        以及 rmmod (到 kmod 的链接)</seg>
        <seg>libkmod.so</seg>
      </seglistitem>
    </segmentedlist>

    <variablelist>
      <bridgehead renderas="sect3">简要描述</bridgehead>
      <?dbfo list-presentation="list"?>
      <?dbhtml list-presentation="table"?>

      <varlistentry id="depmod">
        <term><command>depmod</command></term>
        <listitem>
          <!--para>Creates a dependency file based on the symbols it finds in the
          existing set of modules; this dependency file is used by
          <command>modprobe</command> to automatically load the required
          modules</para-->
          <para>根据现有模块的符号信息创建依赖关系文件；
			  <command>modprobe</command>
			  使用依赖关系文件自动加载需要的模块。</para>
          <indexterm zone="ch-system-kmod depmod">
            <primary sortas="b-depmod">depmod</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="insmod">
        <term><command>insmod</command></term>
        <listitem>
          <para>在正在运行的内核中安装可加载模块</para>
          <indexterm zone="ch-system-kmod insmod">
            <primary sortas="b-insmod">insmod</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="kmod">
        <term><command>kmod</command></term>
        <listitem>
          <para>加载或卸载内核模块</para>
          <indexterm zone="ch-system-kmod kmod">
            <primary sortas="b-kmod">kmod</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="lsmod">
        <term><command>lsmod</command></term>
        <listitem>
          <para>列出当前加载的模块</para>
          <indexterm zone="ch-system-kmod lsmod">
            <primary sortas="b-lsmod">lsmod</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="modinfo">
        <term><command>modinfo</command></term>
        <listitem>
          <para>检验与某个内核模块相关的目标文件，
          打印它能够收集到的一切信息</para>
          <indexterm zone="ch-system-kmod modinfo">
            <primary sortas="b-modinfo">modinfo</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="modprobe">
        <term><command>modprobe</command></term>
        <listitem>
          <para>使用一个 <command>depmod</command> 创建的依赖关系文件，
          自动加载相关模块</para>
          <indexterm zone="ch-system-kmod modprobe">
            <primary sortas="b-modprobe">modprobe</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="rmmod">
        <term><command>rmmod</command></term>
        <listitem>
          <para>从正在运行的内核中卸载模块</para>
          <indexterm zone="ch-system-kmod rmmod">
            <primary sortas="b-rmmod">rmmod</primary>
          </indexterm>
        </listitem>
      </varlistentry>

      <varlistentry id="libkmod">
        <term><filename class="libraryfile">libkmod</filename></term>
        <listitem>
          <para>这个库被其他程序用于加载和卸载内核模块</para>
          <indexterm zone="ch-system-kmod">
            <primary sortas="c-libkmod">libkmod</primary>
          </indexterm>
        </listitem>
      </varlistentry>

    </variablelist>

  </sect2>

</sect1>

