udev 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. $FAILURE_ACTION
  29. /etc/rc.d/init.d/halt stop
  30. fi
  31. # If not using DEVTMPFS mount a temporary file system over
  32. # /dev, so that any devices made or removed during this boot
  33. # don't affect the next one. The reason we don't write to mtab
  34. # is because we don't ever want /dev to be unavailable (such as
  35. # by `umount -a').
  36. if ! mountpoint /dev > /dev/null; then
  37. mount -n -t tmpfs tmpfs /dev -o mode=755
  38. fi
  39. if [ ${?} -ne 0 ]; then
  40. echo_failure
  41. boot_mesg -n "FAILURE:\n\nCannot mount a tmpfs" ${FAILURE}
  42. boot_mesg -n " onto /dev, this system will be halted."
  43. boot_mesg -n "\n\nAfter you press Enter, this system"
  44. boot_mesg -n " will be halted and powered off."
  45. boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
  46. boot_mesg "" ${NORMAL}
  47. $FAILURE_ACTION
  48. /etc/rc.d/init.d/halt stop
  49. fi
  50. # Create a symlink for POSIX shared memory
  51. ln -s /run/shm /dev/shm
  52. # Udev handles uevents itself, so we don't need to have
  53. # the kernel call out to any binary in response to them
  54. # This is a failsafe and should be done in kernel config
  55. echo > /proc/sys/kernel/hotplug
  56. # Copy the only static device node that Udev >= 155 doesn't
  57. # handle to /dev (handled by default with DEVTMPFS)
  58. if [ ! -f /dev/null ]; then
  59. cp -a /lib/udev/devices/null /dev
  60. fi
  61. # Start the udev daemon to continually watch for, and act on,
  62. # uevents
  63. /sbin/udevd --daemon
  64. # Now traverse /sys in order to "coldplug" devices that have
  65. # already been discovered
  66. /sbin/udevadm trigger --action=add --type=subsystems
  67. /sbin/udevadm trigger --action=add --type=devices
  68. # Now wait for udevd to process the uevents we triggered
  69. /sbin/udevadm settle
  70. evaluate_retval standard
  71. ;;
  72. *)
  73. echo "Usage ${0} {start}"
  74. exit 1
  75. ;;
  76. esac
  77. # End $RC_BASE/init.d/udev