#!/bin/sh -e
# initramfs premount script for udev

PREREQ=""

# Output pre-requisites
prereqs()
{
	echo "$PREREQ"
}

case "$1" in
    prereqs)
	prereqs
	exit 0
	;;
esac


# Stop udevd, we'll miss a few events while we run init, but we catch up
for proc in /proc/[0-9]*; do
    [ -x $proc/exe ] || continue
    [ $(readlink $proc/exe) != /sbin/udevd ] || kill ${proc#/proc/}
done

# udevd might have been in the middle of something when we killed it,
# but it doesn't matter because we'll do everything again in userspace
rm -rf /dev/.udev/queue

# cat squashfs boot trace
[ -f ${rootmnt}/dev/.squash.log ] && cat ${rootmnt}/dev/.squash.log >> /dev/.squash.log

# Move the real filesystem's /dev to beneath our tmpfs, then move it all
# to the real filesystem
mkdir -m 0700 -p /dev/.static/dev
mount -n -o bind ${rootmnt}/dev /dev/.static/dev
mount -n -o move /dev ${rootmnt}/dev
