]> git.pld-linux.org Git - packages/systemd.git/blobdiff - start_udev
- rel 12
[packages/systemd.git] / start_udev
index d0e08945bac879b69a039a020140edc7535ecf88..a2d20c0e1c89c0513472a1825f415d5e676063fc 100644 (file)
@@ -21,7 +21,7 @@
 # properly during development...
 
 # default value, if no config present.
-udev_root="/dev/"
+udev_root="/dev"
 sysfs_dir="/sys"
 udevd_timeout=8
 
@@ -35,6 +35,8 @@ udevd_timeout=8
 prog=udev
 bin=/sbin/udev
 udevd=/lib/udev/udevd
+# trim traling slash, code expects it not to be there
+udev_root=${udev_root%/}
 
 make_extra_nodes () {
        grep '^[^#]' /etc/udev/links.conf | \
@@ -62,38 +64,49 @@ set_hotplug_handler() {
        echo "" > /proc/sys/kernel/hotplug
 }
 
+# find subdirs mounted under $udev_root
+get_dev_mounts() {
+       awk -vudev_root="$udev_root/" '
+       BEGIN {
+         len = length(udev_root);
+       }
+
+       substr($2, 1, len) == udev_root {
+         print substr($2, len + 1)
+       }' /proc/mounts
+}
+
 export ACTION=add
 prog=udev
 ret=0
 show "Starting udev"
 busy
 
-# mount the devtmpfs on ${udev_root%/}, if not already done
-awk "\$2 == \"${udev_root%/}\" && \$3 == \"devtmpfs\" { exit 1 }" /proc/mounts && {
-
-       if grep -qF "none ${udev_root%/}/pts " /proc/mounts; then
-               PTSDIR=$(mktemp -d ${TMPDIR:-/tmp}/tmpXXXXXX)
-               mount --move $udev_root/pts "$PTSDIR"
+# mount the devtmpfs on $udev_root, if not already done
+awk "\$2 == \"$udev_root\" && \$3 == \"devtmpfs\" { exit 1 }" /proc/mounts && {
+       submounts=$(get_dev_mounts)
+
+       if [ "$submounts" ]; then
+               # mount to temporary location to be able to move submounts
+               # this needs writable TMPDIR:-/tmp, so it won't work in early boot
+               # but fix is simple: use initramfs instead of romfs
+               devdir=$(mktemp -d ${TMPDIR:-/tmp}/tmpXXXXXX)
+       else
+               devdir=$udev_root
        fi
+       mount -n -o mode=0755 -t devtmpfs devtmpfs "$devdir"
+       ret=$(( $ret + $? ))
 
-       if grep -qF "none ${udev_root%/}/shm " /proc/mounts; then
-               SHMDIR=$(mktemp -d ${TMPDIR:-/tmp}/tmpXXXXXX)
-               mount --move $udev_root/shm "$SHMDIR"
-       fi
+       # relocate submounts
+       for dir in $submounts; do
+               mount -n --move $udev_root/$dir $devdir/$dir
+               ret=$(( $ret + $? ))
+       done
 
-       mount -n -o mode=0755 -t devtmpfs devtmpfs "$udev_root"
-       mkdir -m 0755 $udev_root/pts
-       mkdir -m 0755 $udev_root/shm
-       if [ -n "$PTSDIR" ]; then
-               mount --move "$PTSDIR" $udev_root/pts
-               rmdir "$PTSDIR"
-       fi
-       if [ -n "$SHMDIR" ]; then
-               mount --move "$SHMDIR" $udev_root/shm
-               rmdir "$SHMDIR"
+       if [ "$submounts" ]; then
+               mount -n --move $devdir $udev_root
+               rmdir $devdir
        fi
-
-       ret=$(( $ret + $? ))
 }
 
 kill_udevd > "$udev_root/null" 2>&1
This page took 0.070905 seconds and 4 git commands to generate.