udev 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. if ! mountpoint /dev > /dev/null; then
  36. mount -n -t tmpfs tmpfs /dev -o mode=755
  37. fi
  38. if [ ${?} -ne 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. # Create a symlink for POSIX shared memory
  50. ln -s /run/shm /dev/shm
  51. # Udev handles uevents itself, so we don't need to have
  52. # the kernel call out to any binary in response to them
  53. echo > /proc/sys/kernel/hotplug
  54. # Copy the only static device node that Udev >= 155 doesn't
  55. # handle to /dev
  56. cp -a /lib/udev/devices/null /dev
  57. # Start the udev daemon to continually watch for, and act on,
  58. # uevents
  59. /sbin/udevd --daemon
  60. # Now traverse /sys in order to "coldplug" devices that have
  61. # already been discovered
  62. /sbin/udevadm trigger --action=add
  63. # Now wait for udevd to process the uevents we triggered
  64. /sbin/udevadm settle
  65. evaluate_retval standard
  66. ;;
  67. *)
  68. echo "Usage ${0} {start}"
  69. exit 1
  70. ;;
  71. esac
  72. # End $rc_base/init.d/udev