diff options
author | Koen Kooi <koen@dominion.thruhere.net> | 2011-05-29 20:33:05 +0200 |
---|---|---|
committer | Koen Kooi <koen@dominion.thruhere.net> | 2011-05-30 13:54:49 +0200 |
commit | 7aa7dd55db8db6ec350c743ce42eb469395a3208 (patch) | |
tree | 9ce1e8db459e8d5bef95454344659d6c2ef5e142 /meta-oe | |
parent | 83245fde83671e583fb4ecdc80a225a89e532ed9 (diff) | |
download | meta-openembedded-7aa7dd55db8db6ec350c743ce42eb469395a3208.tar.gz |
udev-extra-rules: recipe with extra rules previously provided by udev
These rules had no demonstratable benefit and slow down bootup a lot
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Diffstat (limited to 'meta-oe')
7 files changed, 228 insertions, 0 deletions
diff --git a/meta-oe/recipes-core/udev/udev-extra-rules.bb b/meta-oe/recipes-core/udev/udev-extra-rules.bb new file mode 100644 index 000000000..bacf152d0 --- /dev/null +++ b/meta-oe/recipes-core/udev/udev-extra-rules.bb | |||
@@ -0,0 +1,33 @@ | |||
1 | DESCRIPTION = "Extra udev rules" | ||
2 | LICENSE = "MIT" | ||
3 | LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58" | ||
4 | |||
5 | SRC_URI = " \ | ||
6 | file://automount.rules \ | ||
7 | file://mount.sh \ | ||
8 | file://mount.blacklist \ | ||
9 | file://autonet.rules \ | ||
10 | file://network.sh \ | ||
11 | file://local.rules \ | ||
12 | " | ||
13 | |||
14 | |||
15 | do_install() { | ||
16 | install -d ${D}${sysconfdir}/udev/rules.d | ||
17 | |||
18 | install -m 0644 ${WORKDIR}/automount.rules ${D}${sysconfdir}/udev/rules.d/automount.rules | ||
19 | install -m 0644 ${WORKDIR}/autonet.rules ${D}${sysconfdir}/udev/rules.d/autonet.rules | ||
20 | install -m 0644 ${WORKDIR}/local.rules ${D}${sysconfdir}/udev/rules.d/local.rules | ||
21 | |||
22 | install -m 0644 ${WORKDIR}/mount.blacklist ${D}${sysconfdir}/udev/ | ||
23 | |||
24 | install -d ${D}${sysconfdir}/udev/scripts/ | ||
25 | |||
26 | install -m 0755 ${WORKDIR}/mount.sh ${D}${sysconfdir}/udev/scripts/mount.sh | ||
27 | install -m 0755 ${WORKDIR}/network.sh ${D}${sysconfdir}/udev/scripts | ||
28 | } | ||
29 | |||
30 | FILES_${PN} = "${sysconfdir}/udev" | ||
31 | RDEPENDS_${PN} = "udev" | ||
32 | PACKAGE_ARCH = "all" | ||
33 | |||
diff --git a/meta-oe/recipes-core/udev/udev-extra-rules/automount.rules b/meta-oe/recipes-core/udev/udev-extra-rules/automount.rules new file mode 100644 index 000000000..7e844c31b --- /dev/null +++ b/meta-oe/recipes-core/udev/udev-extra-rules/automount.rules | |||
@@ -0,0 +1,19 @@ | |||
1 | # There are a number of modifiers that are allowed to be used in some | ||
2 | # of the different fields. They provide the following subsitutions: | ||
3 | # | ||
4 | # %n the "kernel number" of the device. | ||
5 | # For example, 'sda3' has a "kernel number" of '3' | ||
6 | # %e the smallest number for that name which does not matches an existing node | ||
7 | # %k the kernel name for the device | ||
8 | # %M the kernel major number for the device | ||
9 | # %m the kernel minor number for the device | ||
10 | # %b the bus id for the device | ||
11 | # %c the string returned by the PROGRAM | ||
12 | # %s{filename} the content of a sysfs attribute | ||
13 | # %% the '%' char itself | ||
14 | # | ||
15 | |||
16 | # Media automounting | ||
17 | SUBSYSTEM=="block", ACTION=="add" RUN+="/etc/udev/scripts/mount.sh" | ||
18 | SUBSYSTEM=="block", ACTION=="remove" RUN+="/etc/udev/scripts/mount.sh" | ||
19 | |||
diff --git a/meta-oe/recipes-core/udev/udev-extra-rules/autonet.rules b/meta-oe/recipes-core/udev/udev-extra-rules/autonet.rules new file mode 100644 index 000000000..19676aa13 --- /dev/null +++ b/meta-oe/recipes-core/udev/udev-extra-rules/autonet.rules | |||
@@ -0,0 +1,19 @@ | |||
1 | # There are a number of modifiers that are allowed to be used in some | ||
2 | # of the different fields. They provide the following subsitutions: | ||
3 | # | ||
4 | # %n the "kernel number" of the device. | ||
5 | # For example, 'sda3' has a "kernel number" of '3' | ||
6 | # %e the smallest number for that name which does not matches an existing node | ||
7 | # %k the kernel name for the device | ||
8 | # %M the kernel major number for the device | ||
9 | # %m the kernel minor number for the device | ||
10 | # %b the bus id for the device | ||
11 | # %c the string returned by the PROGRAM | ||
12 | # %s{filename} the content of a sysfs attribute | ||
13 | # %% the '%' char itself | ||
14 | # | ||
15 | |||
16 | # Handle network interface setup | ||
17 | SUBSYSTEM=="net", ACTION=="add" RUN+="/etc/udev/scripts/network.sh" | ||
18 | SUBSYSTEM=="net", ACTION=="remove" RUN+="/etc/udev/scripts/network.sh" | ||
19 | |||
diff --git a/meta-oe/recipes-core/udev/udev-extra-rules/local.rules b/meta-oe/recipes-core/udev/udev-extra-rules/local.rules new file mode 100644 index 000000000..900a05a93 --- /dev/null +++ b/meta-oe/recipes-core/udev/udev-extra-rules/local.rules | |||
@@ -0,0 +1,24 @@ | |||
1 | # There are a number of modifiers that are allowed to be used in some | ||
2 | # of the different fields. They provide the following subsitutions: | ||
3 | # | ||
4 | # %n the "kernel number" of the device. | ||
5 | # For example, 'sda3' has a "kernel number" of '3' | ||
6 | # %e the smallest number for that name which does not matches an existing node | ||
7 | # %k the kernel name for the device | ||
8 | # %M the kernel major number for the device | ||
9 | # %m the kernel minor number for the device | ||
10 | # %b the bus id for the device | ||
11 | # %c the string returned by the PROGRAM | ||
12 | # %s{filename} the content of a sysfs attribute | ||
13 | # %% the '%' char itself | ||
14 | # | ||
15 | |||
16 | # The first rtc device is symlinked to /dev/rtc | ||
17 | KERNEL=="rtc0", SYMLINK+="rtc" | ||
18 | |||
19 | #The first framebuffer is symlinked to /dev/fb | ||
20 | KERNEL=="fb0", SYMLINK+="fb" | ||
21 | |||
22 | # Try and modprobe for drivers for new hardware | ||
23 | ACTION=="add", DEVPATH=="/devices/*", ENV{MODALIAS}=="?*", RUN+="/sbin/modprobe $env{MODALIAS}" | ||
24 | |||
diff --git a/meta-oe/recipes-core/udev/udev-extra-rules/mount.blacklist b/meta-oe/recipes-core/udev/udev-extra-rules/mount.blacklist new file mode 100644 index 000000000..d3ebb1717 --- /dev/null +++ b/meta-oe/recipes-core/udev/udev-extra-rules/mount.blacklist | |||
@@ -0,0 +1,3 @@ | |||
1 | /dev/loop | ||
2 | /dev/ram | ||
3 | /dev/mtdblock | ||
diff --git a/meta-oe/recipes-core/udev/udev-extra-rules/mount.sh b/meta-oe/recipes-core/udev/udev-extra-rules/mount.sh new file mode 100644 index 000000000..81bcfba5e --- /dev/null +++ b/meta-oe/recipes-core/udev/udev-extra-rules/mount.sh | |||
@@ -0,0 +1,72 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Called from udev | ||
4 | # Attemp to mount any added block devices | ||
5 | # and remove any removed devices | ||
6 | # | ||
7 | |||
8 | MOUNT="/bin/mount" | ||
9 | PMOUNT="/usr/bin/pmount" | ||
10 | UMOUNT="/bin/umount" | ||
11 | name="`basename "$DEVNAME"`" | ||
12 | |||
13 | for line in `cat /etc/udev/mount.blacklist | grep -v ^#` | ||
14 | do | ||
15 | if ( echo "$DEVNAME" | grep -q "$line" ) | ||
16 | then | ||
17 | logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring" | ||
18 | exit 0 | ||
19 | fi | ||
20 | done | ||
21 | |||
22 | automount() { | ||
23 | ! test -d "/media/$name" && mkdir -p "/media/$name" | ||
24 | |||
25 | if ! $MOUNT -t auto -o async,relatime $DEVNAME "/media/$name" | ||
26 | then | ||
27 | #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/media/$name\" failed!" | ||
28 | rm_dir "/media/$name" | ||
29 | else | ||
30 | logger "mount.sh/automount" "Auto-mount of [/media/$name] successful" | ||
31 | touch "/tmp/.automount-$name" | ||
32 | fi | ||
33 | } | ||
34 | |||
35 | rm_dir() { | ||
36 | # We do not want to rm -r populated directories | ||
37 | if test "`find "$1" | wc -l | tr -d " "`" -lt 2 -a -d "$1" | ||
38 | then | ||
39 | ! test -z "$1" && rm -r "$1" | ||
40 | else | ||
41 | logger "mount.sh/automount" "Not removing non-empty directory [$1]" | ||
42 | fi | ||
43 | } | ||
44 | |||
45 | if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ]; then | ||
46 | if [ -x "$PMOUNT" ]; then | ||
47 | $PMOUNT $DEVNAME 2> /dev/null | ||
48 | elif [ -x $MOUNT ]; then | ||
49 | $MOUNT $DEVNAME 2> /dev/null | ||
50 | fi | ||
51 | |||
52 | # If the device isn't mounted at this point, it isn't configured in fstab | ||
53 | # 20061107: Small correction: The rootfs partition may be called just "rootfs" and not by | ||
54 | # its true device name so this would break. If the rootfs is mounted on two places | ||
55 | # during boot, it confuses the heck out of fsck. So Im auto-adding the root-partition | ||
56 | # to /etc/udev/mount.blacklist via postinst | ||
57 | |||
58 | cat /proc/mounts | awk '{print $1}' | grep -q "^$DEVNAME$" || automount | ||
59 | |||
60 | fi | ||
61 | |||
62 | |||
63 | |||
64 | if [ "$ACTION" = "remove" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then | ||
65 | for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " ` | ||
66 | do | ||
67 | $UMOUNT -l $mnt | ||
68 | done | ||
69 | |||
70 | # Remove empty directories from auto-mounter | ||
71 | test -e "/tmp/.automount-$name" && rm_dir "/media/$name" | ||
72 | fi | ||
diff --git a/meta-oe/recipes-core/udev/udev-extra-rules/network.sh b/meta-oe/recipes-core/udev/udev-extra-rules/network.sh new file mode 100644 index 000000000..182c26d86 --- /dev/null +++ b/meta-oe/recipes-core/udev/udev-extra-rules/network.sh | |||
@@ -0,0 +1,58 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # udevd does clearenv(). Export shell PATH to children. | ||
4 | export PATH | ||
5 | |||
6 | # Do not run when pcmcia-cs is installed | ||
7 | test -x /sbin/cardctl && exit 0 | ||
8 | |||
9 | # We get two "add" events for hostap cards due to wifi0 | ||
10 | echo "$INTERFACE" | grep -q wifi && exit 0 | ||
11 | |||
12 | |||
13 | # Check if /etc/init.d/network has been run yet to see if we are | ||
14 | # called by starting /etc/rcS.d/S03udev and not by hotplugging a device | ||
15 | # | ||
16 | # At this stage, network interfaces should not be brought up | ||
17 | # automatically because: | ||
18 | # a) /etc/init.d/network has not been run yet (security issue) | ||
19 | # b) /var has not been populated yet so /etc/resolv,conf points to | ||
20 | # oblivion, making the network unusable | ||
21 | # | ||
22 | |||
23 | spoofp="`grep ^spoofprotect /etc/network/options`" | ||
24 | if test -z "$spoofp" | ||
25 | then | ||
26 | # This is the default from /etc/init.d/network | ||
27 | spoofp_val=yes | ||
28 | else | ||
29 | spoofp_val=${spoofp#spoofprotect=} | ||
30 | fi | ||
31 | |||
32 | test "$spoofp_val" = yes && spoofp_val=1 || spoofp_val=0 | ||
33 | |||
34 | # I think it is safe to assume that "lo" will always be there ;) | ||
35 | if test "`cat /proc/sys/net/ipv4/conf/lo/rp_filter`" != "$spoofp_val" -a -n "$spoofp_val" | ||
36 | then | ||
37 | echo "$INTERFACE" >> /dev/udev_network_queue | ||
38 | exit 0 | ||
39 | fi | ||
40 | |||
41 | # | ||
42 | # Code taken from pcmcia-cs:/etc/pcmcia/network | ||
43 | # | ||
44 | |||
45 | # if this interface has an entry in /etc/network/interfaces, let ifupdown | ||
46 | # handle it | ||
47 | if grep -q "iface \+$INTERFACE" /etc/network/interfaces; then | ||
48 | case $ACTION in | ||
49 | add) | ||
50 | ifconfig | grep -q "^$INTERFACE" || ifup $INTERFACE | ||
51 | ;; | ||
52 | remove) | ||
53 | ifdown $INTERFACE | ||
54 | ;; | ||
55 | esac | ||
56 | |||
57 | exit 0 | ||
58 | fi | ||