linux系统下的设备有:
1. 字符设备,无缓冲并且只能顺序存取;
2. 块设备,有缓存并且可以随机存取。
每个设备都有主设备号和次设备号组合起来唯一标识一个设备,
其中主设备号相同的设备是同类型设备,它们使用同样的驱动程序进行驱动。
由于linux系统把设备都抽象成文件,所以可以通过查看/dev/目录来查看系统中的各个设备。
sh-# ls -l /dev/sda
brw-r--r-- 1 root root 8, 0 Oct 10 03:04 /dev/sda
sh-# ls -l /dev/sda1
brw-r--r-- 1 root root 8, 1 Oct 10 03:04 /dev/sda1
sh-# ls -l /dev/null
crw-r--r-- 1 root root 1, 3 Oct 10 03:04 /dev/null
sh-# ls -l /dev
total 0
crw-r--r-- 1 root root 5, 1 Oct 11 01:23 console
drwxr-xr-x 2 root root 24 Oct 10 03:04 fb
brw-r--r-- 1 root root 7, 0 Oct 10 03:04 loop0
crw-r--r-- 1 root root 249, 0 Oct 10 03:04 mali
crw-r--r-- 1 root root 1, 1 Oct 10 03:04 mem
crw-r--r-- 1 root root 1, 3 Oct 10 03:04 null
crw-r--r-- 1 root root 1, 4 Oct 10 03:04 port
crw-r--r-- 1 root root 5, 2 Oct 10 03:04 ptmx
drwxr-xr-x 2 root root 60 Oct 10 03:04 pts
brw-r--r-- 1 root root 1, 0 Oct 10 03:04 ram0
brw-r--r-- 1 root root 1, 1 Oct 10 03:04 ram1
crw-r--r-- 1 root root 1, 8 Oct 10 03:04 random
brw-r--r-- 1 root root 8, 0 Oct 10 03:04 sda
brw-r--r-- 1 root root 8, 1 Oct 10 03:04 sda1
brw-r--r-- 1 root root 8, 10 Oct 10 03:04 sda10
brw-r--r-- 1 root root 8, 11 Oct 10 03:04 sda11
brw-r--r-- 1 root root 8, 12 Oct 10 03:04 sda12
brw-r--r-- 1 root root 8, 13 Oct 10 03:04 sda13
brw-r--r-- 1 root root 8, 14 Oct 10 03:04 sda14
brw-r--r-- 1 root root 8, 15 Oct 10 03:04 sda15
brw-r--r-- 1 root root 8, 2 Oct 10 03:04 sda2
brw-r--r-- 1 root root 8, 3 Oct 10 03:04 sda3
brw-r--r-- 1 root root 8, 4 Oct 10 03:04 sda4
brw-r--r-- 1 root root 8, 5 Oct 10 03:04 sda5
brw-r--r-- 1 root root 8, 6 Oct 10 03:04 sda6
brw-r--r-- 1 root root 8, 7 Oct 10 03:04 sda7
brw-r--r-- 1 root root 8, 8 Oct 10 03:04 sda8
brw-r--r-- 1 root root 8, 9 Oct 10 03:04 sda9
brw-r--r-- 1 root root 65, 160 Oct 10 03:04 sdaa
brw-r--r-- 1 root root 65, 176 Oct 10 03:04 sdab
brw-r--r-- 1 root root 65, 192 Oct 10 03:04 sdac
brw-r--r-- 1 root root 65, 208 Oct 10 03:04 sdad
brw-r--r-- 1 root root 65, 224 Oct 10 03:04 sdae
brw-r--r-- 1 root root 65, 240 Oct 10 03:04 sdaf
brw-r--r-- 1 root root 8, 16 Oct 10 03:04 sdb
brw-r--r-- 1 root root 8, 17 Oct 10 03:04 sdb1
brw-r--r-- 1 root root 8, 26 Oct 10 03:04 sdb10
brw-r--r-- 1 root root 8, 27 Oct 10 03:04 sdb11
brw-r--r-- 1 root root 8, 28 Oct 10 03:04 sdb12
brw-r--r-- 1 root root 8, 29 Oct 10 03:04 sdb13
brw-r--r-- 1 root root 8, 30 Oct 10 03:04 sdb14
brw-r--r-- 1 root root 8, 31 Oct 10 03:04 sdb15
brw-r--r-- 1 root root 8, 18 Oct 10 03:04 sdb2
brw-r--r-- 1 root root 8, 19 Oct 10 03:04 sdb3
brw-r--r-- 1 root root 8, 20 Oct 10 03:04 sdb4
brw-r--r-- 1 root root 8, 21 Oct 10 03:04 sdb5
brw-r--r-- 1 root root 8, 22 Oct 10 03:04 sdb6
brw-r--r-- 1 root root 8, 23 Oct 10 03:04 sdb7
brw-r--r-- 1 root root 8, 24 Oct 10 03:04 sdb8
brw-r--r-- 1 root root 8, 25 Oct 10 03:04 sdb9
brw-r--r-- 1 root root 67, 64 Oct 10 03:04 sdba
brw-r--r-- 1 root root 67, 80 Oct 10 03:04 sdbb
brw-r--r-- 1 root root 67, 96 Oct 10 03:04 sdbc
brw-r--r-- 1 root root 67, 112 Oct 10 03:04 sdbd
brw-r--r-- 1 root root 67, 128 Oct 10 03:04 sdbe
brw-r--r-- 1 root root 67, 144 Oct 10 03:04 sdbf
crw-r--r-- 1 root root 5, 0 Oct 10 03:04 tty
crw-r--r-- 1 root root 4, 0 Oct 10 03:04 tty0
crw-r--r-- 1 root root 4, 1 Oct 10 03:04 tty1
crw-r--r-- 1 root root 1, 9 Oct 10 03:04 urandom
crw-r--r-- 1 root root 1, 5 Oct 10 03:04 zero
sh-#
下面命令用来查看当前系统中已经加载的设备驱动程序的主设备号,
sh-# cat /proc/devices
Character devices:
1 mem
5 /dev/tty
5 /dev/console
5 /dev/ptmx
29 fb
128 ptm
136 pts
180 usb
189 usb_device
Block devices:
259 blkext
7 loop
8 sd
65 sd
66 sd
67 sd
68 sd
69 sd
70 sd
71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
251 fbm
sh-#
待确认问题:
为什么系统中有一个设备时,会自动分配到/dev/sda1下?
sh-# fdisk -l
Disk /dev/sda: 4002 MB, 4002910208 bytes
32 heads, 63 sectors/track, 3878 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3878 3908992+ 7 HPFS/NTFS
sh-#
sh-# mount -t vfat /dev/sda2 /mnt/usb/sda1
mount: /dev/sda2 is not a valid block device
sh-# fdisk -l
Disk /dev/sda: 4002 MB, 4002910208 bytes
32 heads, 63 sectors/track, 3878 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3878 3908992+ 7 HPFS/NTFS
Disk /dev/sdb: 8010 MB, 8010194944 bytes
32 heads, 63 sectors/track, 7760 cylinders
Units = cylinders of 2016 * 512 = 1032192 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 7760 7822048+ b Win95 FAT32
sh-#
sh-# mount -t vfat /dev/sdb1 /mnt/usb/sda1/
分享到:
相关推荐
Linux设备驱动程序学习(12)-Linux设备模型(底层原理简介) - Linux设备驱动程序
Linux设备驱动程序学习(14)-Linux设备模型(各环节的整合) - Linux设备驱动程序
Linux 设备驱动程序学习(0) -设备驱动介绍& Hello, world!模块 模块结构介绍 字符设备驱动程序 调试技术 并发和竞态 高级字符驱动程序操作 阻塞型 I/O 和休眠
《linux设备驱动程序》(第三版)的学习笔记,对于学习设备驱动的朋友十分有用
Linux设备驱动程序学习(11)-中断处理 - Linux设备驱动程序
Linux设备驱动程序学习(1)-字符设备驱动程序 ·Linux设备驱动程序学习(0)-Hello, world!模块 ·Linux设备驱动程序学习(2)-调试技术 ·Linux设备驱动程序学习(3)-并发和竞态 ·Linux设备驱动程序学习(4)-...
Linux设备驱动程序学习(8)-分配内存 - Linux设备驱动程序
Linux设备驱动程序学习(0)-Hello, world!模块 - Linux设备驱动程序
Linux设备驱动程序学习(1)-字符设备驱动程序 - Linux设备驱动程序
Linux设备驱动程序学习(13)-Linux设备模型(总线、设备、驱动程序和类) - Linux设备驱动程序
【批量下载】108-Linux设备驱动程序学习-170页,多本书籍
学习 linux 设备驱动编程 的经典 教材!
比较系统地讲解了设备树的引入过程,并给出了内核代码的分析。
·Linux设备驱动程序学习(1)-字符设备驱动程序 ·Linux设备驱动程序学习(0)-设备驱动介绍& Hello, world!模块 ·Linux设备驱动程序学习(2)-调试技术 ·Linux设备驱动程序学习(3)-并发和竞态 ·Linux设备...
Linux设备驱动程序学习教程-170页-pdf版,很不错的教程
Linux设备驱动程序学习(15)-Linux设备模型(热插拔、mdev 与 firmware) - Linux设备驱动程序
Linux设备驱动程序学习(3-补)-Linux中的循环缓冲区 - Linux设备驱动程序
主要通过介绍字符设备scull(Simple Character Utility for Loading Localities,区域装载的简单字符工具)的驱动程序编写,来学习Linux设备驱动的基本知识。scull可以为真正的设备驱动程序提供样板。
Linux设备驱动程序学习(7)-内核的数据类型 - Linux设备驱动程序
Linux设备驱动程序学习总结: *字符设备驱动程序 *调试技术 *并发和竞态 *Linux中的循环缓冲区 *内核的数据类型 *分配内存 *与硬件通信 *时间、延迟及延缓操作 *中断处理 *Linux设备模型