All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] options to configure fs-lib (fsck) and two unrelated fixes
@ 2011-09-30 21:45 Michal Soltys
  2011-10-07  7:49 ` WANG Cong
       [not found] ` <4E86385C.6040706-R61QfzASbfY@public.gmane.org>
  0 siblings, 2 replies; 11+ messages in thread
From: Michal Soltys @ 2011-09-30 21:45 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

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(-)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] options to configure fs-lib (fsck) and two unrelated fixes
  2011-09-30 21:45 [PATCH 0/4] options to configure fs-lib (fsck) and two unrelated fixes Michal Soltys
@ 2011-10-07  7:49 ` WANG Cong
  2011-10-07 20:06   ` Michal Soltys
       [not found] ` <4E86385C.6040706-R61QfzASbfY@public.gmane.org>
  1 sibling, 1 reply; 11+ messages in thread
From: WANG Cong @ 2011-10-07  7:49 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

On Fri, 30 Sep 2011 23:45:00 +0200, Michal Soltys wrote:

> 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

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] options to configure fs-lib (fsck) and two unrelated fixes
  2011-10-07  7:49 ` WANG Cong
@ 2011-10-07 20:06   ` Michal Soltys
       [not found]     ` <4E8F5BB9.2090405-R61QfzASbfY@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Michal Soltys @ 2011-10-07 20:06 UTC (permalink / raw)
  To: WANG Cong; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA

On 11-10-07 09:49, WANG Cong wrote:
>
> 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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] convert_abs_rel() fixups
       [not found] ` <4E86385C.6040706-R61QfzASbfY@public.gmane.org>
@ 2011-10-07 20:23   ` Michal Soltys
  2011-10-07 20:23   ` [PATCH 2/4] dracut.8: add missing lvmconf info Michal Soltys
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Michal Soltys @ 2011-10-07 20:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

- 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

Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
---
 dracut-functions |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/dracut-functions b/dracut-functions
index c4f7f61..12dfa70 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -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[@]}
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] dracut.8: add missing lvmconf info
       [not found] ` <4E86385C.6040706-R61QfzASbfY@public.gmane.org>
  2011-10-07 20:23   ` [PATCH 1/4] convert_abs_rel() fixups Michal Soltys
@ 2011-10-07 20:23   ` Michal Soltys
  2011-10-07 20:23   ` [PATCH 3/4] fs-lib: add ability to choose fsck tools Michal Soltys
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Michal Soltys @ 2011-10-07 20:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
---
 dracut.8.xml |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/dracut.8.xml b/dracut.8.xml
index 11ea8c3..7e5a6d6 100644
--- a/dracut.8.xml
+++ b/dracut.8.xml
@@ -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>
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] fs-lib: add ability to choose fsck tools
       [not found] ` <4E86385C.6040706-R61QfzASbfY@public.gmane.org>
  2011-10-07 20:23   ` [PATCH 1/4] convert_abs_rel() fixups Michal Soltys
  2011-10-07 20:23   ` [PATCH 2/4] dracut.8: add missing lvmconf info Michal Soltys
@ 2011-10-07 20:23   ` Michal Soltys
  2011-10-07 20:23   ` [PATCH 4/4] manuals: add info about fs-lib (fsck) configuration Michal Soltys
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Michal Soltys @ 2011-10-07 20:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

in dracut.conf:

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

and similary on command line:

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

Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
---
 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(-)

diff --git a/dracut b/dracut
index c9329bd..9da1554 100755
--- a/dracut
+++ b/dracut
@@ -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
 
diff --git a/dracut.conf b/dracut.conf
index 8684328..a502066 100644
--- a/dracut.conf
+++ b/dracut.conf
@@ -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"
diff --git a/modules.d/99fs-lib/fs-lib.sh b/modules.d/99fs-lib/fs-lib.sh
index f36299a..772d5c0 100755
--- a/modules.d/99fs-lib/fs-lib.sh
+++ b/modules.d/99fs-lib/fs-lib.sh
@@ -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
diff --git a/modules.d/99fs-lib/module-setup.sh b/modules.d/99fs-lib/module-setup.sh
index cbf69a5..68ea9b1 100755
--- a/modules.d/99fs-lib/module-setup.sh
+++ b/modules.d/99fs-lib/module-setup.sh
@@ -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
 }
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] manuals: add info about fs-lib (fsck) configuration
       [not found] ` <4E86385C.6040706-R61QfzASbfY@public.gmane.org>
                     ` (2 preceding siblings ...)
  2011-10-07 20:23   ` [PATCH 3/4] fs-lib: add ability to choose fsck tools Michal Soltys
@ 2011-10-07 20:23   ` Michal Soltys
  2011-10-07 22:20   ` minor corrections Michal Soltys
  2011-10-07 22:20   ` [PATCH 5/4] dracut-functions: conv/normalize " Michal Soltys
  5 siblings, 0 replies; 11+ messages in thread
