udev 3.0 KB

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