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 LVM µÄʹÓÃÏê½â
ÕªÒª£º LinuxÓû§°²×°Linux²Ù×÷ϵͳʱÓöµ½µÄÒ»¸ö×î³£¼ûµÄÄÑÒÔ¾ö¶¨µÄÎÊÌâ¾ÍÊÇÈçºÎÕýÈ·µØ¸øÆÀ¹À¸÷·ÖÇø´óС£¬ÒÔ·ÖÅäºÏÊʵÄÓ²Å̿ռ䡣¶øÓöµ½³öÏÖij¸ö·ÖÇø¿Õ¼äºÄ¾¡Ê±£¬½â¾öµÄ·½·¨Í¨³£ÊÇʹÓ÷ûºÅÁ´½Ó£¬»òÕßʹÓõ÷Õû·ÖÇø´óСµÄ¹¤¾ß(±ÈÈçPatition MagicµÈ)£¬µ«ÕⶼֻÊÇÔÝʱ½â¾ö°ì·¨£¬Ã»Óиù±¾½â¾öÎÊÌâ¡£Ëæ×ÅL ......
ÊÇÒªÓм¸¸ö½×¶ÎµÄ¡£ ¿ªÊ¼¿´ulk,
ulk×îºÃµÄµØ·½¾ÍÊÇËûËù³«µ¼µÄѧϰ·½·¨ÌرðºÃ¡£µ±ÄãÏëѧϰij·½Ãæʱ£¬ÏÈ¿´Í·Îļþ£¬ÔÚû°Ñÿ¸öÊý¾Ý½á¹¹ÖеÄÿ¸öÊý¾ÝÔªËØŪÇå³þ֮ǰ²»Òª¿´ÊµÏÖ´úÂë¡£
¶ÁÍêÍ·Îļþ£¬Òâζ×ÅÆäÖеÄ×éÖ¯¹Øϵ¸ú±ðµÄµØ·½µÄÁªÏµ¾ÍÇå³þÁË£¬ÕâʱºòÄãÈ¥¿´ÊµÏֵĴúÂëÄã»á·¢ÏÖËûÒѾ×öµÄÕýÊÇÄãËùÏëµÄ¡£
¸ú×Åulk°ÑÕâЩ»ù±¾µ ......
“Sudo”ÊÇUnix/Linuxƽ̨ÉϵÄÒ»¸ö·Ç³£ÓÐÓõŤ¾ß£¬ËüÔÊÐíϵͳ¹ÜÀíÔ±·ÖÅä¸øÆÕͨÓû§Ò»Ð©ºÏÀíµÄ“ȨÀû”£¬ÈÃËûÃÇÖ´ÐÐһЩֻÓг¬¼¶Óû§»òÆäËûÌØÐíÓû§²ÅÄÜÍê³ÉµÄÈÎÎñ£¬±ÈÈ磺ÔËÐÐһЩÏñmount£¬halt£¬suÖ®ÀàµÄÃüÁ»òÕß±à¼Ò»Ð©ÏµÍ³ÅäÖÃÎļþ£¬Ïñ/etc/mtab£¬/etc/samba/smb.confµÈ¡£ÕâÑùÒÔÀ´£¬¾Í²»½ö¼õÉÙÁ ......
http://blog.csdn.net/dinitial/archive/2009/02/22/3923559.aspx
Gdb+gdbserver+insight»·¾³µÄ´î½¨
1. ÏÂÔØgdbÔ´´úÂë http://ftp.gnu.org/gnu/gdb/
2. ÅäÖð²×°gdb+gdbser
$ tar jxvf gdb-6.6.tar.bz2
$ cd x/gdb
$ ./configure --target=arm-linux --prefix ......
½¨Á¢ARM+LinuxÓ¦ÓóÌÐòµ÷ÊÔ»·¾³
Gdb+gdbserver+insight»·¾³µÄ´î½¨
1. ÏÂÔØgdbÔ´´úÂë http://ftp.gnu.org/gnu/gdb/
2. ÅäÖð²×°gdb+gdbser
$ tar jxvf gdb-6.6.tar.bz2
$ cd x/gdb
$ ./configure --target=arm-linux --prefix=/usr/lo ......