`
king_tt
  • 浏览: 2083385 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

linux根文件系统/etc/mdev.conf文件详解

 
阅读更多

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
fi

文章转自:http://www.cnblogs.com/hnrainll/archive/2011/06/25/2090182.html

分享到:
评论

相关推荐

    busybox 中的mdev.txt中文版.pdf

    在linux中。busybox是一个必不可少的好工具, 而他mdev确实创建设备文件的利器,特此对busybox下的mdev进行了翻译,写了他使用说明中文版

    U盘自动挂载.txt

    嵌入式ARM LinuxU盘自动挂载 sd[a-z][0-9] 0:0 666 @(/etc/hotplug/insert.sh $MDEV $SUBSYSTEM) sd[a-z] 0:0 666 $(/etc/hotplug/remove.sh $MDEV $SUBSYSTEM) ub[a-z][0-9] 0:0 666 @(/etc/hotplug/insert.sh $...

    fs_mini_mdev_1.21.0.rar_TQ2440 文件系统_fs_mini_mdev.yaffs2

    适用于TQ2440的yaffs2文件系统

    linux全志R16的linux系统编译的资料_20170502_1655.7z

    d/buildroot-config/conf.o /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/buildroot-config/zconf.tab.o -o /home/wwt/linux_r16/lichee/out/sun8iw5p1/linux/common/buildroot/build/...

    最新版busybox-1.19.4

    8、创建一个空的mdev.conf文件,在挂载根文件系统时会用到的 [root@Sure etc]# touch mdev.conf 9、从本机拷贝passwd、shadow、group文件。 [root@Sure etc]# cp /etc/passwd . [root@Sure etc]# cp /etc/...

    使用mdev来实现arm linux自动识别挂载sd卡,支持热插拔

    使用mdev来实现arm linux自动识别并挂载sd卡,添加对热插拔事件的响应,实现U盘和SD卡的自动挂载。

    嵌入式Linux开发环境.

    3.2 将自己定制的根文件系统下载到开发板运行 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.3 设置开发板的...

    nfs_root.rar_Qtopia_ROOT_linux nfs ro_最小文件系统_根文件

    里面是Linux的4个根文件系统,对应4个子目录: ① 最小的根文件系统fs_mini; ② 使用mdev机制的最小根文件系统fs_mini_mdev; ③ 含有qtopia图形程序的根文件系统fs_qtopia; ④ 含有X Window图形程序的根文件...

    mdev.yaffs

    用busybox 1.20制作的yaffs根文件系统

    houplugSDCard

    将mdev.conf放到/etc下,另外一个文件放到bin目录下即可直接使用

    Linux最小根文件系统支持自动挂载U盘TF卡

    Linux最小根文件系统支持自动挂载U盘TF卡。通过 mdev 工具实现 U 盘和 SD/TF 卡的自动挂载。

    qt基础教程

    2.4.7 mdev.cof ...................................................................................... 8 2.4.8 resolv.conf .................................................................................

    linux启动优化:mdev -s.docx

    linux启动优化:mdev -s.docx

    nfs_root.rar_ROOT_内核目录

    里面是Linux的4个根文件系统,对应4个子目录: ① 最小的根文件系统fs_mini; ② 使用mdev机制的最小根文件系统fs_mini_mdev; ③ 含有qtopia图形程序的根文件系统fs_qtopia; ④ 含有X Window图形程序的根文件...

    linux下的mdev用法

    该文件详细讲述了嵌入式mdev的配置及用法

    linux mdev porting guide

    在 Linux的嵌入式系统中我们经常用到U盘、tf卡的挂载,而每次都手动挂载或卸载非常麻烦,我们可以使用mdev来实现自动挂载或卸载U盘、tf卡。 mdev是busybox自带的一个简化版的udev,适合于嵌入式的应用场合

    fs_mini_mdev_new.tar.bz2

    稍微简便一点的根文件系统,短小精悍,很强大。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

    Python库 | mdev-0.0.7.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:mdev-0.0.7.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Linux热插拔及mdev机制

    就是由内核来启动一个用户进程,通过filter判断kset中的内核对象状态改变是否需要通知到用户层

    系统及数据库备份.doc

    备份策略 1 OS系统文件和操作系统备份 以下是系统文件的备份策略: 以下是操作系统的备份策略: 2 数据库归档日志和控制文件备份 以下是归档日志和控制文件备份策略: 3 数据库数据文件备份 以下是数据文件备份策略...

Global site tag (gtag.js) - Google Analytics