<chapter id="device-list">
<title>Hardware, Devices, and Tools</title>

	<blockquote><para><quote>Knowledge speaks, but wisdom listens.</quote> 
	Jimi Hendrix</para></blockquote>

<para>This chapter gives an overview of what a device file is, and how to
create one.  The canonical list of device files is
<filename>/usr/src/linux/Documentation/devices.txt</filename>
<indexterm id="ch04-kern-dev"><primary>kernel</primary><secondary>devices</secondary>
</indexterm> if you have
the Linux kernel source code installed on your system.  The devices listed
here are correct as of kernel version 2.6.8.</para>

<sect1 id="hwutils">
<title>Hardware Utilities </title>

<sect2 id="makedev">
<title>The <command>MAKEDEV</command><indexterm id="ch04-makedev">
	<primary>commands</primary><secondary>MAKEDEV</secondary> 
	</indexterm> Script</title>

        <para>Most device files will already be created and will be there
	ready to use after you install your Linux system.  If by some chance
	you need to create one which is not provided then you should first
	try to use the <command>MAKEDEV</command> script.  This script is
	usually located in <filename>/dev/MAKEDEV</filename> but might also
	have a copy (or a symbolic link) in
	<filename>/sbin/MAKEDEV</filename>.  If it turns out not to be in
	your path then you will need to specify the path to it
	explicitly.</para>
	
	<para>In general the command is used as:
	
	<screen>
	<prompt>#</prompt> <userinput>/dev/MAKEDEV -v ttyS0</userinput>
	<computeroutput>create ttyS0   c 4 64 root:dialout 0660</computeroutput>
	</screen>

	This will create the device file <filename>/dev/ttyS0</filename>
	<indexterm id="ch04-ttys0"><primary>filesystem</primary>
	<secondary>/dev</secondary><tertiary>/dev/ttyS0</tertiary></indexterm>
	with major node 4 and minor node 64 as a character device with
	access permissions 0660 with owner root and group dialout.</para>

	<para><filename>ttyS0</filename> is a serial port.  The major and
	minor node numbers are numbers understood by the kernel.  The kernel
	refers to hardware devices as numbers, this would be very difficult
	for us to remember, so we use filenames.  Access permissions of 0660
	means read and write permission for the owner (root in this case)
	and read and write permission for members of the group (dialout in 
	this case) with no access for anyone else.</para>
</sect2>

<sect2 id="mknod">
<title>The <command>mknod</command><indexterm id="ch04-mknod">
        <primary>commands</primary><secondary>mknod</secondary>
        </indexterm> command</title>

	<para><command>MAKEDEV</command><indexterm id="ch04-makedev2">
        <primary>commands</primary><secondary>MAKEDEV</secondary>
        </indexterm> is the preferred way of creating
	device files which are not present.  However sometimes the
	<command>MAKEDEV</command> script will not know about the device
	file you wish to create.  This is where the <command>mknod</command>
	command comes in.  In order to use <command>mknod</command> you need
	to know the major and minor node numbers for the device you wish to
	create.  The <filename>devices.txt</filename><indexterm id="kern-doc">
	<primary>kernel</primary><secondary>documentation</secondary>
	<tertiary>devices.txt</tertiary></indexterm> file in the kernel
	source documentation is the canonical source of this
	information.</para>

	<para>To take an example, let us suppose that our version of the
	<command>MAKEDEV</command><indexterm id="ch04-makedev3">
        <primary>commands</primary><secondary>MAKEDEV</secondary>
        </indexterm> script does not know how to create the
	<filename>/dev/ttyS0</filename><indexterm id="ch04-ttys02">
	<primary>filesystem</primary><secondary>/dev</secondary>
        <tertiary>/dev/ttyS0</tertiary></indexterm> device file.  We need 
	to use <command>mknod</command><indexterm id="ch04-mknod2">
        <primary>commands</primary><secondary>mknod</secondary>
        </indexterm> to create it.  We know from looking at the
	<filename>devices.txt</filename><indexterm id="kern-doc2">
        <primary>kernel</primary><secondary>documentation</secondary>
        <tertiary>devices.txt</tertiary></indexterm> that it should be a character
	device with major number 4 and minor number 64.  So we now know all
	we need to create the file.

        <screen>
	<prompt>#</prompt> <userinput>mknod /dev/ttyS0 c 4 64</userinput>
	<prompt>#</prompt> <userinput>chown root.dialout /dev/ttyS0</userinput>
	<prompt>#</prompt> <userinput>chmod 0644 /dev/ttyS0</userinput>
	<prompt>#</prompt> <userinput>ls -l /dev/ttyS0</userinput>
	<computeroutput>
	crw-rw----   1 root dialout    4,   64 Oct 23 18:23 /dev/ttyS0
	</computeroutput> 
	</screen>

	As you can see, many more steps are required to create the file.  In
	this example you can see the process required however.  It is
	unlikely in the extreme that the ttyS0 file would not be provided by
	the <command>MAKEDEV</command><indexterm id="ch04-makedev4">
        <primary>commands</primary><secondary>MAKEDEV</secondary>
        </indexterm> script, but it suffices to illustrate
	the point.</para>
