mdev的使用以及mdev.conf的规则配置--busybox

一下是我在网上看到别人写的一篇文章,这篇文章给我带来了很大的帮助,在好这里我分享出来,希望给你们带来帮助。

mdev是busybox下的udev的精简版,适合在嵌入式系统下管理设备

但mdev会把所有的设备文件都动态地创建在/dev/目录下,如果程序使用dev目录子目录下的设备,就必须修改程序,比较麻烦,当然也可以在mdev运行之后,手工创建子目录,然后再用 ln -s 做设备文件的软链接

这里有人作出了更好的脚本处理机制:

http://lists.busybox.net/pipermail/busybox/2007-May/027309.html

再贴上mdev的使用说明

-------------------------------------------

MDEV 入门(转)

Busybox-1.7.0/docs/mdev.txt
翻译:tekkamanninja Email: - 1 -

-------------
MDEV Primer
MDEV 入门
-------------
For those of us who know how to use mdev, a primer might seem lame. For
这份文档对于那些知道如何使用 mdev 的人看来可能有些肤浅。
everyone else, mdev is a weird black box that they hear is awesome, but can't
但对于其他人,mdev 可能是一个神秘的黑匣子,以至让人敬畏。
seem to get their head around how it works. Thus, a primer.
而这份文档又不足以让他们知道mdev 是如何工作的。 因此,这是一份入门文档。
-----------
Basic Use
基本使用方法
-----------
Mdev has two primary uses: initial population and dynamic updates. Both
mdev 有两个主要的应用:初始化对象和动态更新。
require sysfs support in the kernel and have it mounted at /sys. For dynamic
两个应用都需要内核 sysfs 的支持,且必须挂载到 /sys 。为了实现动态更新,
updates, you also need to have hotplugging enabled in your kernel.
你还必须在内核配置时增加热插拔支持(hotplugging)。
Here's a typical code snippet from the init script:
以下是系统初始化脚本中一个典型的使用mdev 的代码片段:
    [1] mount -t sysfs sysfs /sys
    [2] echo /bin/mdev > /proc/sys/kernel/hotplug
    [3] mdev -s

Of course, a more "full" setup would entail executing this before the previous
当然,一个对mdev 更完整的安装还必须在以上代码片段前执行下面的命令:
code snippet:
    [4] mount -t tmpfs mdev /dev
    [5] mkdir /dev/pts
    [6] mount -t devpts devpts /dev/pts

