|
Harald Hoyer |
b94732 |
From e3eec4b8a21a640b7557678b92716a32f8d3dadf Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
b94732 |
From: Thorsten Behrens <tbehrens@suse.com>
|
|
Harald Hoyer |
b94732 |
Date: Thu, 11 Dec 2014 15:46:08 +0100
|
|
Harald Hoyer |
b94732 |
Subject: [PATCH] Align dev_unit_name() with systemd's function.
|
|
Harald Hoyer |
b94732 |
|
|
Harald Hoyer |
b94732 |
Add more corner cases from systemd's
|
|
Harald Hoyer |
b94732 |
unit_name_from_path_instance() C function.
|
|
Harald Hoyer |
b94732 |
|
|
Harald Hoyer |
b94732 |
Signed-off-by: Thorsten Behrens <tbehrens@suse.com>
|
|
Harald Hoyer |
b94732 |
Signed-off-by: Thomas Renninger <trenn@suse.de>
|
|
Harald Hoyer |
b94732 |
---
|
|
Harald Hoyer |
b94732 |
modules.d/99base/dracut-lib.sh | 24 ++++++++++++++++++------
|
|
Harald Hoyer |
b94732 |
1 file changed, 18 insertions(+), 6 deletions(-)
|
|
Harald Hoyer |
b94732 |
|
|
Harald Hoyer |
b94732 |
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
|
|
Harald Hoyer |
b94732 |
index f7cffc4..5c1504f 100755
|
|
Harald Hoyer |
b94732 |
--- a/modules.d/99base/dracut-lib.sh
|
|
Harald Hoyer |
b94732 |
+++ b/modules.d/99base/dracut-lib.sh
|
|
Harald Hoyer |
b94732 |
@@ -866,18 +866,30 @@ wait_for_mount()
|
|
Harald Hoyer |
b94732 |
} >> "$hookdir/emergency/90-${_name}.sh"
|
|
Harald Hoyer |
b94732 |
}
|
|
Harald Hoyer |
b94732 |
|
|
Harald Hoyer |
b94732 |
+# get a systemd-compatible unit name from a path
|
|
Harald Hoyer |
b94732 |
+# (mimicks unit_name_from_path_instance())
|
|
Harald Hoyer |
b94732 |
dev_unit_name()
|
|
Harald Hoyer |
b94732 |
{
|
|
Harald Hoyer |
b94732 |
+ local dev="$1"
|
|
Harald Hoyer |
b94732 |
+
|
|
Harald Hoyer |
b94732 |
if command -v systemd-escape >/dev/null; then
|
|
Harald Hoyer |
b94732 |
- systemd-escape -p "$1"
|
|
Harald Hoyer |
b94732 |
+ systemd-escape -p "$dev"
|
|
Harald Hoyer |
b94732 |
return
|
|
Harald Hoyer |
b94732 |
fi
|
|
Harald Hoyer |
b94732 |
|
|
Harald Hoyer |
b94732 |
- _name="${1%%/}"
|
|
Harald Hoyer |
b94732 |
- _name="${_name##/}"
|
|
Harald Hoyer |
b94732 |
- _name="$(str_replace "$_name" '-' '\x2d')"
|
|
Harald Hoyer |
b94732 |
- _name="$(str_replace "$_name" '/' '-')"
|
|
Harald Hoyer |
b94732 |
- echo "$_name"
|
|
Harald Hoyer |
b94732 |
+ if [ "$dev" = "/" -o -z "$dev" ]; then
|
|
Harald Hoyer |
b94732 |
+ printf -- "-"
|
|
Harald Hoyer |
b94732 |
+ exit 0
|
|
Harald Hoyer |
b94732 |
+ fi
|
|
Harald Hoyer |
b94732 |
+
|
|
Harald Hoyer |
b94732 |
+ dev="${1%%/}"
|
|
Harald Hoyer |
b94732 |
+ dev="${dev##/}"
|
|
Harald Hoyer |
b94732 |
+ dev="$(str_replace "$dev" '\' '\x5c')"
|
|
Harald Hoyer |
b94732 |
+ dev="$(str_replace "$dev" '-' '\x2d')"
|
|
Harald Hoyer |
b94732 |
+ dev=${dev/#\./\\x2e}
|
|
Harald Hoyer |
b94732 |
+ dev="$(str_replace "$dev" '/' '-')"
|
|
Harald Hoyer |
b94732 |
+
|
|
Harald Hoyer |
b94732 |
+ printf -- "%s" "$dev"
|
|
Harald Hoyer |
b94732 |
}
|
|
Harald Hoyer |
b94732 |
|
|
Harald Hoyer |
b94732 |
# wait_for_dev <dev>
|