summaryrefslogtreecommitdiff
path: root/scripts/local
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2015-12-22 04:54:08 +0000
committerBen Hutchings <ben@decadent.org.uk>2015-12-22 05:22:00 +0000
commit3080087e9b9baa93fb8ac6dbe769cabc58eec01e (patch)
tree9e025683aaa288e8afd210a7b06018933b5cf39f /scripts/local
parent14913b2aa65e11c590b6b7124b70f69cbb8b9878 (diff)
Defer resolving block device IDs to local_device_setup
Since we now invoke blkid to resolve block device IDs rather than relying on symlinks under /dev/disk, resolve_device just doesn't work until the specified device exists. So we need to use it in the multiple existence checks in local_device_setup, and nowhere else. Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'scripts/local')
-rw-r--r--scripts/local37
1 files changed, 22 insertions, 15 deletions
diff --git a/scripts/local b/scripts/local
index 2631df0..af56e66 100644
--- a/scripts/local
+++ b/scripts/local
@@ -38,12 +38,14 @@ local_bottom()
local_top_used=no
}
-# $1=device to mount
+# $1=device ID to mount
# $2=optionname (for root and etc)
+# Sets $DEV to the resolved device node
local_device_setup()
{
- local dev="$1"
+ local dev_id="$1"
local name="$2"
+ local real_dev
wait_for_udev 10
@@ -51,12 +53,15 @@ local_device_setup()
# doesn't work with a char device like ubi.
if [ -n "$UBIMTD" ]; then
modprobe ubi mtd=$UBIMTD
+ DEV="${dev_id}"
return
fi
- # Don't wait for a root device that doesn't have a corresponding
- # device in /dev (ie, mtd0)
- if [ "${dev#/dev}" = "${dev}" ]; then
+ # Don't wait for a device that doesn't have a corresponding
+ # device in /dev and isn't resolvable by blkid (e.g. mtd0)
+ if [ "${dev_id#/dev}" = "${dev_id}" ] &&
+ [ "${dev_id#*=}" = "${dev_id}" ]; then
+ DEV="${dev_id}"
return
fi
@@ -64,7 +69,8 @@ local_device_setup()
# to allow for asynchronous device discovery (e.g. USB). We
# also need to keep invoking the local-block scripts in case
# there are devices stacked on top of those.
- if [ ! -e "${dev}" ] || ! $(get_fstype "${dev}" >/dev/null); then
+ if ! real_dev=$(resolve_device "${dev_id}") ||
+ ! get_fstype "${real_dev}" >/dev/null; then
log_begin_msg "Waiting for ${name} file system"
# Timeout is max(30, rootdelay) seconds (approximately)
@@ -75,8 +81,9 @@ local_device_setup()
while true; do
sleep 1
- local_block "${dev}"
- if [ -e "${dev}" ] && get_fstype "${dev}" >/dev/null; then
+ local_block "${dev_id}"
+ if real_dev=$(resolve_device "${dev_id}") &&
+ get_fstype "${real_dev}" >/dev/null; then
wait_for_udev 10
log_end_msg 0
break
@@ -90,7 +97,8 @@ local_device_setup()
fi
# We've given up, but we'll let the user fix matters if they can
- while [ ! -e "${dev}" ]; do
+ while ! real_dev=$(resolve_device "${dev_id}") ||
+ ! get_fstype "${real_dev}" >/dev/null; do
echo "Gave up waiting for ${name} device. Common problems:"
echo " - Boot args (cat /proc/cmdline)"
echo " - Check rootdelay= (did the system wait long enough?)"
@@ -98,14 +106,17 @@ local_device_setup()
echo " - Check root= (did the system wait for the right device?)"
fi
echo " - Missing modules (cat /proc/modules; ls /dev)"
- panic "ALERT! ${dev} does not exist. Dropping to a shell!"
+ panic "ALERT! ${dev_id} does not exist. Dropping to a shell!"
done
+
+ DEV="${real_dev}"
}
local_mount_root()
{
local_top
local_device_setup "${ROOT}" root
+ ROOT="${DEV}"
# Get the root filesystem type if not set
if [ -z "${ROOTFSTYPE}" ]; then
@@ -116,8 +127,6 @@ local_mount_root()
local_premount
- ROOT=$(resolve_device "$ROOT")
-
if [ "${readonly}" = "y" ]; then
roflag=-r
else
@@ -141,14 +150,12 @@ local_mount_root()
local_mount_fs()
{
read_fstab_entry "$1"
- MNT_FSNAME=$(resolve_device "$MNT_FSNAME")
local_device_setup "$MNT_FSNAME" "$1"
+ MNT_FSNAME="${DEV}"
local_premount
- MNT_FSNAME=$(resolve_device "$MNT_FSNAME")
-
if [ "${readonly}" = "y" ]; then
roflag=-r
else