From 70ff74f8b3d378d7153f9211bbe0e73713a87259 Mon Sep 17 00:00:00 2001 From: maximilian attems Date: Tue, 17 Feb 2009 18:00:16 +0100 Subject: Fix boot with LABEL containting one or several '/' As there is no /dev/disk/by-label//, we need to follow udev on escape the '/' character with \x2f don't rely on sed, as we might not have it in initramfs. (closes: #489008) Reported-by: Josh Triplett Tested-by: Andres Salomon thanks for dilinger to pushing the first easy solution to a complete, so we don't have to revisit the case. --- init | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/init b/init index 072d82c..7f549b1 100755 --- a/init +++ b/init @@ -62,7 +62,34 @@ for x in $(cat /proc/cmdline); do ROOT=${x#root=} case $ROOT in LABEL=*) - ROOT="/dev/disk/by-label/${ROOT#LABEL=}" + ROOT="${ROOT#LABEL=}" + + # support / in LABEL= paths (escape to \x2f) + case "${ROOT}" in + *[/]*) + if [ -x "$(command -v sed)" ]; then + ROOT="$(echo ${ROOT} | sed 's,/,\\x2f,g')" + else + if [ "${ROOT}" != "${ROOT#/}" ]; then + ROOT="\x2f${ROOT#/}" + fi + if [ "${ROOT}" != "${ROOT%/}" ]; then + ROOT="${ROOT%/}\x2f" + fi + IFS='/' + newroot= + for s in $ROOT; do + if [ -z "${newroot}" ]; then + newroot="${s}" + else + newroot="${newroot}\\x2f${s}" + fi + done + unset IFS + ROOT="${newroot}" + fi + esac + ROOT="/dev/disk/by-label/${ROOT}" ;; UUID=*) ROOT="/dev/disk/by-uuid/${ROOT#UUID=}" -- cgit v1.2.3