Difference between revisions of "Device"

From Hackepedia
Jump to navigationJump to search
(attempt at explanation of devices)
 
m
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
devices are found in /dev, there is block devices and character devices.  Block devices are also called cooked devices because character devices are also called raw devicesConfused yet?  Let's look at why there is block and character devices.  Terminals handle one character at a time so they are character devices. Tape drives handle data in blocks so they are a block device.
+
Devices are found in the /dev directory.  There are several types of devices:
 +
 
 +
* '''block devices''' -- A.K.A "cooked" devices.  Data stored on the device is typically accessed in groups, instead of one byte at a time.  Hard drives, tape systems, and other mass-storage devices are almost always block devices.  Data is more or less random-access (although performance may suffer greatly, as in the case of a tape).
 +
* '''character devices''' -- Data is usually managed in a streamSerial, audio, and most other non-storage devices fall into this category.
 +
* '''sockets''' -- File-like interfaces to network resources that open a [[ports|port]]
 +
* '''pipes''' -- A "named pipe."  See [[FIFO]]
 +
 
 +
 
 +
# ls -la /dev/
 +
[snip]
 +
brw-rw----  1 root disk      1,   9 2005-12-27 14:14 ram9
 +
crw-rw-rw-  1 root root      1,  8 2005-12-27 14:14 random
 +
[snip]
 +
 
 +
You can see the b and c for block vs character. You can use [[mknod]] to create a block or charcter device.

Latest revision as of 21:26, 16 March 2006

Devices are found in the /dev directory. There are several types of devices:

  • block devices -- A.K.A "cooked" devices. Data stored on the device is typically accessed in groups, instead of one byte at a time. Hard drives, tape systems, and other mass-storage devices are almost always block devices. Data is more or less random-access (although performance may suffer greatly, as in the case of a tape).
  • character devices -- Data is usually managed in a stream. Serial, audio, and most other non-storage devices fall into this category.
  • sockets -- File-like interfaces to network resources that open a port
  • pipes -- A "named pipe." See FIFO


# ls -la /dev/
[snip]
brw-rw----  1 root disk      1,   9 2005-12-27 14:14 ram9
crw-rw-rw-  1 root root      1,   8 2005-12-27 14:14 random
[snip]

You can see the b and c for block vs character. You can use mknod to create a block or charcter device.