udev 2.3 KB

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