Section 14.8. Peripheral Devices


[Page 587 (continued)]

14.8. Peripheral Devices

Let's assume that you've just bought a new device and you wish to connect it to your system. For the system to be able to "talk to" a new device the hardware must be connected and the software must be installed or activated. If the device is already recognized by Linux (as is most common PC hardware), this may be simple. Some devices require that new drivers be loaded into the kernel and the kernel rebuilt, others may use dynamically loadable device drivers where the driver will be loaded into the kernel when the device is accessed. The basic steps of device installation are as follows:

1.

Install the device driver if it isn't currently in the kernel and loadable device drivers are not used.

2.

Determine the device's major and minor numbers.

3.

Use mknod to associate a filename in "/dev" with the new device.

Once the device driver is installed and the major and minor numbers are known, you must use mknod to create the special file (Figure 14-12).


[Page 588]

Figure 14-12. Description of the mknod command.

Utility: mknod fileName [ c] [ b ] majorNumber minorNumber

mknod fileName p

mknod creates the special file fileName in the file system. The first form of mknod allows a super-user to create either a character-oriented or block-oriented special file with the specified major and minor numbers. The major number identifies the class of the device, and the minor number identifies the instance of the device. The second form of mknod creates a named pipe, and may be used by anyone (or the mkfifo command may also be used).


In the following example, I installed the thirteenth instance of a terminal whose major number was 1:

$ mknod /dev/tty12 c 1 12  ...note the 13th instance is index 12. $ _ 


The "c" indicated that the terminal was a character-oriented device. In the next example, I installed the first instance of a disk drive whose major number was 2:

$ mknod /dev/dk1 b 2 0     ...note the 1st instance is index 0. $ _ 


The "b" indicated that the terminal was a block-oriented device.

Major and minor numbers are the fourth and fifth fields, respectively, in an "ls -lG" listing. In the following example, I obtained a long listing of the "/dev" directory:

$ ls -lG /dev     ...get a long listing of the device directory. crw--w--w-  1      root  1,  0 Feb 13 14:21 /dev/tty0 crw--w--w-  1      root  1,  1 Feb 13 14:27 /dev/tty1 brw--w--w-  1      root  2,  0 Feb 13 14:29 /dev/dk0 crw--w--w-  1      root  3,  0 Feb 13 14:27 /dev/rmt0 ... $ _ 





Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net