aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-02-14 13:20:29 +0000
committervapier <vapier@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-02-14 13:20:29 +0000
commit5b35105d59cf2b44394410564952762334bd2dfe (patch)
tree3c2eb0a95388b09437f6a0e839ba31bf2ff07ec2
parenteff633f958509cb5cfa336fae7e5d4915ae63f27 (diff)
downloadbusybox-w32-5b35105d59cf2b44394410564952762334bd2dfe.tar.gz
busybox-w32-5b35105d59cf2b44394410564952762334bd2dfe.tar.bz2
busybox-w32-5b35105d59cf2b44394410564952762334bd2dfe.zip
create a document for mdev so people dont have to rtfs
git-svn-id: svn://busybox.net/trunk/busybox@17885 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--docs/mdev.txt68
-rw-r--r--util-linux/Config.in36
2 files changed, 78 insertions, 26 deletions
diff --git a/docs/mdev.txt b/docs/mdev.txt
new file mode 100644
index 000000000..51c3f0ed1
--- /dev/null
+++ b/docs/mdev.txt
@@ -0,0 +1,68 @@
1-------------
2 MDEV Primer
3-------------
4
5For those of us who know how to use mdev, a primer might seem lame. For
6everyone else, mdev is a weird black box that they hear is awesome, but can't
7seem to get their head around how it works. Thus, a primer.
8
9-----------
10 Basic Use
11-----------
12
13Mdev has two primary uses: initial population and dynamic updates. Both
14require sysfs support in the kernel and have it mounted at /sys. For dynamic
15updates, you also need to have hotplugging enabled in your kernel.
16
17Here's a typical code snippet from the init script:
18[1] mount -t sysfs sysfs /sys
19[2] echo /bin/mdev > /proc/sys/kernel/hotplug
20[3] mdev -s
21
22Of course, a more "full" setup would entail executing this before the previous
23code snippet:
24[4] mount -t tmpfs mdev /dev
25[5] mkdir /dev/pts
26[6] mount -t devpts devpts /dev/pts
27
28The simple explanation here is that [1] you need to have /sys mounted before
29executing mdev. Then you [2] instruct the kernel to execute /bin/mdev whenever
30a device is added or removed so that the device node can be created or
31destroyed. Then you [3] seed /dev with all the device nodes that were created
32while the system was booting.
33
34For the "full" setup, you want to [4] make sure /dev is a tmpfs filesystem
35(assuming you're running out of flash). Then you want to [5] create the
36/dev/pts mount point and finally [6] mount the devpts filesystem on it.
37
38-------------
39 MDEV Config (/etc/mdev.conf)
40-------------
41
42Mdev has an optional config file for controlling ownership/permissions of
43device nodes if your system needs something more than the default root/root
44660 permissions.
45
46The file has the format:
47 <device regex> <uid>:<gid> <octal permissions>
48For example:
49 hd[a-z][0-9]* 0:3 660
50
51The config file parsing stops at the first matching line. If no line is
52matched, then the default of 0:0 660 is used. To set your own default, simply
53create your own total match like so:
54 .* 1:1 777
55
56If you also enable support for executing your own commands, then the file has
57the format:
58 <device regex> <uid>:<gid> <octal permissions> [<@|$|*> <command>]
59The special characters have the meaning:
60 @ Run after creating the device.
61 $ Run before removing the device.
62 * Run both after creating and before removing the device.
63
64The command is executed via the system() function (which means you're giving a
65command to the shell), so make sure you have a shell installed at /bin/sh.
66
67For your convenience, the shell env var $MDEV is set to the device name. So if
68the device 'hdc' was matched, MDEV would be set to "hdc".
diff --git a/util-linux/Config.in b/util-linux/Config.in
index 1f144cae5..2184df153 100644
--- a/util-linux/Config.in
+++ b/util-linux/Config.in
@@ -269,46 +269,30 @@ config MDEV
269 bool "mdev" 269 bool "mdev"
270 default n 270 default n
271 help 271 help
272 mdev is a mini-udev implementation: call it with -s to populate 272 mdev is a mini-udev implementation for dynamically creating device
273 /dev from /sys, then "echo /sbin/mdev > /proc/sys/kernel/hotplug" to 273 nodes in the /dev directory.
274 have it handle hotplug events afterwards. Device names are taken 274
275 from sysfs. 275 For more information, please see docs/mdev.txt
276 276
277config FEATURE_MDEV_CONF 277config FEATURE_MDEV_CONF
278 bool "Support /etc/mdev.conf" 278 bool "Support /etc/mdev.conf"
279 default n 279 default n
280 depends on MDEV 280 depends on MDEV
281 help 281 help
282 The mdev config file contains lines that look like: 282 Add support for the mdev config file to control ownership and
283 283 permissions of the device nodes.
284 hd[a-z][0-9]* 0:3 660
285
286 That's device name (with regex match), uid:gid, and permissions.
287 284
288 Config file parsing stops on the first matching line. If no config 285 For more information, please see docs/mdev.txt
289 entry is matched, devices are created with default 0:0 660. (Make
290 the last line match .* to override this.)
291 286
292config FEATURE_MDEV_EXEC 287config FEATURE_MDEV_EXEC
293 bool "Support command execution at device addition/removal" 288 bool "Support command execution at device addition/removal"
294 default n 289 default n
295 depends on FEATURE_MDEV_CONF 290 depends on FEATURE_MDEV_CONF
296 help 291 help
297 This adds support for an optional field to /etc/mdev.conf, consisting 292 This adds support for an optional field to /etc/mdev.conf for
298 of a special character and a command line to run after creating the 293 executing commands when devices are created/removed.
299 corresponding device(s) and before removing, ala:
300
301 hdc root:cdrom 660 *ln -s $MDEV cdrom
302
303 The $MDEV environment variable is set to the name of the device.
304
305 The special characters and their meanings are:
306 @ Run after creating the device.
307 $ Run before removing the device.
308 * Run both after creating and before removing the device.
309 294
310 Commands are executed via system() so you need /bin/sh, meaning you 295 For more information, please see docs/mdev.txt
311 probably want to select a default shell in the Shells menu.
312 296
313config MKSWAP 297config MKSWAP
314 bool "mkswap" 298 bool "mkswap"