精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>电脑技术>>● FreeBSD>>网络书籍>>中文HandBook>>Make device nodes

主题:Make device nodes
发信人: highwaywj()
整理人: hahalee(1999-03-17 22:50:02), 站内信件
不好意思,又把handbook翻了一小段.因为自己也是FREEBSD初初手,
很多东西自己并不明了,如有误人之嫌,以后我就不做了,免误他人.

Make device nodes
    翻译   汪骏
    [email protected]

        几乎所有的设备在/dev中都有一个对应的"node"入口.这些
node看起来象正规的文件,但是实际上它进入内核的入口.程序通过
它来存取设备.但你第一次装OS时.脚本/dev/MAKEDEV将被执行.创建
所支持的几乎所有设备nodes,实际上它并不创建它们中的"全部".因此
当你加一些新设备支持时.检查(pay to)在此目录下是否有合适的入口,
如果没有,添加它们.这儿有一个简单的例子.
假如你加一个IDE CD-ROM支持到内核,加的行是
controller wcd0
(译注:这一块我自己也不大懂,硬翻的,能否请有关高手讲解下)
这意味着在/dev中,你应该用启动wcd0来寻找一些入口.可能后面跟一个字母
如"c"或前面有一个字母"r",它意思是"raw"设备,它证明这些文件不是在这儿
我必须改变目录到/dev下. type
# sh MAKEDEV wcd0
但是脚本执行完以后,/dev中将有wcd0c和rwcd0c入口,说明它已执行成功.
对声卡命令:
# sh MAKEDEV snd0
 创建合适的入口
 注意,所有的scsi控制用/dev下一套同样的入口,你不必创建它们.同 样网卡
 和slip/ppp,虑设备(pseudo-devices) 在/dev中根本没有入口,所以你根本不必

 心这些.
 
 5.4. Making Device Nodes

Almost every device in the kernel has a corresponding ``node'' entry i
n the /dev directory. These nodes look
like regular files, but are actually special entries into the kernel w
hich programs use to access the device. The
shell script /dev/MAKEDEV, which is executed when you first install th
e operating system, creates nearly all of
the device nodes supported. However, it does not create all of them, s
o when you add support for a new
device, it pays to make sure that the appropriate entries are in this 
directory, and if not, add them. Here is a
simple example:

Suppose you add the IDE CD-ROM support to the kernel. The line to add 
is: 

    controller wcd0

This means that you should look for some entries that start with wcd0 
in the /dev directory, possibly followed
by a letter, such as `c', or preceded by the letter 'r', which means a
 `raw' device. It turns out that those files are
not there, so I must change to the /dev directory and type: 

    # sh MAKEDEV wcd0

When this script finishes, you will find that there are now wcd0c and 
rwcd0c entries in /dev so you know that
it executed correctly.

For sound cards, the command: 

    # sh MAKEDEV snd0

creates the appropriate entries. Note: when creating device nodes for 
devices such as sound cards, if other
people have access to your machine, it may be desirable to protect the
 devices from outside access by adding
them to the /etc/fbtab file. See man fbtab for more information.

Follow this simple procedure for any other non-GENERIC devices which d
o not have entries.

    Note: All SCSI controllers use the same set of /dev entries, so yo
u do not need to create these.
    Also, network cards and SLIP/PPP pseudo-devices do not have entrie
s in /dev at all, so you do
    not have to worry about these either. 

--
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.102.201.218]

[关闭][返回]