Skip to content

Commit

Permalink
init_functions: escape slashes in tag values
Browse files Browse the repository at this point in the history
This allows booting from devices which have labels like LABEL=/.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
  • Loading branch information
falconindy committed Nov 27, 2013
1 parent a1e50f0 commit 9e2c162
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions init_functions
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 9e2c162

Please sign in to comment.