summaryrefslogtreecommitdiff
path: root/packages/udev/files/udevsynthesize.sh
blob: d58217c144ded317e64526d54994c044503b5663 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh -e

load_input_modules() {
  for module in mousedev evdev joydev; do
    modprobe -q $module || true
  done
}

if [ ! -e /sys/class/mem/null/uevent ]; then # <= 2.6.14
  /lib/udev/udevsynthesize
  load_input_modules
  exit 0
fi

# replace $IFS with something which is not likely to appear in a sysfs path,
# because some buggy drivers have spaces in their names
oldifs="$IFS"
IFS="|"

for file in /sys/bus/*/devices/*/uevent /sys/class/*/*/uevent \
		/sys/block/*/uevent /sys/block/*/*/uevent; do
  case "$file" in
    */device/uevent) ;;		# skip followed device symlinks
    */\*/*) ;;

    */class/mem/*)		# for /dev/null
    first="$first${IFS}$file" ;;

    */block/md[0-9]*)
    last="$last${IFS}$file" ;;

    *)
    default="$default${IFS}$file" ;;
  esac
done

for file in $first${IFS}$default${IFS}$last; do
  [ "$file" ] || continue
  echo 'add' > "$file" || true
done

IFS="$oldifs"

case "$(uname -r)" in
  2.6.1[0-5]|2.6.1[0-5][!0-9]*) # <= 2.6.15
  load_input_modules
  ;;
esac

exit 0