udev 2.2 KB

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