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>
---
init | 1 -
scripts/functions | 8 ++++----
scripts/local | 37 ++++++++++++++++++++++---------------
3 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/init b/init
index 5a5123c..60e76c3 100755
--- a/init
+++ b/init
@@ -79,7 +79,6 @@ for x in $(cat /proc/cmdline); do
;;
root=*)
ROOT=${x#root=}
- ROOT=$(resolve_device "$ROOT")
if [ -z "${BOOT}" ] && [ "$ROOT" = "/dev/nfs" ]; then
BOOT=nfs
fi
diff --git a/scripts/functions b/scripts/functions
index 4ac898d..5916a94 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -300,15 +300,15 @@ resolve_device() {
case "$DEV" in
LABEL=* | UUID=* | PARTLABEL=* | PARTUUID=*)
if command -v blkid >/dev/null 2>&1; then
- DEV="$(blkid -l -t "$DEV" -o device)"
+ DEV="$(blkid -l -t "$DEV" -o device)" || return 1
else
log_warning_msg "blkid not present, so cannot resolve $DEV"
+ return 1
fi
;;
esac
- # Only canonicalise if a valid file, in case $DEV isn't a filename
- [ -e "$DEV" ] && DEV=$(readlink -f "$DEV")
- echo "$DEV"
+ [ -e "$DEV" ] || return 1
+ readlink -f "$DEV"
}
# Check a file system.
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
Attachment:
signature.asc
Description: Digital signature