Notes for Advanced Linux Programming 6. Devices
6. Devices
A device driver hides the hardware device’s communication
protocols from the operating system and allows the system to interact with the
device through a standardized interface.
Processes can communicate with a device driver via
file-like objects.
6.1 Device Types
A character device represents a hardware device that reads
or writes a serial stream of data bytes.
A block device represents a hardware device that reads or
writes data in fixed-size blocks.
6.2 Device Numbers
Linux identifies devices using two numbers: the major
device number and the minor device number.
The major device number specifies which driver the device
corresponds to.
Minor device numbers distinguish individual devices or
components controlled by a single driver.
The special entry /proc/devices lists major device numbers
corresponding to active device drivers currently loaded into the kernel.
[liuchao@localhost ~]$ cat /proc/devices
Character devices:
1
mem
4
/dev/vc/0
4
tty
4
ttyS
5
/dev/tty
5
/dev/console
5
/dev/ptmx
6
lp
7
vcs
10
misc
13
input
14
sound
21
sg
29
fb
99
ppdev
116 alsa
128 ptm
136 pts
180 usb
189 usb_device
216 rfcomm
254 pcmcia
Block devices:
1
ramdisk
1
ramdisk
2
fd
8
sd
9
md
22
ide1
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
253 device-mapper
254 mdp
6.3 Device Entries
Only superuser processes can create block and character
devices using the mknod command or the mknod system call.
To create a device using the mknod command
The first argument is the path of the entry in the file
system.
The second argument is b for a block device or c for a
character device.
Provide the major and minor device numbers as
相关文档:
昨天分别试用了一下Linux下和Windows下的IPv6 Ping,发现无法ping Link-local地址,百思不得其解,遂上网google一下,终于找到了原因。
Windows XP下的IPv6地址:
Ethernet adapter Test:
Connection-specific DNS Suffix . :
& ......
Linux LVM 的使用详解
摘要: Linux用户安装Linux操作系统时遇到的一个最常见的难以决定的问题就是如何正确地给评估各分区大小,以分配合适的硬盘空间。而遇到出现某个分区空间耗尽时,解决的方法通常是使用符号链接,或者使用调整分区大小的工具(比如Patition Magic等),但这都只是暂时解决办法,没有根本解决问题。随着L ......
指令名称 : chmod
使用权限 : 所有使用者
使用方式 : chmod [-cfvR] [--help] [--version] mode file...
说明 : Linux/Unix 的档案调用权限分为三级 : 档案拥有者、群组、其他。利用 chmod 可以藉以控制档案如何被他人所调用。
参数 :
mode : 权限设定字串,格式如下 : [ugoa...][[+-=][rwxX]...][,...],其中
......
果然是过了好久,这次又准备开始学习linux了。系统的学习和在网上找点只言片语的了解果然是不一样的。看完这点章节,自己就再做做总结吧。
我大概了解下来是这样的。对于linux的文件系统来说,下面有很多“文件”,这些“文件”包括了设备、磁盘驱动器等等。比如"\"表示根目录,而\user是用来装整个操 ......