S10udev 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/sh
  2. #
  3. # udev This is a minimal non-LSB version of a UDEV startup script. It
  4. # was derived by stripping down the udev-058 LSB version for use
  5. # with buildroot on embedded hardware using Linux 2.6.12+ kernels.
  6. #
  7. # You may need to customize this for your system's resource limits
  8. # (including startup time!) and administration. For example, if
  9. # your early userspace has a custom initramfs or initrd you might
  10. # need /dev much earlier; or without hotpluggable busses (like USB,
  11. # PCMCIA, MMC/SD, and so on) your /dev might be static after boot.
  12. #
  13. # This script assumes your system boots right into the eventual root
  14. # filesystem, and that init runs this udev script before any programs
  15. # needing more device nodes than the bare-bones set -- /dev/console,
  16. # /dev/zero, /dev/null -- that's needed to boot and run this script.
  17. #
  18. # old kernels don't use udev
  19. case $(uname -r) in
  20. 2.6*|2.7*) ;;
  21. *) exit 0;;
  22. esac
  23. # Check for missing binaries
  24. UDEV_BIN=/sbin/udevd
  25. test -x $UDEV_BIN || exit 5
  26. UDEVSTART_BIN=/sbin/udevstart
  27. test -x $UDEVSTART_BIN || exit 5
  28. # Check for config file and read it
  29. UDEV_CONFIG=/etc/udev/udev.conf
  30. test -r $UDEV_CONFIG || exit 6
  31. . $UDEV_CONFIG
  32. # Directory where sysfs is mounted
  33. SYSFS_DIR=/sys
  34. case "$1" in
  35. start)
  36. # mount sysfs if it's not yet mounted
  37. if [ ! -d $SYSFS_DIR ]; then
  38. echo "${0}: SYSFS_DIR \"$SYSFS_DIR\" not found"
  39. exit 1
  40. fi
  41. grep -q "^sysfs $SYSFS_DIR" /proc/mounts ||
  42. mount -t sysfs /sys /sys ||
  43. exit 1
  44. # mount $udev_root as ramfs if it's not yet mounted
  45. # we know 2.6 kernels always support ramfs
  46. if [ ! -d $udev_root ]; then
  47. echo "${0}: udev_root \"$udev_root\" not found"
  48. exit 1
  49. fi
  50. grep -q "^udev $udev_root" /proc/mounts ||
  51. mount -t ramfs udev $udev_root ||
  52. exit 1
  53. mkdir $udev_root/pts $udev_root/shm
  54. mknod -m 0666 /dev/null c 1 3
  55. mknod -m 0666 /dev/zero c 1 5
  56. mknod -m 0600 /dev/console c 5 1
  57. # populate /dev (normally)
  58. echo -n "Populating $udev_root using udev: "
  59. echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
  60. $UDEV_BIN -d || (echo "FAIL" && exit 1)
  61. $UDEVSTART_BIN || (echo "FAIL" && exit 1)
  62. mount -t devpts /dev/pts /dev/pts || (echo "FAIL" && exit 1)
  63. echo "done"
  64. ;;
  65. stop)
  66. # Stop execution of events
  67. udevcontrol stop_exec_queue
  68. killall udevd
  69. ;;
  70. *)
  71. echo "Usage: $0 {start|stop}"
  72. exit 1
  73. ;;
  74. esac
  75. exit 0