Blob Blame History Raw
From c4b572b5ca767aec6cc8b5ba98b5fc76c991f690 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 4 Apr 2013 12:51:33 +0200
Subject: [PATCH] base/dracut-lib.sh: add dev_unit_name()

add helper function to convert device path to systemd unit names
---
 modules.d/99base/dracut-lib.sh | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index e456b01..79fc953 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -818,6 +818,15 @@ wait_for_mount()
     } >> "$hookdir/emergency/90-${_name}.sh"
 }
 
+dev_unit_name()
+{
+    _name="${1%%/}"
+    _name="${_name##/}"
+    _name="$(str_replace "$_name" '-' '\x2d')"
+    _name="$(str_replace "$_name" '/' '-')"
+    echo "$_name"
+}
+
 # wait_for_dev <dev>
 #
 # Installs a initqueue-finished script,
@@ -835,10 +844,7 @@ wait_for_dev()
     } >> "${PREFIX}$hookdir/emergency/80-${_name}.sh"
 
     if [ -n "$DRACUT_SYSTEMD" ]; then
-        _name="${1%%/}"
-        _name="${_name##/}"
-        _name="$(str_replace "$_name" '-' '\x2d')"
-        _name="$(str_replace "$_name" '/' '-')"
+        _name=$(dev_unit_name "$1")
         if ! [ -L ${PREFIX}/etc/systemd/system/initrd.target.requires/${_name}.device ]; then
             [ -d ${PREFIX}/etc/systemd/system/initrd.target.requires ] || mkdir -p ${PREFIX}/etc/systemd/system/initrd.target.requires
             ln -s ../${_name}.device ${PREFIX}/etc/systemd/system/initrd.target.requires/${_name}.device