</sect2> 

<sect2 id="lspci">
<title>The <command>lspci</command><indexterm id="ch04-lspci">
        <primary>commands</primary><secondary>lspci</secondary>
        </indexterm>  command</title>
	
	<para>lspci</para>

	<para>TO BE ADDED</para>

</sect2>

<sect2 id="lsdev">
<title>The <command>lsdev</command><indexterm id="ch04-lsdev">
        <primary>commands</primary><secondary>lsdev</secondary>
        </indexterm>  command</title>
	
	<para>lsdev</para>

	<para>TO BE ADDED</para>

</sect2>

<sect2 id="lsusb">
<title>The <command>lsusb</command><indexterm id="ch04-lsusb">
        <primary>commands</primary><secondary>lsusb</secondary>
        </indexterm>  command</title>
	
	<para>lsusb</para>

	<para>TO BE ADDED</para>

</sect2>

<sect2 id="lsraid">
<title>The <command>lsraid</command><indexterm id="ch04-lsraid">
        <primary>commands</primary><secondary>lsraid</secondary>
        </indexterm>  command</title>
	
	<para>lsraid</para>

	<para>TO BE ADDED</para>

</sect2>

<sect2 id="hdparm">
<title>The <command>hdparm</command><indexterm id="ch04-hdparm">
        <primary>commands</primary><secondary>hdparm</secondary>
        </indexterm>  command</title>
	
	<para>hdparm</para>

	<para>TO BE ADDED</para>

</sect2>

<sect2 id="more-hwresources">
<title>More Hardware Resources</title>

	<para>More information on what hardware resources the kernel is using
	can be found in the <filename>/proc</filename> directory.  Refer to 
	<xref linkend="proc-fs"> in chapter 3.
	</para>
</sect2>
</sect1>

<sect1>
<title>Kernel Modules<indexterm id="ch04-modules"><primary>kernel</primary>
        <secondary>modules</secondary></indexterm></title>

	<para>This section will discuss kernel modules.</para>

	<para>TO BE ADDED</para>

<sect2>
<title>lsmod<indexterm id="ch04-lsmod1"><primary>commands</primary>
        <secondary>lsmod</secondary></indexterm><indexterm id="ch04-lsmod2">
	<primary>kernel</primary><secondary>modules</secondary>
        <tertiary>lsmod</tertiary></indexterm></title>

	<para>lsmod</para>

	<para>TO BE ADDED</para>
</sect2>

<sect2>
<title>insmod<indexterm id="ch04-insmod1"><primary>commands</primary>
        <secondary>insmod</secondary></indexterm><indexterm id="ch04-insmod2">
        <primary>kernel</primary><secondary>modules</secondary>
        <tertiary>insmod</tertiary></indexterm></title>

	<para>insmod</para>

	<para>TO BE ADDED</para>
</sect2>

<sect2>
<title>depmod<indexterm id="ch04-depmod1"><primary>commands</primary>
        <secondary>depmod</secondary></indexterm><indexterm id="ch04-depmod2">
        <primary>kernel</primary><secondary>modules</secondary>
        <tertiary>depmod</tertiary></indexterm></title>

	<para>depmod</para>

	<para>TO BE ADDED</para>
</sect2>

<sect2>
<title>rmmod<indexterm id="ch04-rmmod1"><primary>commands</primary>
        <secondary>rmmod</secondary></indexterm><indexterm id="ch04-rmmod2">
        <primary>kernel</primary><secondary>modules</secondary>
        <tertiary>rmmod</tertiary></indexterm></title>

	<para>rmmod</para>

	<para>TO BE ADDED</para>
</sect2>

<sect2>
<title>modprobe<indexterm id="ch04-modprobe1"><primary>commands</primary>
        <secondary>modprobe</secondary></indexterm><indexterm id="ch04-modprobe2">
        <primary>kernel</primary><secondary>modules</secondary>
        <tertiary>modprobe</tertiary></indexterm></title>

	<para>modprobe</para>

	<para>TO BE ADDED</para>
</sect2>

</sect1>
</chapter>
