# Introduction Devices in POSIX Systems are files in /dev directory. As with any files in POSIX, they may be opened, closed, read from, written to, seeked, ioctl'd, and others. Examples of device files: * /dev/sda - A SCSI block device * /dev/ttyS0 - A Serial terminal device # POSIX I/O calls POSIX systems have some standard calls for I/O. Since devices are files, these same system calls are used to work with devices. We are gonna work with the following calls: * open * read * write * close * lseek * ioctl # Device types and numbers Linux devices may be of different types, including character devices, block devices or network devices. Both character and block devices have identifying numbers, a major and a minor number. # Character devices allocation In Linux, major and minor numbers have to be requested or allocated. The calls to do that for character devices are: * int register\\_chrdev\\_region (dev\\_t first, unsigned int count, char *name); * int alloc\\_chrdev\\_region (dev\\_t *dev, unsigned int firstminor, unsigned int count, char *name); * void unregister\\_chrdev\\_region (dev\\_t dev, unsigned int count);