udev 3.0 KB

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