From 9e2c16294bd6281ecbf7ab96e9b14a10154c4f01 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 16 Nov 2013 12:46:59 -0500 Subject: init_functions: escape slashes in tag values This allows booting from devices which have labels like LABEL=/. Signed-off-by: Dave Reisner --- init_functions | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/init_functions b/init_functions index 474d6fa..11ce3ca 100644 --- a/init_functions +++ b/init_functions @@ -252,6 +252,16 @@ fsck_root() { fi } +# TODO: this really needs to follow the logic of systemd's encode_devnode_name +# function more closely. +tag_to_udev_path() { + awk -v "tag=$1" -v "value=$2" ' + BEGIN { + gsub(/\//, "\\x2f", value) + printf "/dev/disk/by-%s/%s\n", tolower(tag), value + }' +} + resolve_device() { local major minor dev tag device=$1 @@ -264,8 +274,7 @@ resolve_device() { UUID=*|LABEL=*|PARTUUID=*|PARTLABEL=*) dev=$(blkid -lt "$device" -o device) if [ -z "$dev" -a "$udevd_running" -eq 1 ]; then - tag=$(awk -v t="${device%%=*}" 'BEGIN { print tolower(t) }') - dev=/dev/disk/by-$tag/${device#*=} + dev=$(tag_to_udev_path "${device%%=*}" "${device#*=}") fi esac -- cgit v1.2.3-24-g4f1b