Skip to contentSkip to conversation

options to configure fs-lib (fsck) and two unrelated fixes

PATCH In review Michal Soltys 3 participants 11 messages Sep 30, 2011 – Oct 10, 2011 4 messages not in the archive

lore
Share & tools
lore
#0 lore raw

cover options to configure fs-lib (fsck) and two unrelated fixes

First two patches are unreleated fixups, the other two implement options to configure fs-lib (which fscks to include in the image).

The following changes since commit d23159a69c818274486f1287ba6267b96f3febb7:

dracut [PATCH]es: parallelize block_module filter and net_module_filter (2011-09-30 09:40:49 +0200)

are available in the git repository at:
git://git.hasevolq.net/dracut.git fixup

Michal Soltys (4):
convert_abs_rel() fixups
dracut.8: add missing lvmconf info
fs-lib: add ability to choose fsck tools
manuals: add info about fs-lib (fsck) configuration

 dracut                             |   13 ++++++++++++-
 dracut-functions                   |   18 +++++++++++-------
 dracut.8.xml                       |   36 ++++++++++++++++++++++++++++++++++++
 dracut.conf                        |    9 +++++++++
 dracut.conf.5.xml                  |   22 ++++++++++++++++++++++
 modules.d/99fs-lib/fs-lib.sh       |    6 +++---
 modules.d/99fs-lib/module-setup.sh |   23 ++++++++++++++++-------
 7 files changed, 109 insertions(+), 18 deletions(-)
#1 lore raw
Quoted 10 lines · Michal Soltys

First two patches are unreleated fixups, the other two implement options to configure fs-lib (which fscks to include in the image).

The following changes since commit
d23159a69c818274486f1287ba6267b96f3febb7:

dracut [PATCH]es: parallelize block_module filter and net_module_filter (2011-09-30 09:40:49 +0200)

Quoted 8 lines

are available in the git repository at:
git://git.hasevolq.net/dracut.git fixup

Michal Soltys (4):
convert_abs_rel() fixups
dracut.8: add missing lvmconf info
fs-lib: add ability to choose fsck tools manuals: add info about fs-lib (fsck) configuration

But I only saw patch 0/4, where are the rest? :-/

#2 lore raw
Quoted 3 lines · WANG Cong

But I only saw patch 0/4, where are the rest? :-/

