Devices and Drivers

    user@linux:~$ ls /dev/*

The /dev Folder

The Linux file structure holds directories and files for devices such as keyboards, memory, printers, and more. Linux interacts with devices through passing data in the devices defined files. These files contain both text and block data, which is defined by the type and use case of the device.

Device Classification

Linux devices can be classified into block and data stream

Block Devices

Block type devices handle data in blocks in comparison to the text data handled in data stream. An example of a block device, are disks, which handle data in sets of 256 bytes. The easiest way to tell what a block device is running lsblk, or list block devices, in a terminal. The output of this file shows hard disks, flash drives, CD-ROMs, and similar devices.

Data Stream Devices

Data stream devices are more common than block devices. Data stream primarily refer to the stream of text data between devices, files and the shell. Data is unidirectional in these files. Data streams can be looked at as a flow of pipes. You can use a data streams to create an input and send that to an output, such as redirecting a command output into a file as an input. Treating data as files allows the easy flow of information.

Naming Conventions: * Input streams * stdin * Standard input stream: Text input * Output streams * stdout * Standard out: Text from the shell * stderr * Standard error: Command error messages

Drivers in Linux

Drivers in linux holds the jobs of allocation, initialization, declaration and registration of devices. Device drivers need allocating as they are statically defined, and need a permanent location to be accessed by the shell. Initialization of drivers creates the name, bus fields, and often the devclass. The process of initialization allows for drivers to properly communicate with the kernel. Driver declaration defines the names and functions of a driver. Registration of drivers define the structures the device uses. Drivers in Linux are seldom interacted with by the consumer, but a high level understanding can help explain the process of how communication occurs between the terminal and the kernel.


References

The Linux Kernel - Device Drivers

mjmwired.net - devices.txt

Opensource.com - Managing Devices in Linux

Opensource.com - Linux Data Streams

How-To Geek - What Are stdin, stdout, and stderr on Linux?

LinOxide - Command to List Block Device in Linux