udev 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/sh
  2. # Begin $rc_base/init.d/udev
  3. ### BEGIN INIT INFO
  4. # Provides: udev
  5. # Required-Start:
  6. # Should-Start: modules
  7. # Required-Stop:
  8. # Should-Stop:
  9. # Default-Start: S
  10. # Default-Stop:
  11. # Short-Description: Populated /dev with device nodes.
  12. # Description: Mounts a tempfs on /dev and starts the udevd daemon.
  13. # Device nodes are created as defined by udev.
  14. # X-LFS-Default-Start: S15
  15. # X-LFS-Default-Stop:
  16. # X-LFS-Provided-By: LFS
  17. ### END INIT INFO
  18. . /lib/lsb/init-functions
  19. MESSAGE="Populating /dev with device nodes..."
  20. case "${1}" in
  21. start)
  22. if ! grep -q '[[:space:]]sysfs' /proc/mounts; then
  23. echo_failure
  24. boot_mesg -n "FAILURE:\n\nUnable to create" ${FAILURE}
  25. boot_mesg -n " devices without a SysFS filesystem"
  26. boot_mesg -n "\n\nAfter you press Enter, this system"
  27. boot_mesg -n " will be halted and powered off."
  28. boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
  29. boot_mesg "" ${NORMAL}
  30. read ENTER
  31. /etc/rc.d/init.d/halt stop
  32. fi
  33. # Mount a temporary file system over /dev, so that any devices
  34. # made or removed during this boot don't affect the next one.
  35. # The reason we don't write to mtab is because we don't ever
  36. # want /dev to be unavailable (such as by `umount -a').
  37. mount -n -t tmpfs tmpfs /dev -o mode=755
  38. if [ ${?} != 0 ]; then
  39. echo_failure
  40. boot_mesg -n "FAILURE:\n\nCannot mount a tmpfs" ${FAILURE}
  41. boot_mesg -n " onto /dev, this system will be halted."
  42. boot_mesg -n "\n\nAfter you press Enter, this system"
  43. boot_mesg -n " will be halted and powered off."
  44. boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
  45. boot_mesg "" ${NORMAL}
  46. read ENTER
  47. /etc/rc.d/init.d/halt stop
  48. fi
  49. # Udev handles uevents itself, so we don't need to have
  50. # the kernel call out to any binary in response to them
  51. echo > /proc/sys/kernel/hotplug
  52. # Copy static device nodes to /dev
  53. cp -a /lib/udev/devices/* /dev
  54. # Start the udev daemon to continually watch for, and act on,
  55. # uevents
  56. /sbin/udevd --daemon
  57. # Now traverse /sys in order to "coldplug" devices that have
  58. # already been discovered
  59. /sbin/udevadm trigger
  60. # Now wait for udevd to process the uevents we triggered
  61. /sbin/udevadm settle
  62. evaluate_retval standard
  63. ;;
  64. *)
  65. echo "Usage ${0} {start}"
  66. exit 1
  67. ;;
  68. esac
  69. # End $rc_base/init.d/udev