The simple explanation here is that [1] you need to have /sys mounted before
简单说明一下上面的代码:[1]你必须在执行mdev 前挂载 /sys 。
executing mdev. Then you [2] instruct the kernel to execute /bin/mdev whenever
随后你 [2] 命令内核在增删设备时执行 /bin/mdev ,
a device is added or removed so that the device node can be created or
使设备节点文件会被创建和删除。
destroyed. Then you [3] seed /dev with all the device nodes that were created
最后你 [3] 设置mdev,让它在系统启动时创建所有的设备节点。
while the system was booting.
For the "full" setup, you want to [4] make sure /dev is a tmpfs filesystem
而对mdev 更完整的安装,你必须[4]确保 /dev 是 tmpfs 文件系统
(assuming you're running out of flash). Then you want to [5] create the
(假设文件系统在 flash 外运行)。 而且你必须 [5] 创建

-------------
MDEV Config (/etc/mdev.conf)
MDEV 配置 (/etc/mdev.conf)
-------------
Mdev has an optional config file for controlling ownership/permissions of
device nodes if your system needs something more than the default root/root
660 permissions.
如果你的系统需要一些比默认的 root/root 660 更多的权限,
你可以使用 mdev 的可选配置文件,以控制设备节点的 所有者 和 权限。
The file has the format:
这个文件的格式如下:
    <device regex> <uid>:<gid> <octal permissions>
For example:
例如:
    hd[a-z][0-9]* 0:3 660
The config file parsing stops at the first matching line. If no line is
这个配置文件在第一个匹配行处停止解析。 如果没有匹配行,
matched, then the default of 0:0 660 is used. To set your own default, simply
那么就使用默认的 0:0 660 。 你也可以通过在最后创建如下的全匹配
create your own total match like so:
行,来设置你自己的默认设置:
    .* 1:1 777
If you also enable support for executing your own commands, then the file has
如果你想 mdev 在找到匹配行时可以执行自定义的命令,那么文件格式如下:
the format:
    <device regex> <uid>:<gid> <octal permissions> [<@|$|*> <command>]
The special characters have the meaning:
特殊字符的意义如下:
   @ Run after creating the device.
    @ 在创建设备节点后运行命令。
    $ Run before removing the device.
    $ 在删除设备节点前运行命令。
    * Run both after creating and before removing the device.
    * 在创建设备节点后和删除设备节点前都运行命令。
The command is executed via the system() function (which means you're giving a
这些命令是通过系统函数(system())执行的(也就是说你在对shell 下命令)
command to the shell), so make sure you have a shell installed at /bin/sh.
,所以请确保你已在 /bin/sh 安装了shell。
For your convenience, the shell env var $MDEV is set to the device name. So if
为了方便,shell 的环境变量 $MDEV 会被设置成设备名。 例如
the device 'hdc' was matched, MDEV would be set to "hdc".
mdev 解析到设备 'hdc' 匹配,MDEV 将会被设置为 "hdc"。

----------
FIRMWARE
固件
----------
Some kernel device drivers need to request firmware at runtime in order to
有些设备驱动程序在运行时,为了正确的初始化设备,需要上传固件。
properly initialize a device. Place all such firmware files into the
请将所有的固件文件放入
/lib/firmware/ directory. At runtime, the kernel will invoke mdev with the
/lib/firmware/ 目录。 在运行时,内核将会按固件文件名调用 mdev ,
filename of the firmware which mdev will load out of /lib/firmware/ and into
之后 mdev 会通过 sysfs 接口将固件从 /lib/firmware/
the kernel via the sysfs interface. The exact filename is hardcoded in the
装载到内核。 确定的文件名被固化在内核中,
kernel, so look there if you need to want to know what to name the file in
如有必要,你必须知道如何在用户空间命名这个文件。
userspace.

 

# cat /etc/mdev.conf

# system all-writable devices
full            0:0     0666
null            0:0     0666
ptmx            0:0     0666
random          0:0     0666
tty             0:0     0666
zero            0:0     0666

# console devices
tty[0-9]*       0:5     0660
vc/[0-9]*       0:5     0660

# serial port devices
s3c2410_serial0 0:5     0666    =ttySAC0
s3c2410_serial1 0:5     0666    =ttySAC1
s3c2410_serial2 0:5     0666    =ttySAC2
s3c2410_serial3 0:5     0666    =ttySAC3

# loop devices
loop[0-9]*      0:0     0660    =loop/

# i2c devices
i2c-0           0:0     0666    =i2c/0
i2c-1           0:0     0666    =i2c/1

# frame buffer devices
fb[0-9]         0:0     0666

# input devices
mice            0:0     0660    =input/
mouse.*         0:0     0660    =input/
event.*         0:0     0660    =input/
ts.*            0:0     0660    =input/

# rtc devices
rtc0            0:0     0644    >rtc
rtc[1-9]        0:0     0644

# misc devices
mmcblk0p1       0:0     0600    =sdcard  */bin/hotplug.sh
sda1            0:0     0600    =udisk   * /bin/hotplug.sh
vntwpa          1:1     777              * /bin/ltls.sh  //$MDEV 参数 为"usb-wifi" vntwpa  执行脚本ltls.sh
# .*            1:1     777              * /bin/ltls.sh

1-1.*           1:1     777              * /bin/llll

[root@FriendlyARM /mnt]# cat ltls.sh
#!/bin/sh

echo $MDEV    >  /dev/ttySAC0  // 有变化的设备 会在/dev产生 相应设备 如:1-1.1 /sys 下class或block下也会变化

echo $ACTION    >  /dev/ttySAC0 // 设备状态"remove"   "add"

#echo  - n  "enter your name:"
#read name

#echo "ltls  "  > /dev/ttySACO
if [ "$MDEV" = "vntwpa" ];then
        /bin/wifi-ltls
        echo "going to vntwpa " > /dev/ttySAC0
f

时间: 2024-08-01 13:35:24

mdev的使用以及mdev.conf的规则配置--busybox的相关文章

aws service network restart 恢复/etc/resolve.conf这个的配置,怎么不让它重写?

问题描述 awsservicenetworkrestart恢复/etc/resolve.conf这个的配置,怎么不让它重写?

LNMP下WordPress伪静态规则配置

更换了 VPS,就要开始给网站搬家,搬家出现的第一个问题就是 WordPress 的伪静态问题.新的VPS 采用了 LNMP 环境,安装的是 AMH 面板.之前使用的是LAMP环境的 Webmin,但是 Webmin 功能过于臃肿复杂,比较耗内存,而且Nginx 对比 Apache 更高效稳定.所以这次决定采用 LNMP 环境.虽说这样比较折腾,但是只有去折腾才会有意外的收获. Nignx 不支持 .htaccess 伪静态规则,需要修改 Nignx 相应的配置文件添加伪静态规则,以下记录了整个

iptables规则配置 增加、删除和修改命令

介绍 iptables 是与最新的 3.5 版本 Linux 内核集成的 IP 信息包过滤系统.如果 Linux 系统连接到因特网或 LAN.服务器或连接 LAN 和因特网的代理服务器, 则该系统有利于在 Linux 系统上更好地控制 IP 信息包过滤和防火墙配置. Iptables命令的管理控制选项 -A(append) 在指定链的末尾添加一条新的规则 -I (insert)在指定链中插入一条新规则,为指明插入位置 -D(delete)删除制定链里的某条规则 -R (replace)修改.替换

WordPress 伪静态规则配置(IIS/Apache/Nginx)

IIS伪静态规则 IIS 环境是 Windows 主机常用的服务器环境,新建一个 txt 文件,将下面的代码添加到文件中: [ISAPI_Rewrite] # Defend your computer from some worm attacks #RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O] # 3600 = 1 hour CacheClockRate 3600 RepeatLimit 32   # P

Nginx中wordpress伪静态规则配置

因为与apache规则有一些不一样,所以我们不能直接使用apache的wordpress规则了. 费话不说多直接上代码  代码如下 复制代码 [root@localhost ~]# cat /etc/nginx/wprw.conf rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last; if (!-e $request_filename) { rewrite ^.+?(/wp-.*) $1 last; rewrite ^.+

BAE3.0多站点app.conf文件的配置方法

今天把3个网站,其中一个CodeIgniter建的网站,和两个wordpres站点,全部搬到一个域名下面来了,又是颇费一番周折,最近总是喜欢折腾! 首先,这三个网站现在的域名是: http://你的域名 (wordpress) http://你的域名/tanteng/ (wordpress) http://你的域名/hongzhiban/ (CodeIgniter) 如果不是在BAE3.0的环境下,把其他站点直接搬过来,数据库表放到一起共用数据库,然后改下数据库连接配置,基本上就OK了. 但是在

DNS客户端/etc/resolv.conf文件的配置

DNS客户端(服务器不运行http://www.aliyun.com/zixun/aggregation/33800.html">BIND)使用/etc/resolv.conf文件设置DNS服务器和他们隶属的域名.这个文件通常有两列:第一列是一个关键词,第二列是一个数值,由逗号分隔开.请看表中关键词列表. /etc/resolv.conf中的关键词 关键词 值 Nameserver 你的名称服务器的IP地址.一个"nameserver"关键词只能有一个条目.如有 不只一

Ubuntu nginx 1.6.0 服务器 nginx.conf等相关配置

环境UBUNUT 14.04  nginx:nginx 1.6.0 内存:12G 呆狐狸.风来了 等有空了再添加 注释 nginx.conf user www www; #启动进程,通常设置成和cpu的数量相等 worker_processes 4; #错误日志文件 error_log /www/wwwLogs/nginx_error.log; pid /www/lanmps/nginx/logs/nginx.pid; worker_rlimit_nofile 5120; events { us

C#实现单据编号规则配置和自动生成

问题描述 先放一张图图片中可以看到对每种单据的编号的规则进行配置,然后在新建单据的时候根据规则自动生成编号我现在实现的功能跟这个类似,只是有个别的单据的编号是要根据某些表的某个字段值生成的,希望能提供一下思路最好是有demo谢谢 解决方案 解决方案二:你不是已经把做法说出来了吗?还要出来问.编号第一段根据不同的业务有不同的编码YY第二段是日期,也设置了日期的长度第三段是自增的,会有一张表来记录这个值这样不是已经算出来了吗你还要问什么解决方案三:这图上规则蛮清楚的啊,流水号怎么生成网上查下也是n多