Blob Blame History Raw
From 8aa9926839dc8ee861a44d21ae71fb33eee04ed1 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 26 Jul 2012 17:22:14 +0200
Subject: [PATCH] mv rootfs-block/module-setup.sh:search_option() in
 dracut-functions.sh

new function fs_get_option()
---
 dracut-functions.sh                      | 20 ++++++++++++++++++++
 modules.d/95rootfs-block/module-setup.sh | 21 ++-------------------
 2 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/dracut-functions.sh b/dracut-functions.sh
index df450ef..fb28bdc 100755
--- a/dracut-functions.sh
+++ b/dracut-functions.sh
@@ -454,6 +454,26 @@ check_vol_slaves() {
     return 1
 }
 
+# fs_get_option <filesystem options> <search for option>
+# search for a specific option in a bunch of filesystem options
+# and return the value
+fs_get_option() {
+    local _fsopts=$1
+    local _option=$2
+    local OLDIFS="$IFS"
+    IFS=,
+    set -- $_fsopts
+    IFS="$OLDIFS"
+    while [ $# -gt 0 ]; do
+        case $1 in
+            $_option=*)
+                echo ${1#${_option}=}
+                break
+        esac
+        shift
+    done
+}
+
 if [[ $DRACUT_INSTALL ]]; then
     [[ $DRACUT_RESOLVE_LAZY ]] || export DRACUT_RESOLVE_DEPS=1
     inst_dir() {
diff --git a/modules.d/95rootfs-block/module-setup.sh b/modules.d/95rootfs-block/module-setup.sh
index 4d87fab..8254289 100755
--- a/modules.d/95rootfs-block/module-setup.sh
+++ b/modules.d/95rootfs-block/module-setup.sh
@@ -2,23 +2,6 @@
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 
-search_option() {
-    rootopts=$1
-    option=$2
-    local OLDIFS="$IFS"
-    IFS=,
-    set -- $rootopts
-    IFS="$OLDIFS"
-    while [ $# -gt 0 ]; do
-        case $1 in
-            $option=*)
-                echo ${1#${option}=}
-                break
-        esac
-        shift
-    done
-}
-
 check() {
         rootopts="defaults"
         while read dev mp fs opts dump fsck; do
@@ -34,8 +17,8 @@ check() {
             fi
         done < "$NEWROOT/etc/fstab"
 
-        [ "$rootfs" = "reiserfs" ] && journaldev=$(search_option $rootopts "jdev")
-        [ "$rootfs" = "xfs" ] && journaldev=$(search_option $rootopts "logdev")
+        [ "$rootfs" = "reiserfs" ] && journaldev=$(fs_get_option $rootopts "jdev")
+        [ "$rootfs" = "xfs" ] && journaldev=$(fs_get_option $rootopts "logdev")
         if [ -n "$journaldev" ]; then
             echo "root.journaldev=$journaldev" >> "${initdir}/etc/cmdline.d/95root-jurnaldev.conf"
         fi