Saturday, September 27, 2008

Linux Device Drivers: Device Types

Classes of Linux Devices

1. Character [CHAR] Devices
- Can be accessed as a stream of bytes 
- Normally MUST implement open, close, read and write functionalities
- Can be accessed ONLY Sequentially unlike a regular file where it is posssible to move back & forth. However there can be a workaround for this using mmap() and lseek operations
- Mapped to a node in the filesystem e.g. /dev/ttyS0
- examples : serial ports, text consoles

2. Block Devices
- normally capable of hosting a filesystem
- Mapped to a node in the filesystem 
- In most of UNIX systems, block devices can ONLY handle I/O operations that transfer one or more blocks.
- Linux allows block devices to be read and written to like char devices

3. Network Interfaces
- Normally a hardware interface but software interface can also exist e.g. the loopback
- Unlike char device it is NOT stream oriented
- not mapped to a node in filesystem
- instead of read and write , they support receieve and transmit operations

No comments: