Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.kernel > #51841 > unrolled thread
| Started by | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| First post | 2015-12-22 22:50 +0100 |
| Last post | 2015-12-22 22:50 +0100 |
| Articles | 6 — 1 participant |
Back to article view | Back to linux.debian.kernel
[PATCH initramfs-tools 0/4] Fix resolution of device IDs Ben Hutchings <ben@decadent.org.uk> - 2015-12-22 22:50 +0100
[PATCH initramfs-tools 2/4] scripts/local: Name parameters to local_device_setup Ben Hutchings <ben@decadent.org.uk> - 2015-12-22 22:50 +0100
[PATCH initramfs-tools 4/4] scripts/functions: Stop resolving symlinks in resolve_device Ben Hutchings <ben@decadent.org.uk> - 2015-12-22 22:50 +0100
[PATCH initramfs-tools 1/4] scripts/local: Remove residual support for separate /etc filesystem Ben Hutchings <ben@decadent.org.uk> - 2015-12-22 22:50 +0100
[PATCH initramfs-tools 3/4] Defer resolving block device IDs to local_device_setup Ben Hutchings <ben@decadent.org.uk> - 2015-12-22 22:50 +0100
Re: [PATCH initramfs-tools 0/4] Fix resolution of device IDs Ben Hutchings <ben@decadent.org.uk> - 2015-12-22 22:50 +0100
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2015-12-22 22:50 +0100 |
| Subject | [PATCH initramfs-tools 0/4] Fix resolution of device IDs |
| Message-ID | <qICYF-QF-1@gated-at.bofh.it> |
[Multipart message — attachments visible in raw view] — view raw
This series fixes a serious regression on the master branch caused by
using blkid directly to resolve device IDs. It also fixes an
earlier regression in version 0.117.
Ben.
Ben Hutchings (4):
scripts/local: Remove residual support for separate /etc filesystem
scripts/local: Name parameters to local_device_setup
Defer resolving block device IDs to local_device_setup
scripts/functions: Stop resolving symlinks in resolve_device
init | 1 -
scripts/functions | 7 +++----
scripts/local | 47 ++++++++++++++++++++++++++++-------------------
3 files changed, 31 insertions(+), 24 deletions(-)
--
Ben Hutchings
Hoare's Law of Large Problems:
Inside every large problem is a small problem struggling to get out.
[toc] | [next] | [standalone]
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2015-12-22 22:50 +0100 |
| Subject | [PATCH initramfs-tools 2/4] scripts/local: Name parameters to local_device_setup |
| Message-ID | <qICYF-QF-5@gated-at.bofh.it> |
| In reply to | #51841 |
[Multipart message — attachments visible in raw view] — view raw
Using $1 and $2 in a function of this length isn't good practice.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
scripts/local | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/scripts/local b/scripts/local
index 7ae9117..2631df0 100644
--- a/scripts/local
+++ b/scripts/local
@@ -42,6 +42,9 @@ local_bottom()
# $2=optionname (for root and etc)
local_device_setup()
{
+ local dev="$1"
+ local name="$2"
+
wait_for_udev 10
# Load ubi with the correct MTD partition and return since fstype
@@ -53,7 +56,7 @@ local_device_setup()
# Don't wait for a root device that doesn't have a corresponding
# device in /dev (ie, mtd0)
- if [ "${1#/dev}" = "$1" ]; then
+ if [ "${dev#/dev}" = "${dev}" ]; then
return
fi
@@ -61,8 +64,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 "$1" ] || ! $(get_fstype "$1" >/dev/null); then
- log_begin_msg "Waiting for $2 file system"
+ if [ ! -e "${dev}" ] || ! $(get_fstype "${dev}" >/dev/null); then
+ log_begin_msg "Waiting for ${name} file system"
# Timeout is max(30, rootdelay) seconds (approximately)
slumber=30
@@ -72,8 +75,8 @@ local_device_setup()
while true; do
sleep 1
- local_block "$1"
- if [ -e "$1" ] && get_fstype "$1" >/dev/null; then
+ local_block "${dev}"
+ if [ -e "${dev}" ] && get_fstype "${dev}" >/dev/null; then
wait_for_udev 10
log_end_msg 0
break
@@ -87,15 +90,15 @@ local_device_setup()
fi
# We've given up, but we'll let the user fix matters if they can
- while [ ! -e "$1" ]; do
- echo "Gave up waiting for $2 device. Common problems:"
+ while [ ! -e "${dev}" ]; 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?)"
- if [ "$2" = root ]; then
+ if [ "${name}" = root ]; then
echo " - Check root= (did the system wait for the right device?)"
fi
echo " - Missing modules (cat /proc/modules; ls /dev)"
- panic "ALERT! $1 does not exist. Dropping to a shell!"
+ panic "ALERT! ${dev} does not exist. Dropping to a shell!"
done
}
[toc] | [prev] | [next] | [standalone]
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2015-12-22 22:50 +0100 |
| Subject | [PATCH initramfs-tools 4/4] scripts/functions: Stop resolving symlinks in resolve_device |
| Message-ID | <qICYF-QF-17@gated-at.bofh.it> |
| In reply to | #51841 |
[Multipart message — attachments visible in raw view] — view raw
Now that we use blkid directly, there is no need to resolve /dev/disk
symlinks. We shouldn't resolve any other symlinks we're given either,
as this causes /proc/mounts to be inconsistent with /etc/fstab.
Closes: #791754
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
scripts/functions | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/scripts/functions b/scripts/functions
index 5916a94..499a430 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -307,8 +307,7 @@ resolve_device() {
fi
;;
esac
- [ -e "$DEV" ] || return 1
- readlink -f "$DEV"
+ [ -e "$DEV" ] && echo "$DEV"
}
# Check a file system.
[toc] | [prev] | [next] | [standalone]
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2015-12-22 22:50 +0100 |
| Subject | [PATCH initramfs-tools 1/4] scripts/local: Remove residual support for separate /etc filesystem |
| Message-ID | <qICYG-QF-29@gated-at.bofh.it> |
| In reply to | #51841 |
[Multipart message — attachments visible in raw view] — view raw
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
scripts/local | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/scripts/local b/scripts/local
index 0f1d5b9..7ae9117 100644
--- a/scripts/local
+++ b/scripts/local
@@ -91,9 +91,8 @@ local_device_setup()
echo "Gave up waiting for $2 device. Common problems:"
echo " - Boot args (cat /proc/cmdline)"
echo " - Check rootdelay= (did the system wait long enough?)"
- # Only applies to root= and etc=:
- if [ "${2#/}" = "$2" ]; then
- echo " - Check $2= (did the system wait for the right device?)"
+ if [ "$2" = root ]; then
+ echo " - Check root= (did the system wait for the right device?)"
fi
echo " - Missing modules (cat /proc/modules; ls /dev)"
panic "ALERT! $1 does not exist. Dropping to a shell!"
[toc] | [prev] | [next] | [standalone]
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2015-12-22 22:50 +0100 |
| Subject | [PATCH initramfs-tools 3/4] Defer resolving block device IDs to local_device_setup |
| Message-ID | <qICYG-QF-23@gated-at.bofh.it> |
| In reply to | #51841 |
[Multipart message — attachments visible in raw view] — view raw
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
[toc] | [prev] | [next] | [standalone]
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Date | 2015-12-22 22:50 +0100 |
| Message-ID | <qICYG-QF-27@gated-at.bofh.it> |
| In reply to | #51841 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, 2015-12-22 at 21:41 +0000, Ben Hutchings wrote:
> This series fixes a serious regression on the master branch caused by
> using blkid directly to resolve device IDs. It also fixes an
> earlier regression in version 0.117.
As I didn't receive any review comments on previous patches, I'm not
going to wait for them this time. Instead I will merge these and make
a release straight away. Since there are so many changes since 0.120
I'll call this a release candidate (0.121~rc1 rather than 0.121).
Ben.
--
Ben Hutchings
Hoare's Law of Large Problems:
Inside every large problem is a small problem struggling to get out.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.kernel
csiph-web