udev 2.2 KB

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