summaryrefslogtreecommitdiffstats
path: root/init_functions
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-11-16 18:46:59 +0100
committerDave Reisner <dreisner@archlinux.org>2013-11-27 21:16:00 +0100
commit9e2c16294bd6281ecbf7ab96e9b14a10154c4f01 (patch)
tree011b9f8e6e43c4a6f47d314ce312872a529ace2b /init_functions
parenta1e50f04b89ff042baf91a403a6df0cbd1e3cec2 (diff)
downloadmkinitcpio-9e2c16294bd6281ecbf7ab96e9b14a10154c4f01.tar.gz
mkinitcpio-9e2c16294bd6281ecbf7ab96e9b14a10154c4f01.tar.xz
init_functions: escape slashes in tag values
This allows booting from devices which have labels like LABEL=/. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'init_functions')
-rw-r--r--init_functions13
1 files 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