From: Michal Soltys @ 2011-10-07 20:23 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

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

Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
---
 dracut.8.xml      |   19 +++++++++++++++++++
 dracut.conf.5.xml |   22 ++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/dracut.8.xml b/dracut.8.xml
index 7e5a6d6..a7ce5ab 100644
--- a/dracut.8.xml
+++ b/dracut.8.xml
@@ -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>
diff --git a/dracut.conf.5.xml b/dracut.conf.5.xml
index 697e655..dbcdb90 100644
--- a/dracut.conf.5.xml
+++ b/dracut.conf.5.xml
@@ -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>
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* minor corrections
       [not found] ` <4E86385C.6040706-R61QfzASbfY@public.gmane.org>
                     ` (3 preceding siblings ...)
  2011-10-07 20:23   ` [PATCH 4/4] manuals: add info about fs-lib (fsck) configuration Michal Soltys
@ 2011-10-07 22:20   ` Michal Soltys
  2011-10-07 22:20   ` [PATCH 5/4] dracut-functions: conv/normalize " Michal Soltys
  5 siblings, 0 replies; 11+ messages in thread
From: Michal Soltys @ 2011-10-07 22:20 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

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(-)

-- 
1.7.5.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 5/4] dracut-functions: conv/normalize minor corrections
       [not found] ` <4E86385C.6040706-R61QfzASbfY@public.gmane.org>
                     ` (4 preceding siblings ...)
  2011-10-07 22:20   ` minor corrections Michal Soltys
@ 2011-10-07 22:20   ` Michal Soltys
       [not found]     ` <1318026050-5891-2-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
  5 siblings, 1 reply; 11+ messages in thread
From: Michal Soltys @ 2011-10-07 22:20 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

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

Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
---
 dracut-functions |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/dracut-functions b/dracut-functions
index 12dfa70..ce593c9 100755
--- a/dracut-functions
+++ b/dracut-functions
@@ -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[@]}
-- 
1.7.5.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/4] options to configure fs-lib (fsck) and two unrelated fixes
       [not found]     ` <4E8F5BB9.2090405-R61QfzASbfY@public.gmane.org>
@ 2011-10-08 11:44       ` Américo Wang
  0 siblings, 0 replies; 11+ messages in thread
From: Américo Wang @ 2011-10-08 11:44 UTC (permalink / raw)
  To: Michal Soltys; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA

On Sat, Oct 8, 2011 at 4:06 AM, Michal Soltys <soltys-R61QfzASbfY@public.gmane.org> wrote:
> On 11-10-07 09:49, WANG Cong wrote:
>>
>> 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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/4] dracut-functions: conv/normalize minor corrections
       [not found]     ` <1318026050-5891-2-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
@ 2011-10-10  9:57       ` Harald Hoyer
  0 siblings, 0 replies; 11+ messages in thread
From: Harald Hoyer @ 2011-10-10  9:57 UTC (permalink / raw)
  To: Michal Soltys; +Cc: initramfs-u79uwXL29TY76Z2rM5mHXA

On 08.10.2011 00:20, Michal Soltys wrote:
> 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
> 
> Signed-off-by: Michal Soltys <soltys-R61QfzASbfY@public.gmane.org>
> ---
>  dracut-functions |   22 ++++++++++------------
>  1 files changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/dracut-functions b/dracut-functions
> index 12dfa70..ce593c9 100755
> --- a/dracut-functions
> +++ b/dracut-functions
> @@ -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[@]}

pushed all 5

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-10-10  9:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-30 21:45 [PATCH 0/4] options to configure fs-lib (fsck) and two unrelated fixes Michal Soltys
2011-10-07  7:49 ` WANG Cong
2011-10-07 20:06   ` Michal Soltys
     [not found]     ` <4E8F5BB9.2090405-R61QfzASbfY@public.gmane.org>
2011-10-08 11:44       ` Américo Wang
     [not found] ` <4E86385C.6040706-R61QfzASbfY@public.gmane.org>
2011-10-07 20:23   ` [PATCH 1/4] convert_abs_rel() fixups Michal Soltys
2011-10-07 20:23   ` [PATCH 2/4] dracut.8: add missing lvmconf info Michal Soltys
2011-10-07 20:23   ` [PATCH 3/4] fs-lib: add ability to choose fsck tools Michal Soltys
2011-10-07 20:23   ` [PATCH 4/4] manuals: add info about fs-lib (fsck) configuration Michal Soltys
2011-10-07 22:20   ` minor corrections Michal Soltys
2011-10-07 22:20   ` [PATCH 5/4] dracut-functions: conv/normalize " Michal Soltys
     [not found]     ` <1318026050-5891-2-git-send-email-soltys-R61QfzASbfY@public.gmane.org>
2011-10-10  9:57       ` Harald Hoyer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.