diff options
author | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
commit | 972dcfcdbfe75dcfeb777150c136576cf1a71e99 (patch) | |
tree | 97a61cd7e293d7ae9d56ef7ed0f81253365bb026 /meta/recipes-core/udev/udev-extraconf | |
download | poky-972dcfcdbfe75dcfeb777150c136576cf1a71e99.tar.gz |
initial commit for Enea Linux 5.0 arm
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'meta/recipes-core/udev/udev-extraconf')
6 files changed, 210 insertions, 0 deletions
diff --git a/meta/recipes-core/udev/udev-extraconf/automount.rules b/meta/recipes-core/udev/udev-extraconf/automount.rules new file mode 100644 index 0000000000..62578ea631 --- /dev/null +++ b/meta/recipes-core/udev/udev-extraconf/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 | SUBSYSTEM=="block", ACTION=="change", ENV{DISK_MEDIA_CHANGE}=="1" RUN+="/etc/udev/scripts/mount.sh" | ||
diff --git a/meta/recipes-core/udev/udev-extraconf/autonet.rules b/meta/recipes-core/udev/udev-extraconf/autonet.rules new file mode 100644 index 0000000000..19676aa13b --- /dev/null +++ b/meta/recipes-core/udev/udev-extraconf/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/recipes-core/udev/udev-extraconf/localextra.rules b/meta/recipes-core/udev/udev-extraconf/localextra.rules new file mode 100644 index 0000000000..3d51d3e395 --- /dev/null +++ b/meta/recipes-core/udev/udev-extraconf/localextra.rules | |||
@@ -0,0 +1,23 @@ | |||
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 | # Make all input devices read-write to the input group | ||
23 | SUBSYSTEM=="input", GROUP="input", MODE="660" | ||
diff --git a/meta/recipes-core/udev/udev-extraconf/mount.blacklist b/meta/recipes-core/udev/udev-extraconf/mount.blacklist new file mode 100644 index 0000000000..e49349428b --- /dev/null +++ b/meta/recipes-core/udev/udev-extraconf/mount.blacklist | |||
@@ -0,0 +1,5 @@ | |||
1 | /dev/loop | ||
2 | /dev/ram | ||
3 | /dev/mtdblock | ||
4 | /dev/md | ||
5 | /dev/dm-* | ||
diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh new file mode 100644 index 0000000000..3eea910854 --- /dev/null +++ b/meta/recipes-core/udev/udev-extraconf/mount.sh | |||
@@ -0,0 +1,90 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Called from udev | ||
4 | # | ||
5 | # Attempt to mount any added block devices and umount any removed devices | ||
6 | |||
7 | |||
8 | MOUNT="/bin/mount" | ||
9 | PMOUNT="/usr/bin/pmount" | ||
10 | UMOUNT="/bin/umount" | ||
11 | for line in `grep -v ^# /etc/udev/mount.blacklist` | ||
12 | do | ||
13 | if [ ` expr match "$DEVNAME" "$line" ` -gt 0 ]; | ||
14 | then | ||
15 | logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring" | ||
16 | exit 0 | ||
17 | fi | ||
18 | done | ||
19 | |||
20 | automount() { | ||
21 | name="`basename "$DEVNAME"`" | ||
22 | |||
23 | ! test -d "/run/media/$name" && mkdir -p "/run/media/$name" | ||
24 | # Silent util-linux's version of mounting auto | ||
25 | if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ; | ||
26 | then | ||
27 | MOUNT="$MOUNT -o silent" | ||
28 | fi | ||
29 | |||
30 | # If filesystem type is vfat, change the ownership group to 'disk', and | ||
31 | # grant it with w/r/x permissions. | ||
32 | case $ID_FS_TYPE in | ||
33 | vfat|fat) | ||
34 | MOUNT="$MOUNT -o umask=007,gid=`awk -F':' '/^disk/{print $3}' /etc/group`" | ||
35 | ;; | ||
36 | # TODO | ||
37 | *) | ||
38 | ;; | ||
39 | esac | ||
40 | |||
41 | if ! $MOUNT -t auto $DEVNAME "/run/media/$name" | ||
42 | then | ||
43 | #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/run/media/$name\" failed!" | ||
44 | rm_dir "/run/media/$name" | ||
45 | else | ||
46 | logger "mount.sh/automount" "Auto-mount of [/run/media/$name] successful" | ||
47 | touch "/tmp/.automount-$name" | ||
48 | fi | ||
49 | } | ||
50 | |||
51 | rm_dir() { | ||
52 | # We do not want to rm -r populated directories | ||
53 | if test "`find "$1" | wc -l | tr -d " "`" -lt 2 -a -d "$1" | ||
54 | then | ||
55 | ! test -z "$1" && rm -r "$1" | ||
56 | else | ||
57 | logger "mount.sh/automount" "Not removing non-empty directory [$1]" | ||
58 | fi | ||
59 | } | ||
60 | |||
61 | # No ID_FS_TYPE for cdrom device, yet it should be mounted | ||
62 | name="`basename "$DEVNAME"`" | ||
63 | [ -e /sys/block/$name/device/media ] && media_type=`cat /sys/block/$name/device/media` | ||
64 | |||
65 | if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ -n "$ID_FS_TYPE" -o "$media_type" = "cdrom" ]; then | ||
66 | if [ -x "$PMOUNT" ]; then | ||
67 | $PMOUNT $DEVNAME 2> /dev/null | ||
68 | elif [ -x $MOUNT ]; then | ||
69 | $MOUNT $DEVNAME 2> /dev/null | ||
70 | fi | ||
71 | |||
72 | # If the device isn't mounted at this point, it isn't | ||
73 | # configured in fstab (note the root filesystem can show up as | ||
74 | # /dev/root in /proc/mounts, so check the device number too) | ||
75 | if expr $MAJOR "*" 256 + $MINOR != `stat -c %d /`; then | ||
76 | grep -q "^$DEVNAME " /proc/mounts || automount | ||
77 | fi | ||
78 | fi | ||
79 | |||
80 | |||
81 | if [ "$ACTION" = "remove" ] || [ "$ACTION" = "change" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then | ||
82 | for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " ` | ||
83 | do | ||
84 | $UMOUNT $mnt | ||
85 | done | ||
86 | |||
87 | # Remove empty directories from auto-mounter | ||
88 | name="`basename "$DEVNAME"`" | ||
89 | test -e "/tmp/.automount-$name" && rm_dir "/run/media/$name" | ||
90 | fi | ||
diff --git a/meta/recipes-core/udev/udev-extraconf/network.sh b/meta/recipes-core/udev/udev-extraconf/network.sh new file mode 100644 index 0000000000..3ee92714af --- /dev/null +++ b/meta/recipes-core/udev/udev-extraconf/network.sh | |||
@@ -0,0 +1,54 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # We get two "add" events for hostap cards due to wifi0 | ||
4 | echo "$INTERFACE" | grep -q wifi && exit 0 | ||
5 | |||
6 | # udevd does clearenv(). Export shell PATH to children. | ||
7 | export PATH | ||
8 | |||
9 | # Check if /etc/init.d/network has been run yet to see if we are | ||
10 | # called by starting /etc/rcS.d/S03udev and not by hotplugging a device | ||
11 | # | ||
12 | # At this stage, network interfaces should not be brought up | ||
13 | # automatically because: | ||
14 | # a) /etc/init.d/network has not been run yet (security issue) | ||
15 | # b) /var has not been populated yet so /etc/resolv,conf points to | ||
16 | # oblivion, making the network unusable | ||
17 | # | ||
18 | |||
19 | spoofp="`grep ^spoofprotect /etc/network/options`" | ||
20 | if test -z "$spoofp" | ||
21 | then | ||
22 | # This is the default from /etc/init.d/network | ||
23 | spoofp_val=yes | ||
24 | else | ||
25 | spoofp_val=${spoofp#spoofprotect=} | ||
26 | fi | ||
27 | |||
28 | test "$spoofp_val" = yes && spoofp_val=1 || spoofp_val=0 | ||
29 | |||
30 | # I think it is safe to assume that "lo" will always be there ;) | ||
31 | if test "`cat /proc/sys/net/ipv4/conf/lo/rp_filter`" != "$spoofp_val" -a -n "$spoofp_val" | ||
32 | then | ||
33 | echo "$INTERFACE" >> /dev/udev_network_queue | ||
34 | exit 0 | ||
35 | fi | ||
36 | |||
37 | # | ||
38 | # Code taken from pcmcia-cs:/etc/pcmcia/network | ||
39 | # | ||
40 | |||
41 | # if this interface has an entry in /etc/network/interfaces, let ifupdown | ||
42 | # handle it | ||
43 | if grep -q "iface \+$INTERFACE" /etc/network/interfaces; then | ||
44 | case $ACTION in | ||
45 | add) | ||
46 | ifconfig | grep -q "^$INTERFACE" || ifup $INTERFACE | ||
47 | ;; | ||
48 | remove) | ||
49 | ifdown $INTERFACE | ||
50 | ;; | ||
51 | esac | ||
52 | |||
53 | exit 0 | ||
54 | fi | ||