1 | <sect1 id="ch-system-MAKEDEV" xreflabel="Make_devices">
|
---|
2 | <title>Creating devices with Make_devices-&makedev-version;</title>
|
---|
3 | <?dbhtml filename="makedevices.html" dir="chapter06"?>
|
---|
4 |
|
---|
5 | <para>The Make_devices package contains a script for creating device
|
---|
6 | nodes.</para>
|
---|
7 |
|
---|
8 | <screen>&buildtime; &makedev-time;
|
---|
9 | &diskspace; &makedev-compsize;</screen>
|
---|
10 |
|
---|
11 | &aa-makedev-down;
|
---|
12 | &aa-makedev-dep;
|
---|
13 |
|
---|
14 | <sect2><title> </title><para> </para></sect2>
|
---|
15 |
|
---|
16 | <sect2>
|
---|
17 | <title>Making devices</title>
|
---|
18 |
|
---|
19 | <para>Note that unpacking the
|
---|
20 | <filename>make_devices-&makedev-version;.bz2</filename> file doesn't
|
---|
21 | create a directory for you to <command>cd</command> into, as the file
|
---|
22 | contains only a shell script.</para>
|
---|
23 |
|
---|
24 | <para>Install the <filename>make_devices</filename> script:</para>
|
---|
25 |
|
---|
26 | <screen><userinput>bzcat make_devices-&makedev-version;.bz2 > /dev/make_devices
|
---|
27 | chmod 754 /dev/make_devices</userinput></screen>
|
---|
28 |
|
---|
29 | <para>Device nodes are special files: things that can generate or receive data.
|
---|
30 | They usually correspond to physical pieces of hardware. Device nodes can be
|
---|
31 | created by issuing commands of the form: <command>mknod -m mode name type major
|
---|
32 | minor</command>. In such a command, <emphasis>mode</emphasis> is the usual
|
---|
33 | octal read/write/execute permissions triplet, and <emphasis>name</emphasis> is
|
---|
34 | the name of the device file to be created. It may seem surprising, but the
|
---|
35 | device name is actually arbitrary, except that most programs rely on devices
|
---|
36 | such as <filename>/dev/null</filename> having their usual names. The remaining
|
---|
37 | three parameters tell the kernel what device the node
|
---|
38 | actually refers to. The <emphasis>type</emphasis> is a letter, either b or c,
|
---|
39 | indicating whether the device is accessed in blocks (such as a hard disk) or
|
---|
40 | character by character (such as the console). And <emphasis>major</emphasis>
|
---|
41 | and <emphasis>minor</emphasis> are numbers, together forming a code that
|
---|
42 | identifies the device to the kernel. A list of the currently assigned device
|
---|
43 | numbers for Linux can be found in the file <filename>devices.txt</filename> in
|
---|
44 | the <filename class="directory">Documentation</filename> subdirectory of the
|
---|
45 | kernel sources.</para>
|
---|
46 |
|
---|
47 | <para>Note that the same major/minor combination is usually assigned to both a
|
---|
48 | block and a character device. These are, however, completely unrelated devices
|
---|
49 | that cannot be interchanged. A device is identified by the type/major/minor
|
---|
50 | triple, not just the major/minor pair, so when creating a device node it is
|
---|
51 | important to choose the correct <emphasis>type</emphasis> of device.</para>
|
---|
52 |
|
---|
53 | <para>Because looking up the type/major/minor triples and using
|
---|
54 | <command>mknod</command> manually is tedious and error-prone, the
|
---|
55 | <filename>make_devices</filename> script has been created. It contains a whole
|
---|
56 | series of <command>mknod</command> commands, one for each device, complete with
|
---|
57 | recommended name, permissions and group assignment. It has been set up so that
|
---|
58 | only a minimal set of commonly used devices is enabled and the other lines are
|
---|
59 | commented out. You should open <filename>make_devices</filename> in an editor
|
---|
60 | and customize it to your needs. This takes some time, but is very simple. When
|
---|
61 | you are satisfied, run the script to create the device files:</para>
|
---|
62 |
|
---|
63 | <screen><userinput>cd /dev
|
---|
64 | ./make_devices</userinput></screen>
|
---|
65 |
|
---|
66 | <para>If you had success with mounting the devpts file system earlier in <xref
|
---|
67 | linkend="ch-system-proc"/>, you can continue with the next section. If you were
|
---|
68 | unable to mount devpts, you will have to create a few static ptyXX and ttyXX
|
---|
69 | device nodes instead. To do this, open <filename>make_devices</filename> in
|
---|
70 | your editor, go to the section "Pseudo-TTY masters" and enable a few ptyXX
|
---|
71 | devices -- a handful are enough to enable the test suites to run, but if you
|
---|
72 | plan to run a kernel without devpts support you will probably need many more
|
---|
73 | (every xterm, ssh connection, telnet connection, and the like, uses one of
|
---|
74 | these pseudo terminals). In the immediately following section "Pseudo-TTY
|
---|
75 | slaves", enable the corresponding ttyXX devices. When you are done, rerun
|
---|
76 | <command>./make_devices</command> from inside <filename>/dev</filename> to
|
---|
77 | have it create the new devices.</para>
|
---|
78 |
|
---|
79 | </sect2>
|
---|
80 |
|
---|
81 | &aa-makedev-shortdesc;
|
---|
82 | &aa-makedev-desc;
|
---|
83 |
|
---|
84 | </sect1>
|
---|
85 |
|
---|