
# Check if we already have a mounted config partition
bootpart=$(mount | grep /etc/shared | awk '{ print $1 }')
if [ ! -z "$bootpart" ]; then
	exit 0
fi
# Check if there is an eMMC boot partition with a FAT
# filesystem labeled "config"
mkdir -p /etc/shared
for bootpart_sys in `find /sys/class/mmc_host/mmc*/*/block/mmcblk*/mmcblk*boot? -maxdepth 0`; do
	bootpart=$(basename $bootpart_sys)
	# We are called from /etc/init.d/rcS in the first place, so udev has
	# not created the device nodes, yet. If it does not exist, create it.
	if [ ! -e /dev/$bootpart ]; then
		major=$(awk -F : '{print $1}' $bootpart_sys/dev)
		minor=$(awk -F : '{print $2}' $bootpart_sys/dev)
		mknod -m 660 /dev/$bootpart b $major $minor
	fi
	bootpart_label=`(dosfslabel /dev/$bootpart 2> /dev/null || echo "(none)") | tr [:upper:] [:lower:]`
	if [ $bootpart_label == "config" ]; then
		echo 0 > /sys/block/$bootpart/force_ro
		mount /dev/$bootpart /etc/shared -t vfat 2>/dev/null
		echo "$bootpart"
		exit 0
	fi
done
exit 1
