[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#801154: [PATCH initramfs-tools 1/2] scripts/functions: Use blkid to resolve LABEL= and UUID= block device IDs



This is a preparatory patch for fixing #801154.

Ben.
---
This means we will deal correctly with various other characters than
'/' that also need to be escaped.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 scripts/functions | 32 +++++---------------------------
 1 file changed, 5 insertions(+), 27 deletions(-)

diff --git a/scripts/functions b/scripts/functions
index aa53010..8f2fac7 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -297,35 +297,13 @@ read_fstab_entry() {
 resolve_device() {
 	DEV="$1"
 
-	case $DEV in
-	LABEL=*)
-		DEV="${DEV#LABEL=}"
-
-		# support any / in LABEL= path (escape to \x2f)
-		case "${DEV}" in
-		*/*)
-		if command -v sed >/dev/null 2>&1; then
-			DEV="$(echo ${DEV} | sed 's,/,\\x2f,g')"
+	case "$DEV" in
+	LABEL=* | UUID=*)
+		if command -v blkid >/dev/null 2>&1; then
+			DEV="$(blkid -l -t "$DEV" -o device)"
 		else
-			if [ "${DEV}" != "${DEV#/}" ]; then
-				DEV="\x2f${DEV#/}"
-			fi
-			if [ "${DEV}" != "${DEV%/}" ]; then
-				DEV="${DEV%/}\x2f"
-			fi
-			IFS='/'
-			newroot=
-			for s in $DEV; do
-				newroot="${newroot:+${newroot}\\x2f}${s}"
-			done
-			unset IFS
-			DEV="${newroot}"
+			log_warning_msg "blkid not present, so cannot resolve $DEV"
 		fi
-		esac
-		DEV="/dev/disk/by-label/${DEV}"
-		;;
-	UUID=*)
-		DEV="/dev/disk/by-uuid/${DEV#UUID=}"
 		;;
 	esac
 	# Only canonicalise if a valid file, in case $DEV isn't a filename

Attachment: signature.asc
Description: Digital signature


Reply to: