Blame 0072-fs-lib-add-ability-to-choose-fsck-tools.patch

Harald Hoyer 55891e
From 25b45979f20e5b6b4dfb5a15b1b8f93bccc60625 Mon Sep 17 00:00:00 2001
Harald Hoyer 55891e
From: Michal Soltys <soltys@ziu.info>
Harald Hoyer 55891e
Date: Fri, 7 Oct 2011 22:23:51 +0200
Harald Hoyer 55891e
Subject: [PATCH] fs-lib: add ability to choose fsck tools
Harald Hoyer 55891e
Harald Hoyer 55891e
in dracut.conf:
Harald Hoyer 55891e
Harald Hoyer 55891e
fscks="<tools>"
Harald Hoyer 55891e
nofscks="yes"
Harald Hoyer 55891e
Harald Hoyer 55891e
and similary on command line:
Harald Hoyer 55891e
Harald Hoyer 55891e
--fscks [LIST] (in addition to conf's, if defined there)
Harald Hoyer 55891e
--nofscks
Harald Hoyer 55891e
Harald Hoyer 55891e
Signed-off-by: Michal Soltys <soltys@ziu.info>
Harald Hoyer 55891e
---
Harald Hoyer 55891e
 dracut                             |   13 ++++++++++++-
Harald Hoyer 55891e
 dracut.conf                        |    9 +++++++++
Harald Hoyer 55891e
 modules.d/99fs-lib/fs-lib.sh       |    6 +++---
Harald Hoyer 55891e
 modules.d/99fs-lib/module-setup.sh |   23 ++++++++++++++++-------
Harald Hoyer 55891e
 4 files changed, 40 insertions(+), 11 deletions(-)
Harald Hoyer 55891e
Harald Hoyer 55891e
diff --git a/dracut b/dracut
Harald Hoyer 55891e
index de13445..63d4ea6 100755
Harald Hoyer 55891e
--- a/dracut
Harald Hoyer 55891e
+++ b/dracut
Harald Hoyer 55891e
@@ -59,6 +59,8 @@ Creates initial ramdisk images for preloading modules
Harald Hoyer 55891e
   --nomdadmconf         Do not include local /etc/mdadm.conf
Harald Hoyer 55891e
   --lvmconf             Include local /etc/lvm/lvm.conf
Harald Hoyer 55891e
   --nolvmconf           Do not include local /etc/lvm/lvm.conf
Harald Hoyer 55891e
+  --fscks [LIST]        Add a space-separated list of fsck helpers.
Harald Hoyer 55891e
+  --nofscks             Inhibit installation of any fsck helpers.
Harald Hoyer 55891e
   -h, --help            This message
Harald Hoyer 55891e
   --debug               Output debug information of the build process
Harald Hoyer 55891e
   --profile             Output profile information of the build process
Harald Hoyer 55891e
@@ -204,6 +206,8 @@ while (($# > 0)); do
Harald Hoyer 55891e
         --filesystems) push_arg filesystems_l        "$@" || shift;;
Harald Hoyer 55891e
         -I|--install)  push_arg install_items        "$@" || shift;;
Harald Hoyer 55891e
         --fwdir)       push_arg fw_dir_l             "$@" || shift;;
Harald Hoyer 55891e
+        --fscks)       push_arg fscks_l              "$@" || shift;;
Harald Hoyer 55891e
+        --nofscks)     nofscks_l="yes";;
Harald Hoyer 55891e
         -k|--kmoddir)  read_arg drivers_dir_l        "$@" || shift;;
Harald Hoyer 55891e
         -c|--conf)     read_arg conffile             "$@" || shift;;
Harald Hoyer 55891e
         --confdir)     read_arg confdir              "$@" || shift;;
Harald Hoyer 55891e
@@ -324,6 +328,12 @@ if (( ${#add_drivers_l[@]} )); then
Harald Hoyer 55891e
     done
Harald Hoyer 55891e
 fi
Harald Hoyer 55891e
 
Harald Hoyer 55891e
+if (( ${#fscks_l[@]} )); then
Harald Hoyer 55891e
+    while pop fscks_l val; do
Harald Hoyer 55891e
+        fscks+=" $val "
Harald Hoyer 55891e
+    done
Harald Hoyer 55891e
+fi
Harald Hoyer 55891e
+
Harald Hoyer 55891e
 # these options override the stuff in the config file
Harald Hoyer 55891e
 if (( ${#dracutmodules_l[@]} )); then
Harald Hoyer 55891e
     dracutmodules=''
Harald Hoyer 55891e
@@ -379,6 +389,7 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
Harald Hoyer 55891e
 [[ $do_strip ]] || do_strip=no
Harald Hoyer 55891e
 [[ $compress_l ]] && compress=$compress_l
Harald Hoyer 55891e
 [[ $show_modules_l ]] && show_modules=$show_modules_l
Harald Hoyer 55891e
+[[ $nofscks_l ]] && nofscks="yes"
Harald Hoyer 55891e
 # eliminate IFS hackery when messing with fw_dir
Harald Hoyer 55891e
 fw_dir=${fw_dir//:/ }
Harald Hoyer 55891e
 
Harald Hoyer 55891e
@@ -488,7 +499,7 @@ chmod 755 "$initdir"
Harald Hoyer 55891e
 export initdir dracutbasedir dracutmodules drivers \
Harald Hoyer 55891e
     fw_dir drivers_dir debug no_kernel kernel_only \
Harald Hoyer 55891e
     add_drivers mdadmconf lvmconf filesystems \
Harald Hoyer 55891e
-    use_fstab libdir usrlibdir \
Harald Hoyer 55891e
+    use_fstab libdir usrlibdir fscks nofscks \
Harald Hoyer 55891e
     stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
Harald Hoyer 55891e
     debug
Harald Hoyer 55891e
 
Harald Hoyer 55891e
diff --git a/dracut.conf b/dracut.conf
Harald Hoyer 55891e
index 8684328..a502066 100644
Harald Hoyer 55891e
--- a/dracut.conf
Harald Hoyer 55891e
+++ b/dracut.conf
Harald Hoyer 55891e
@@ -29,3 +29,12 @@ mdadmconf="yes"
Harald Hoyer 55891e
 
Harald Hoyer 55891e
 # install local /etc/lvm/lvm.conf
Harald Hoyer 55891e
 lvmconf="yes"
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+# A list of fsck tools to install. If it's not specified, module's hardcoded
Harald Hoyer 55891e
+# default is used, currently: "umount mount /sbin/fsck* xfs_db xfs_check
Harald Hoyer 55891e
+# xfs_repair e2fsck jfs_fsck reiserfsck btrfsck". The installation is
Harald Hoyer 55891e
+# opportunistic, so non-existing tools are just ignored.
Harald Hoyer 55891e
+#fscks=""
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+# inhibit installation of any fsck tools
Harald Hoyer 55891e
+#nofscks="yes"
Harald Hoyer 55891e
diff --git a/modules.d/99fs-lib/fs-lib.sh b/modules.d/99fs-lib/fs-lib.sh
Harald Hoyer 55891e
index f36299a..772d5c0 100755
Harald Hoyer 55891e
--- a/modules.d/99fs-lib/fs-lib.sh
Harald Hoyer 55891e
+++ b/modules.d/99fs-lib/fs-lib.sh
Harald Hoyer 55891e
@@ -177,7 +177,7 @@ fsck_drv_std() {
Harald Hoyer 55891e
 # returns 255 if filesystem wasn't checked at all (e.g. due to lack of
Harald Hoyer 55891e
 # necessary tools or insufficient options)
Harald Hoyer 55891e
 fsck_single() {
Harald Hoyer 55891e
-    local FSTAB_FILE=/etc/fstab.fslib
Harald Hoyer 55891e
+    local FSTAB_FILE=/etc/fstab.empty
Harald Hoyer 55891e
     local _dev="$1"
Harald Hoyer 55891e
     local _fs="${2:-auto}"
Harald Hoyer 55891e
     local _fop="$3"
Harald Hoyer 55891e
@@ -197,13 +197,13 @@ fsck_single() {
Harald Hoyer 55891e
 # takes list of filesystems to check in parallel; we don't rely on automatic
Harald Hoyer 55891e
 # checking based on fstab, so empty one is passed
Harald Hoyer 55891e
 fsck_batch() {
Harald Hoyer 55891e
-    local FSTAB_FILE=/etc/fstab.fslib
Harald Hoyer 55891e
+    local FSTAB_FILE=/etc/fstab.empty
Harald Hoyer 55891e
     local _drv=fsck
Harald Hoyer 55891e
     local _dev
Harald Hoyer 55891e
     local _ret
Harald Hoyer 55891e
     local _out
Harald Hoyer 55891e
 
Harald Hoyer 55891e
-    [ $# -eq 0 ] && return 255
Harald Hoyer 55891e
+    [ $# -eq 0 ] || ! type fsck >/dev/null 2>&1 && return 255
Harald Hoyer 55891e
 
Harald Hoyer 55891e
     info "Checking filesystems (fsck -M -T -a):"
Harald Hoyer 55891e
     for _dev in "$@"; do
Harald Hoyer 55891e
diff --git a/modules.d/99fs-lib/module-setup.sh b/modules.d/99fs-lib/module-setup.sh
Harald Hoyer 55891e
index cbf69a5..68ea9b1 100755
Harald Hoyer 55891e
--- a/modules.d/99fs-lib/module-setup.sh
Harald Hoyer 55891e
+++ b/modules.d/99fs-lib/module-setup.sh
Harald Hoyer 55891e
@@ -11,13 +11,22 @@ depends() {
Harald Hoyer 55891e
 }
Harald Hoyer 55891e
 
Harald Hoyer 55891e
 install() {
Harald Hoyer 55891e
-    dracut_install -o umount mount xfs_db xfs_check xfs_repair
Harald Hoyer 55891e
-    dracut_install -o e2fsck
Harald Hoyer 55891e
-    dracut_install -o jfs_fsck
Harald Hoyer 55891e
-    dracut_install -o reiserfsck
Harald Hoyer 55891e
-    dracut_install -o btrfsck
Harald Hoyer 55891e
-    dracut_install -o /sbin/fsck*
Harald Hoyer 55891e
+    local _helpers
Harald Hoyer 55891e
 
Harald Hoyer 55891e
     inst "$moddir/fs-lib.sh" "/lib/fs-lib.sh"
Harald Hoyer 55891e
-    touch ${initdir}/etc/fstab.fslib
Harald Hoyer 55891e
+    touch ${initdir}/etc/fstab.empty
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    [[ "$nofscks" = "yes" ]] && return
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    if [[ "$fscks" = "${fscks#*[^ ]*}" ]]; then
Harald Hoyer 55891e
+        _helpers="\
Harald Hoyer 55891e
+            umount mount /sbin/fsck*
Harald Hoyer 55891e
+            xfs_db xfs_check xfs_repair
Harald Hoyer 55891e
+            e2fsck jfs_fsck reiserfsck btrfsck
Harald Hoyer 55891e
+        "
Harald Hoyer 55891e
+    else
Harald Hoyer 55891e
+        _helpers="$fscks"
Harald Hoyer 55891e
+    fi
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    dracut_install -o $_helpers
Harald Hoyer 55891e
 }