I prepared it as a remote branch (git fetch git:// etc.). I'll send normal mails in a moment.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 8 lines · Michal Soltys
Quoted 3 lines · WANG Cong

But I only saw patch 0/4, where are the rest? :-/

I prepared it as a remote branch (git fetch git:// etc.). I'll send normal mails in a moment.

Please. If you don't send patches to this mailing list, it is not convenient for people to review them.

Thanks.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

PATCH 1/4 convert_abs_rel() fixups

- IFS was not preserved, and modified value could leak to outside functions

- the '.' relative path should be returned for arguments such as /x/y/z /x/y - but not for $1 == $2 ones

- $1 == $2 is self-looping link, so it returns final component of its name

---
 dracut-functions |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
dracut-functions +11 -7
index c4f7f61..12dfa70 100755
@@ -91,20 +91,24 @@ normalize_path() {
 }
 
 convert_abs_rel() {
-    local __current __absolute __abssize __cursize __i __level __newpath
+    local __current __absolute __abssize __cursize __newpath="" __oldifs
+    local -i __i __level=0
 #    PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
 
-    if [[ "$1" == "$2" ]]
-    then
-        echo "."
-        return
-    fi
+    # corner case #1 - self looping link
+    [[ "$1" == "$2" ]] && { echo "${1##*/}"; return; }
+
+    # corner case #2 - own dir link
+    [[ "${1%/*}" == "$2" ]] && { echo "."; return; }
+
     __current=$(normalize_path "$1")
     __absolute=$(normalize_path "$2")
-    IFS="/"
 
+    __oldifs="$IFS"
+    IFS="/"
     __current=($__current)
     __absolute=($__absolute)
+    IFS="$__oldifs"
 
     __abssize=${#__absolute[@]}
     __cursize=${#__current[@]}
Signature · 1 line
1.7.5.3
#7 lore raw

PATCH 2/4 dracut.8: add missing lvmconf info

In reply to a message not in the archive
---
 dracut.8.xml |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
dracut.8.xml +17 -0
index 11ea8c3..7e5a6d6 100644
@@ -1,5 +1,6 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <!-- This document was created with Syntext Serna Free. --><!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
+<!-- vim: set ts=8 sts=2 sw=2 et: -->
 <refentry id="dracut8">
   <refentryinfo>
     <title>dracut</title>
@@ -229,6 +230,22 @@ include in the generic initramfs. This parameter can be specified multiple times
         </varlistentry>
         <varlistentry>
           <term>
+            <option>--lvmconf</option>
+          </term>
+          <listitem>
+            <para>include local <filename>/etc/lvm/lvm.conf</filename></para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>
+            <option>--nolvmconf</option>
+          </term>
+          <listitem>
+            <para>do not include local <filename>/etc/lvm/lvm.conf</filename></para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>
             <option>--strip</option>
           </term>
           <listitem>
Signature · 1 line
1.7.5.3
#8 lore raw

PATCH 3/4 fs-lib: add ability to choose fsck tools

In reply to a message not in the archive

in dracut.conf:

fscks="<tools>"
nofscks="yes"

and similary on command line:

--fscks [LIST] (in addition to conf's, if defined there) --nofscks

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

PATCH 4/4 manuals: add info about fs-lib (fsck) configuration

In reply to a message not in the archive

in dracut.8.xml & dracut.conf.5.xml

---
 dracut.8.xml      |   19 +++++++++++++++++++
 dracut.conf.5.xml |   22 ++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)
dracut.8.xml +19 -0
index 7e5a6d6..a7ce5ab 100644
@@ -246,6 +246,25 @@ include in the generic initramfs. This parameter can be specified multiple times
         </varlistentry>
         <varlistentry>
           <term>
+            <option>--fscks [LIST]</option>
+          </term>
+          <listitem>
+            <para>add a space-separated list of fsck tools, in addition to
+              <filename>dracut.conf</filename>'s specification; the
+              installation is opportunistic (non-exisiting tools are ignored)
+            </para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>
+            <option>--nofscks</option>
+          </term>
+          <listitem>
+            <para>inhibit installation of any fsck tools</para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>
             <option>--strip</option>
           </term>
           <listitem>
dracut.conf.5.xml +22 -0
index 697e655..dbcdb90 100644
@@ -1,5 +1,6 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <!-- This document was created with Syntext Serna Free. --><!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
+<!-- vim: set ts=8 sts=2 sw=2 et: -->
 <refentry id="dracutconf5">
   <refentryinfo>
     <title>dracut.conf</title>
@@ -156,6 +157,27 @@ initramfs.</para>
       </varlistentry>
       <varlistentry>
         <term>
+          <envar>fscks=&quot;&nbsp;<replaceable>&lt;fsck tools&gt;</replaceable>&nbsp;&quot;</envar>
+        </term>
+        <listitem>
+          <para>Add a space-separated list of fsck tools. If nothing is
+            specified, the default is: &quot;<replaceable>umount mount
+            /sbin/fsck* xfs_db xfs_check xfs_repair e2fsck jfs_fsck
+            reiserfsck btrfsck</replaceable>&quot;
+          </para>
+          <para>The installation is opportunistic (non-exisiting tools are ignored).<para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
+          <envar>nofscks=&quot;<replaceable>{yes}</replaceable>&quot;</envar>
+        </term>
+        <listitem>
+          <para>If specified, inhibit installation of any fsck tools.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>
           <envar>kernel_only=&quot;<replaceable>{yes|no}</replaceable>&quot;</envar>
         </term>
         <listitem>
Signature · 1 line
1.7.5.3
#10 lore raw

minor corrections

In reply to a message not in the archive

No need for unsetting vars in [1/4]; apart from that - make sure we remove trailing slashes, and normalize before checks.

Michal Soltys (1):
dracut-functions: conv/normalize minor corrections

 dracut-functions |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
Signature · 1 line
1.7.5.3

A message that is not in the archive (sent off-list or not yet received): 1318026050-5891-1-git-send-email-soltys-R61QfzASbfY@public.gmane.org

#12 lore raw

[PATCH 5/4] dracut-functions: conv/normalize minor corrections

mostly with reference to earlier commit:

- bash doesn't need unsetting locals
- make normalize_path() a bit faster, also make sure we remove all trailing slashes
- normalize paths before tests

---
 dracut-functions |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
dracut-functions +10 -12
index 12dfa70..ce593c9 100755
@@ -83,31 +83,29 @@ print_vars() {
 }
 
 normalize_path() {
-    p=$1
-    while [[ ${p#*//*} != $p ]]; do
-        p=${p/\/\///}
-    done
-    echo $p
+    shopt -q -s extglob
+    set -- "${1//+(\/)//}"
+    shopt -q -u extglob
+    echo "${1%/}"
 }
 
 convert_abs_rel() {
-    local __current __absolute __abssize __cursize __newpath="" __oldifs
-    local -i __i __level=0
+    local __current __absolute __abssize __cursize __newpath __oldifs
+    local -i __i __level
 #    PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
 
+    set -- "$(normalize_path "$1")" "$(normalize_path "$2")"
+
     # corner case #1 - self looping link
     [[ "$1" == "$2" ]] && { echo "${1##*/}"; return; }
 
     # corner case #2 - own dir link
     [[ "${1%/*}" == "$2" ]] && { echo "."; return; }
 
-    __current=$(normalize_path "$1")
-    __absolute=$(normalize_path "$2")
-
     __oldifs="$IFS"
     IFS="/"
-    __current=($__current)
-    __absolute=($__absolute)
+    __current=($1)
+    __absolute=($2)
     IFS="$__oldifs"
 
     __abssize=${#__absolute[@]}
Signature · 1 line
1.7.5.3

A message that is not in the archive (sent off-list or not yet received): 1318026050-5891-2-git-send-email-soltys-R61QfzASbfY@public.gmane.org

#14 lore raw

Re: [PATCH 5/4] dracut-functions: conv/normalize minor corrections

Quoted 48 lines · Michal Soltys

mostly with reference to earlier commit:

- bash doesn't need unsetting locals
- make normalize_path() a bit faster, also make sure we remove all trailing slashes
- normalize paths before tests

---
 dracut-functions |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
dracut-functions +8 -9
index 12dfa70..ce593c9 100755
@@ -83,31 +83,29 @@ print_vars() {
 }
 
 normalize_path() {
-    p=$1
-    while [[ ${p#*//*} != $p ]]; do
-        p=${p/\/\///}
-    done
-    echo $p
+    shopt -q -s extglob
+    set -- "${1//+(\/)//}"
+    shopt -q -u extglob
+    echo "${1%/}"
 }
 
 convert_abs_rel() {
-    local __current __absolute __abssize __cursize __newpath="" __oldifs
-    local -i __i __level=0
+    local __current __absolute __abssize __cursize __newpath __oldifs
+    local -i __i __level
 #    PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
 
+    set -- "$(normalize_path "$1")" "$(normalize_path "$2")"
+
     # corner case #1 - self looping link
     [[ "$1" == "$2" ]] && { echo "${1##*/}"; return; }
 
     # corner case #2 - own dir link
     [[ "${1%/*}" == "$2" ]] && { echo "."; return; }
 
-    __current=$(normalize_path "$1")
-    __absolute=$(normalize_path "$2")

dracut-functions print_vars() { · line 111

Quoted 10 lines
dracut-functions +2 -3
-
     __oldifs="$IFS"
     IFS="/"
-    __current=($__current)
-    __absolute=($__absolute)
+    __current=($1)
+    __absolute=($2)
     IFS="$__oldifs"
 
     __abssize=${#__absolute[@]}

pushed all 5