Under Linux and UNIX each and every hardware device treated as a file. A device file allows to accesses hardware devices so that end users do not need to get technical details about hardware.
In short, a device file (also called as a special file) is an interface for a device driver that appears in a file system as if it were an ordinary file. This allows software to interact with the device driver using standard input/output system calls, which simplifies many tasks.
Device file two types
There are two types of device files based upon how data written to them and read from them is processed by the operating system and hardware:
- Character special files or Character devices
- Block special files or Block devices
Understanding Character special files or Character devices
- Talks to devices in a character by character (1 byte at a time)
- Examples: Virtual terminals, terminals and serial modems etc
Understanding Block special files or Block devices
- Talks to devices 1 block at a time ( 1 block = 512 bytes to 32KB)
- Examples: Hard disk, DVD/CD ROM, and memory regions etc
Why use device files?
Device file allows transparent communication between user space applications and computer hardware.
Device file location
All device files are stored in /dev directory. Use cd and ls command to browse the directory:
cd /dev/
ls -l
How do I find out the device file type?
Simply use ls -l command:
ls -l /dev
Look for file's type in the first column output.
A character device is marked with a c as the first letter of the permissions strings.
$ ls -l /dev/console
A block device is marked with a b as the first letter of the permissions strings:
$ ls -l /dev/sdb1
分享到:
相关推荐
Access Control on a Device File 173 Quick Reference 179 7. Time, Delays, and Deferred Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 Measuring Time Lapses 183 Knowing ...
The Linux Device Model Memory Barriers Power Management Looking at the Sources Chapter 5. Character Drivers Char Driver Basics Device Example: System CMOS Sensing Data Availability Talking to ...
Linux usb gadget 驱动 刘洪涛老师的讲稿,详细整理过的资源。转换为pdf版本。 linux从设备驱动开发的参考资源不多,这是非常好的参考资料。
结合实验代码device_create ()详解
Device Tree Source File for embedded linux
Prentice.Essential Linux Device Drivers.2008 一个老外写的,写的非常详细 Chapter 1. Introduction Evolution The GNU Copyleft Kernel.org Mailing Lists and Forums Linux Distributions Looking at ...
PenMount Device Driver for Linux This file contains information about the open source version of PenMount device driver for Linux.
shared memory, message queues, semaphores, POSIX, file handling, sockets, and more Provides detailed discussion of scripting and integration with the GNU/Linux environment with bash, including ...
Linux File System Concepts Section 9.2. ext2 Section 9.3. ext3 Section 9.4. ReiserFS Section 9.5. JFFS2 Section 9.6. cramfs Section 9.7. Network File System Section 9.8. Pseudo File Systems Section ...
通常编写linux 字符设备常接触到的file_operations 以及miscdevice,然后申请设备号, 注册字符设备,没有涉及到设备驱动模型,而驱动模型里,device_driver 根本没有涉及到 设备操作的函数、file_operations 等,...
sub funciton Open Directory /sys/class/scsi_device/0:0:0:0/device/block Error:No such file or directory get name return:0,disk name:sdb1 # 因为有的USB设备会有好几个,比如把CD和U盘集成到一起,就会...
虚拟机备份转移后,网络启动异常,提示“SIOCSIFADDR: No such device” he problem lies in the fact that ethernet MAC addresses are cached. You need to remove a file to clear the cached value: ...
linux错误码 errno值 #define EPERM 1/* Not super-user */ #define ENOENT 2 /* No such file or directory */ #define ESRCH 3/* No such process */ #define EINTR 4/* Interrupted system call */ #...
Chapter 8 Device Driver Basics Chapter 9 File Systems Chapter 10 MTD Subsystem Chapter 11 BusyBox Chapter 12 Embedded Development Environment Chapter 13 Development Tools Chapter 14 Kernel Debugging ...
然后介绍Device Tree的语法格式, 让你能看懂一个device tree source file, 并修改这个file. 然后介绍如何把人能读懂的device tree source file编译成机器能读懂的device tree binary file. 最后介绍内核是如何解析...
The Device File Abstraction 224 Kernel Events 238 Ignoring Kernel Protections 239 Internal Kernel Interfaces 243 The Kernel API 243 The kernel ABI 244 Summary 245 Chapter 9: Linux Kernel Modules 247 ...
Writing from the embedded developer's viewpoint, he thoroughly addresses issues ranging from kernel building and initialization to bootloaders, device drivers to file systems. Hallinan thoroughly ...
rootroot@cm-System-Product-Name:/home/wwt/linux_r16$ tar zxvf lichee_parrotv1.1_20161202.tar.gz rootroot@cm-System-Product-Name:/home/wwt/linux_r16$ rootroot@cm-System-Product-Name:/home/wwt/linux_...
Opening a Block Device File Chapter 15. The Page Cache Section 15.1. The Page Cache Section 15.2. Storing Blocks in the Page Cache Section 15.3. Writing Dirty Pages to Disk Section 15.4. The sync( ...
linux-dts linux-device-driver