Blame 0048-rootfs-block-module-setup.sh-add-support-for-xfs-rei.patch

Harald Hoyer 12f6cc
From 3cc4c8ba9b43ff646701d4236c1a70860c16d02c Mon Sep 17 00:00:00 2001
Harald Hoyer 12f6cc
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 12f6cc
Date: Thu, 26 Jul 2012 17:00:47 +0200
Harald Hoyer 12f6cc
Subject: [PATCH] rootfs-block/module-setup.sh: add support for xfs / reiserfs
Harald Hoyer 12f6cc
 separate journal device
Harald Hoyer 12f6cc
Harald Hoyer 12f6cc
xfs and reiserfs (among other) supports storing journal data to a
Harald Hoyer 12f6cc
separate device. Unfortunately, XFS requires this information to boot
Harald Hoyer 12f6cc
properly (reiserfs can embed the information in its metadata but you
Harald Hoyer 12f6cc
might want to override it).
Harald Hoyer 12f6cc
Harald Hoyer 12f6cc
Frederic Crozat <fcrozat@suse.com>
Harald Hoyer 12f6cc
---
Harald Hoyer 12f6cc
 modules.d/95rootfs-block/module-setup.sh | 41 ++++++++++++++++++++++++++++++++
Harald Hoyer 12f6cc
 1 file changed, 41 insertions(+)
Harald Hoyer 12f6cc
Harald Hoyer 12f6cc
diff --git a/modules.d/95rootfs-block/module-setup.sh b/modules.d/95rootfs-block/module-setup.sh
Harald Hoyer 12f6cc
index 243a174..4d87fab 100755
Harald Hoyer 12f6cc
--- a/modules.d/95rootfs-block/module-setup.sh
Harald Hoyer 12f6cc
+++ b/modules.d/95rootfs-block/module-setup.sh
Harald Hoyer 12f6cc
@@ -2,6 +2,47 @@
Harald Hoyer 12f6cc
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
Harald Hoyer 12f6cc
 # ex: ts=8 sw=4 sts=4 et filetype=sh
Harald Hoyer 12f6cc
 
Harald Hoyer 12f6cc
+search_option() {
Harald Hoyer 12f6cc
+    rootopts=$1
Harald Hoyer 12f6cc
+    option=$2
Harald Hoyer 12f6cc
+    local OLDIFS="$IFS"
Harald Hoyer 12f6cc
+    IFS=,
Harald Hoyer 12f6cc
+    set -- $rootopts
Harald Hoyer 12f6cc
+    IFS="$OLDIFS"
Harald Hoyer 12f6cc
+    while [ $# -gt 0 ]; do
Harald Hoyer 12f6cc
+        case $1 in
Harald Hoyer 12f6cc
+            $option=*)
Harald Hoyer 12f6cc
+                echo ${1#${option}=}
Harald Hoyer 12f6cc
+                break
Harald Hoyer 12f6cc
+        esac
Harald Hoyer 12f6cc
+        shift
Harald Hoyer 12f6cc
+    done
Harald Hoyer 12f6cc
+}
Harald Hoyer 12f6cc
+
Harald Hoyer 12f6cc
+check() {
Harald Hoyer 12f6cc
+        rootopts="defaults"
Harald Hoyer 12f6cc
+        while read dev mp fs opts dump fsck; do
Harald Hoyer 12f6cc
+            # skip comments
Harald Hoyer 12f6cc
+            [ "${dev%%#*}" != "$dev" ] && continue
Harald Hoyer 12f6cc
+
Harald Hoyer 12f6cc
+            if [ "$mp" = "/" ]; then
Harald Hoyer 12f6cc
+                # sanity - determine/fix fstype
Harald Hoyer 12f6cc
+                rootfs=$(find_mp_fstype /)
Harald Hoyer 12f6cc
+                rootfs=${rootfs:-$fs}
Harald Hoyer 12f6cc
+                rootopts=$opts
Harald Hoyer 12f6cc
+                break
Harald Hoyer 12f6cc
+            fi
Harald Hoyer 12f6cc
+        done < "$NEWROOT/etc/fstab"
Harald Hoyer 12f6cc
+
Harald Hoyer 12f6cc
+        [ "$rootfs" = "reiserfs" ] && journaldev=$(search_option $rootopts "jdev")
Harald Hoyer 12f6cc
+        [ "$rootfs" = "xfs" ] && journaldev=$(search_option $rootopts "logdev")
Harald Hoyer 12f6cc
+        if [ -n "$journaldev" ]; then
Harald Hoyer 12f6cc
+            echo "root.journaldev=$journaldev" >> "${initdir}/etc/cmdline.d/95root-jurnaldev.conf"
Harald Hoyer 12f6cc
+        fi
Harald Hoyer 12f6cc
+    return 0
Harald Hoyer 12f6cc
+
Harald Hoyer 12f6cc
+}
Harald Hoyer 12f6cc
+
Harald Hoyer 12f6cc
 depends() {
Harald Hoyer 12f6cc
     echo fs-lib
Harald Hoyer 12f6cc
 }