diff options
| author | Richard Purdie <richard@openedhand.com> | 2005-08-31 10:45:47 +0000 |
|---|---|---|
| committer | Richard Purdie <richard@openedhand.com> | 2005-08-31 10:45:47 +0000 |
| commit | 4b46c1f6e891b1ddd5968536440b888661fade3e (patch) | |
| tree | e0ba2c1f56f61b868bf746da5c4feabb25b800b2 /openembedded/packages/udev/files/init | |
| download | poky-4b46c1f6e891b1ddd5968536440b888661fade3e.tar.gz | |
Initial population
git-svn-id: https://svn.o-hand.com/repos/poky@1 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'openembedded/packages/udev/files/init')
| -rwxr-xr-x | openembedded/packages/udev/files/init | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/openembedded/packages/udev/files/init b/openembedded/packages/udev/files/init new file mode 100755 index 0000000000..16efb31542 --- /dev/null +++ b/openembedded/packages/udev/files/init | |||
| @@ -0,0 +1,178 @@ | |||
| 1 | #!/bin/sh -e | ||
| 2 | |||
| 3 | PATH="/usr/sbin:/usr/bin:/sbin:/bin" | ||
| 4 | |||
| 5 | UDEVSTART=/sbin/udevstart | ||
| 6 | |||
| 7 | # default maximum size of the /dev ramfs | ||
| 8 | ramfs_size="1M" | ||
| 9 | |||
| 10 | [ -x $UDEVSTART ] || exit 0 | ||
| 11 | |||
| 12 | . /etc/udev/udev.conf | ||
| 13 | |||
| 14 | case "$(uname -r)" in | ||
| 15 | 2.[012345].*) | ||
| 16 | echo "udev requires a kernel >= 2.6, not started." | ||
| 17 | exit 0 | ||
| 18 | ;; | ||
| 19 | esac | ||
| 20 | |||
| 21 | if ! grep -q '[[:space:]]ramfs$' /proc/filesystems; then | ||
| 22 | echo "udev requires ramfs support, not started." | ||
| 23 | exit 0 | ||
| 24 | fi | ||
| 25 | |||
| 26 | if [ ! -e /proc/sys/kernel/hotplug ]; then | ||
| 27 | echo "udev requires hotplug support, not started." | ||
| 28 | exit 0 | ||
| 29 | fi | ||
| 30 | |||
| 31 | ############################################################################## | ||
| 32 | |||
| 33 | # we need to unmount /dev/pts/ and remount it later over the ramfs | ||
| 34 | unmount_devpts() { | ||
| 35 | if mountpoint -q /dev/pts/; then | ||
| 36 | umount -l /dev/pts/ | ||
| 37 | fi | ||
| 38 | |||
| 39 | if mountpoint -q /dev/shm/; then | ||
| 40 | umount -l /dev/shm/ | ||
| 41 | fi | ||
| 42 | } | ||
| 43 | |||
| 44 | # mount a ramfs over /dev, if somebody did not already do it | ||
| 45 | mount_ramfs() { | ||
| 46 | if grep -E -q "^[^[:space:]]+ /dev ramfs" /proc/mounts; then | ||
| 47 | return 0 | ||
| 48 | fi | ||
| 49 | |||
| 50 | # /.dev is used by /sbin/MAKEDEV to access the real /dev directory. | ||
| 51 | # if you don't like this, remove /.dev/. | ||
| 52 | [ -d /.dev ] && mount --bind /dev /.dev | ||
| 53 | |||
| 54 | echo -n "Mounting a ramfs over /dev..." | ||
| 55 | mount -n -o size=$ramfs_size,mode=0755 -t ramfs none /dev | ||
| 56 | echo "done." | ||
| 57 | } | ||
| 58 | |||
| 59 | # I hate this hack. -- Md | ||
| 60 | make_extra_nodes() { | ||
| 61 | if [ -f /etc/udev/links.conf ]; then | ||
| 62 | grep '^[^#]' /etc/udev/links.conf | \ | ||
| 63 | while read type name arg1; do | ||
| 64 | [ "$type" -a "$name" -a ! -e "/dev/$name" -a ! -L "/dev/$name" ] ||continue | ||
| 65 | case "$type" in | ||
| 66 | L) | ||
| 67 | ln -s $arg1 /dev/$name | ||
| 68 | ;; | ||
| 69 | D) | ||
| 70 | mkdir -p /dev/$name | ||
| 71 | ;; | ||
| 72 | M) | ||
| 73 | mknod -m 600 /dev/$name $arg1 | ||
| 74 | ;; | ||
| 75 | *) | ||
| 76 | echo "unparseable line ($type $name $arg1)" | ||
| 77 | ;; | ||
| 78 | esac | ||
| 79 | done | ||
| 80 | fi | ||
| 81 | } | ||
| 82 | |||
| 83 | ############################################################################## | ||
| 84 | |||
| 85 | if [ "$udev_root" != "/dev" ]; then | ||
| 86 | echo "WARNING: udev_root != /dev" | ||
| 87 | |||
| 88 | case "$1" in | ||
| 89 | start) | ||
| 90 | if [ -e "$udev_root/.udev.tdb" ]; then | ||
| 91 | if mountpoint -q /dev/; then | ||
| 92 | echo "FATAL: udev is already active on $udev_root." | ||
| 93 | exit 1 | ||
| 94 | else | ||
| 95 | echo "WARNING: .udev.tdb already exists on the old $udev_root!" | ||
| 96 | fi | ||
| 97 | fi | ||
| 98 | mount -n -o size=$ramfs_size,mode=0755 -t ramfs none $udev_root | ||
| 99 | echo -n "Creating initial device nodes..." | ||
| 100 | $UDEVSTART | ||
| 101 | echo "done." | ||
| 102 | ;; | ||
| 103 | stop) | ||
| 104 | start-stop-daemon -K -x /sbin/udevd | ||
| 105 | echo -n "Unmounting $udev_root..." | ||
| 106 | # unmounting with -l should never fail | ||
| 107 | if umount -l $udev_root; then | ||
| 108 | echo "done." | ||
| 109 | else | ||
| 110 | echo "failed." | ||
| 111 | fi | ||
| 112 | ;; | ||
| 113 | restart|force-reload) | ||
| 114 | $0 stop | ||
| 115 | $0 start | ||
| 116 | ;; | ||
| 117 | *) | ||
| 118 | echo "Usage: /etc/init.d/udev {start|stop|restart|force-reload}" | ||
| 119 | exit 1 | ||
| 120 | ;; | ||
| 121 | esac | ||
| 122 | |||
| 123 | exit 0 | ||
| 124 | fi # udev_root != /dev/ | ||
| 125 | |||
| 126 | ############################################################################## | ||
| 127 | # When modifying this script, do not forget that between the time that | ||
| 128 | # the new /dev has been mounted and udevstart has been run there will be | ||
| 129 | # no /dev/null. This also means that you cannot use the "&" shell command. | ||
| 130 | |||
| 131 | case "$1" in | ||
| 132 | start) | ||
| 133 | if [ -e "$udev_root/.udev.tdb" ]; then | ||
| 134 | if mountpoint -q /dev/; then | ||
| 135 | echo "FATAL: udev is already active on $udev_root." | ||
| 136 | exit 1 | ||
| 137 | else | ||
| 138 | echo "WARNING: .udev.tdb already exists on the old $udev_root!" | ||
| 139 | fi | ||
| 140 | fi | ||
| 141 | unmount_devpts | ||
| 142 | mount_ramfs | ||
| 143 | ACTION=add | ||
| 144 | echo -n "Creating initial device nodes..." | ||
| 145 | $UDEVSTART | ||
| 146 | make_extra_nodes | ||
| 147 | echo "done." | ||
| 148 | # /etc/init.d/mountvirtfs start | ||
| 149 | ;; | ||
| 150 | stop) | ||
| 151 | start-stop-daemon -K -x /sbin/udevd | ||
| 152 | unmount_devpts | ||
| 153 | echo -n "Unmounting /dev..." | ||
| 154 | # unmounting with -l should never fail | ||
| 155 | if umount -l /dev; then | ||
| 156 | echo "done." | ||
| 157 | umount -l /.dev || true | ||
| 158 | # /etc/init.d/mountvirtfs start | ||
| 159 | else | ||
| 160 | echo "failed." | ||
| 161 | fi | ||
| 162 | ;; | ||
| 163 | restart|force-reload) | ||
| 164 | start-stop-daemon -K -x /sbin/udevd | ||
| 165 | echo -n "Recreating device nodes..." | ||
| 166 | ACTION=add | ||
| 167 | $UDEVSTART | ||
| 168 | make_extra_nodes | ||
| 169 | echo "done." | ||
| 170 | ;; | ||
| 171 | *) | ||
| 172 | echo "Usage: /etc/init.d/udev {start|stop|restart|force-reload}" | ||
| 173 | exit 1 | ||
| 174 | ;; | ||
| 175 | esac | ||
| 176 | |||
| 177 | exit 0 | ||
| 178 | |||
