master - tests: aux.sh better loop logic
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2baac408fc8421b0f65...
Commit: 2baac408fc8421b0f65d1cc9ec18470f330c36a1
Parent: b97f75b1331b112412073ffd54812375867d9de7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jul 12 01:14:36 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 12 01:21:44 2017 +0200
tests: aux.sh better loop logic
Instead of using pipe for read and haveing no chance
to modify shell vars inside such loop use <( )
and keep using bash arrays.
---
test/lib/aux.sh | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index fda826f..9f60430 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -504,20 +504,18 @@ kill_tagged_processes() {
local wait
# read uses all vars within pipe subshell
- rm -f PIDS
- print_procs_by_tag_ "$@" | while read -r pid wait; do
+ local pids=()
+ while read -r pid wait; do
if test -n "$pid" ; then
echo "## killing tagged process: $pid ${wait:0:120}..."
kill -TERM "$pid" 2>/dev/null || true
fi
- echo "$pid" >> PIDS
- done
-
- test -s PIDS || return 0
+ pids+=( "$pid" )
+ done < <(print_procs_by_tag_ "$@")
# wait if process exited and eventually -KILL
wait=0
- for pid in $(< PIDS) ; do
+ for pid in "${pids[@]}" ; do
while ps "$pid" > /dev/null && test "$wait" -le 10; do
sleep .2
wait=$(( wait + 1 ))
6 years, 10 months
master - tests: improve logic for a race to catch abortion
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b97f75b1331b1124120...
Commit: b97f75b1331b112412073ffd54812375867d9de7
Parent: a87860965e99ae2d11f2c2496adb33fff050f4d4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 11 17:20:24 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 11 17:21:25 2017 +0200
tests: improve logic for a race to catch abortion
---
test/shell/lvconvert-cache-abort.sh | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/test/shell/lvconvert-cache-abort.sh b/test/shell/lvconvert-cache-abort.sh
index 9cf9410..468f8aa 100644
--- a/test/shell/lvconvert-cache-abort.sh
+++ b/test/shell/lvconvert-cache-abort.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright (C) 2014-2016 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2017 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@@ -44,13 +44,21 @@ lvdisplay --maps $vg
sync
dd if=/dev/zero of="$DM_DEV_DIR/$vg/$lv1" bs=4k count=100 conv=fdatasync
-LVM_TEST_TAG="kill_me_$PREFIX" lvconvert -v --splitcache $vg/$lv1 >log 2>&1 &
+LVM_TEST_TAG="kill_me_$PREFIX" lvconvert -v --splitcache $vg/$lv1 >logconvert 2>&1 &
PID_CONVERT=$!
-sleep 0.2
+while ! (dmsetup table $vg-$lv1 | grep cleaner) ; do
+ echo "Waiting for cleaner policy on $vg/$lv1"
+ sleep .05
+done
kill -INT $PID_CONVERT
aux enable_dev "$dev1"
wait
-grep -E "Flushing.*aborted" log
+
+grep -E "Flushing.*aborted" logconvert || {
+ cat logconvert || true
+ die "Flushing of $vg/$lv1 not aborted ?"
+}
+
# check the table got restored
check grep_dmsetup table $vg-$lv1 "writeback"
6 years, 10 months
master - tests: hardening - no unbound vars
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a87860965e99ae2d11f...
Commit: a87860965e99ae2d11f2c2496adb33fff050f4d4
Parent: 41e11e0f210bf1c423e39a836dfcb7c4fa3c8032
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 11 11:23:34 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 11 16:48:25 2017 +0200
tests: hardening - no unbound vars
Dissallow usage of any unbound shell variable in tests.
All vars needs to have some defined value.
---
test/lib/inittest.sh | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 1dad2eb..e32b044 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -25,6 +25,24 @@ TESTNAME=${0##*/}
PS4='#${BASH_SOURCE[0]##*/}:${LINENO}+ '
export TESTNAME PS4
+LVM_TEST_NODEBUG=${LVM_TEST_NODEBUG-}
+
+LVM_TEST_LVMETAD=${LVM_TEST_LVMETAD-}
+LVM_TEST_LVMLOCKD=${LVM_TEST_LVMLOCKD-}
+LVM_TEST_LVMLOCKD_TEST=${LVM_TEST_LVMLOCKD_TEST-}
+LVM_TEST_LVMPOLLD=${LVM_TEST_LVMPOLLD-}
+LVM_TEST_LOCK_TYPE_DLM=${LVM_TEST_LOCK_TYPE_DLM-}
+LVM_TEST_LOCK_TYPE_SANLOCK=${LVM_TEST_LOCK_TYPE_SANLOCK-}
+
+SKIP_WITHOUT_CLVMD=${SKIP_WITHOUT_CLVMD-}
+SKIP_WITH_CLVMD=${SKIP_WITH_CLVMD-}
+
+SKIP_WITHOUT_LVMETAD=${SKIP_WITHOUT_LVMETAD-}
+SKIP_WITH_LVMETAD=${SKIP_WITH_LVMETAD-}
+
+SKIP_WITH_LVMPOLLD=${SKIP_WITH_LVMPOLLD-}
+SKIP_WITH_LVMLOCKD=${SKIP_WITH_LVMLOCKD-}
+
if test -n "$LVM_TEST_FLAVOUR"; then
. "lib/flavour-$LVM_TEST_FLAVOUR"
fi
@@ -106,7 +124,9 @@ free -m || true
# Set vars from utils now that we have TESTDIR/PREFIX/...
prepare_test_vars
-test -n "$BASH" && set -eE -o pipefail
+# Set strict shell mode
+# see: http://redsymbol.net/articles/unofficial-bash-strict-mode
+test -n "$BASH" && set -euE -o pipefail
# Vars for harness
echo "@TESTDIR=$TESTDIR"
6 years, 10 months
master - tests: check.sh simplify in_sync
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=41e11e0f210bf1c423e...
Commit: 41e11e0f210bf1c423e39a836dfcb7c4fa3c8032
Parent: 5ab2676bac452e9875a970d0ece53983a6c16643
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 11 13:29:54 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 11 16:26:12 2017 +0200
tests: check.sh simplify in_sync
Avoid calling sed.
---
test/lib/check.sh | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/test/lib/check.sh b/test/lib/check.sh
index a61eb81..1829857 100644
--- a/test/lib/check.sh
+++ b/test/lib/check.sh
@@ -194,15 +194,13 @@ linear() {
in_sync() {
local a
local b
+ local c
local idx
local type
local snap=""
local lvm_name="$1/$2"
- local ignore_a=$3
- local dm_name
-
- dm_name=$(echo "$lvm_name" | sed s:-:--: | sed s:/:-:)
- [ -z "$ignore_a" ] && ignore_a=0
+ local ignore_a=${3:-0}
+ local dm_name="$1-$2"
a=( $(dmsetup status "$dm_name") ) || \
die "Unable to get sync status of $1"
@@ -233,9 +231,10 @@ in_sync() {
;;
esac
- b=( $(echo "${a[$idx]}" | sed s:/:' ':) )
+ b=${a[$idx]%%/*} # split ratio x/y
+ c=${a[$idx]##*/}
- if [ "${b[0]}" -eq 0 ] || [ "${b[0]}" != "${b[1]}" ]; then
+ if [ "$b" -eq 0 ] || [ "$b" != "$c" ]; then
echo "$lvm_name ($type$snap) is not in-sync"
return 1
fi
6 years, 10 months
master - tests: double quote
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5ab2676bac452e9875a...
Commit: 5ab2676bac452e9875a970d0ece53983a6c16643
Parent: 21e0e98665f0a51b928e621ea5a6794d36d16a47
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 11 11:23:14 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 11 16:26:12 2017 +0200
tests: double quote
---
test/shell/lvconvert-raid-regionsize.sh | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/test/shell/lvconvert-raid-regionsize.sh b/test/shell/lvconvert-raid-regionsize.sh
index 4763bab..893c158 100644
--- a/test/shell/lvconvert-raid-regionsize.sh
+++ b/test/shell/lvconvert-raid-regionsize.sh
@@ -28,10 +28,10 @@ function _test_regionsize
local vg=$4
local lv=$5
- lvconvert --type $type --yes -R $regionsize $vg/$lv
+ lvconvert --type "$type" --yes -R "$regionsize" "$vg/$lv"
check lv_field $vg/$lv regionsize "$regionsize_str"
- not lvconvert --regionsize $regionsize $vg/$lv 2>err
+ not lvconvert --regionsize "$regionsize" "$vg/$lv" 2>err
grep "is already" err
fsck -fn "$DM_DEV_DIR/$vg/$lv"
@@ -43,12 +43,12 @@ function _test_regionsizes
local type=$1
# Test RAID regionsize changes
- _test_regionsize $type 128K "128.00k" $vg $lv1
- _test_regionsize $type 256K "256.00k" $vg $lv1
- not _test_regionsize $type 1K "1.00k" $vg $lv1
- _test_regionsize $type 1m "1.00m" $vg $lv1
- not _test_regionsize $type 1G "1.00g" $vg $lv1
- not _test_regionsize $type 16K "16.00k" $vg $lv1
+ _test_regionsize "$type" 128K "128.00k" $vg $lv1
+ _test_regionsize "$type" 256K "256.00k" $vg $lv1
+ not _test_regionsize "$type" 1K "1.00k" $vg $lv1
+ _test_regionsize "$type" 1m "1.00m" $vg $lv1
+ not _test_regionsize "$type" 1G "1.00g" $vg $lv1
+ not _test_regionsize "$type" 16K "16.00k" $vg $lv1
}
# Create 3-way raid1
6 years, 10 months
master - tests: correct typo
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=21e0e98665f0a51b928...
Commit: 21e0e98665f0a51b928e621ea5a6794d36d16a47
Parent: 429e613ba86386829d2bd3556d29158aff93a04f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 11 11:19:09 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 11 16:26:12 2017 +0200
tests: correct typo
Use defined MARKED_AS_USED_MSG shell var.
---
test/shell/pv-ext-flags.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/shell/pv-ext-flags.sh b/test/shell/pv-ext-flags.sh
index cc21eab..bae16df 100644
--- a/test/shell/pv-ext-flags.sh
+++ b/test/shell/pv-ext-flags.sh
@@ -48,7 +48,7 @@ grep "$MARKED_AS_USED_MSG" err
not pvchange -u "$dev1" 2>err
grep "$MARKED_AS_USED_MSG" err
not vgcreate $vg2 "$dev1" 2>err
-grep "$MARKED_AS_USED" err
+grep "$MARKED_AS_USED_MSG" err
not pvremove "$dev1" 2>err
grep "$MARKED_AS_USED_MSG" err
@@ -113,7 +113,7 @@ grep "$MARKED_AS_USED_MSG" err
not pvchange -u "$dev1" 2>err
grep "$MARKED_AS_USED_MSG" err
not vgcreate $vg2 "$dev1" 2>err
-grep "$MARKED_AS_USED" err
+grep "$MARKED_AS_USED_MSG" err
not pvremove "$dev1" 2>err
grep "$MARKED_AS_USED_MSG" err
6 years, 10 months
master - tests: avoid unbound shell var usage
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=429e613ba86386829d2...
Commit: 429e613ba86386829d2bd3556d29158aff93a04f
Parent: f11e74ae3d1f5bd5221110fa08d502cc39365955
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 11 11:18:22 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 11 16:26:12 2017 +0200
tests: avoid unbound shell var usage
---
test/shell/lvchange-rebuild-raid.sh | 2 +-
test/shell/profiles-thin.sh | 1 +
test/shell/snapshot-autoumount-dmeventd.sh | 2 +-
test/shell/snapshots-of-mirrors.sh | 1 +
test/shell/topology-support.sh | 1 +
test/shell/unlost-pv.sh | 3 ++-
6 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvchange-rebuild-raid.sh b/test/shell/lvchange-rebuild-raid.sh
index 892d58d..4f535e6 100644
--- a/test/shell/lvchange-rebuild-raid.sh
+++ b/test/shell/lvchange-rebuild-raid.sh
@@ -24,7 +24,7 @@ _sync() {
aux enable_dev "${DEVICES[@]}"
aux wait_for_sync $vg $lv1
- test -z "$1" || check raid_leg_status $vg $lv1 $1
+ test "$#" -eq 0 || check raid_leg_status $vg $lv1 "$@"
# restore to delay_dev tables for all devices
aux restore_from_devtable "${DEVICES[@]}"
diff --git a/test/shell/profiles-thin.sh b/test/shell/profiles-thin.sh
index 9c9fadf..df6fd73 100644
--- a/test/shell/profiles-thin.sh
+++ b/test/shell/profiles-thin.sh
@@ -35,6 +35,7 @@ aux prepare_pvs 1 "$DEV_SIZE"
# Check we are not running on buggy kernel (broken lcm())
# If so, turn chunk_size test into 'should'
+SHOULD=""
check sysfs "$dev1" queue/optimal_io_size "$EXPECT" || SHOULD=should
vgcreate $vg "$dev1"
diff --git a/test/shell/snapshot-autoumount-dmeventd.sh b/test/shell/snapshot-autoumount-dmeventd.sh
index 8e2781e..e2702bb 100644
--- a/test/shell/snapshot-autoumount-dmeventd.sh
+++ b/test/shell/snapshot-autoumount-dmeventd.sh
@@ -41,7 +41,7 @@ test "$(dmsetup info -c --noheadings -o open $vg-snap)" -eq 1
grep "$mntdir" /proc/mounts
# overfill 4M snapshot (with metadata)
-not dd if=/dev/zero of="$mntdir/file$1" bs=1M count=4 conv=fdatasync
+not dd if=/dev/zero of="$mntdir/file" bs=1M count=4 conv=fdatasync
# Should be nearly instant check of dmeventd for invalid snapshot.
# Wait here for umount and open_count drops to 0 as it may
diff --git a/test/shell/snapshots-of-mirrors.sh b/test/shell/snapshots-of-mirrors.sh
index a23cc58..7e3f736 100644
--- a/test/shell/snapshots-of-mirrors.sh
+++ b/test/shell/snapshots-of-mirrors.sh
@@ -38,6 +38,7 @@ lvconvert --mirrorlog core $vg/lv
# Log conversion (core -> mirrored)
# FIXME on cluster
+SHOULD=""
test -e LOCAL_CLVMD && SHOULD=should
$SHOULD lvconvert --mirrorlog mirrored $vg/lv
diff --git a/test/shell/topology-support.sh b/test/shell/topology-support.sh
index ffa3fe6..98a6d9f 100644
--- a/test/shell/topology-support.sh
+++ b/test/shell/topology-support.sh
@@ -116,6 +116,7 @@ aux prepare_pvs 1 $PER_DEV_SIZE
# Kernel (3.19) could provide wrong results - in this case skip
# test with incorrect result - lvm2 can't figure out good values.
+SHOULD=""
check sysfs "$dev1" queue/optimal_io_size 786432 || SHOULD=should
$SHOULD check pv_field "${DEVICES[@]}" pe_start 768.00k
diff --git a/test/shell/unlost-pv.sh b/test/shell/unlost-pv.sh
index 982e340..ffc22b8 100644
--- a/test/shell/unlost-pv.sh
+++ b/test/shell/unlost-pv.sh
@@ -16,10 +16,11 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
check_() {
+ local cache=""
# vgscan needs --cache option for direct scan if lvmetad is used
test -e LOCAL_LVMETAD && cache="--cache"
vgscan $cache 2>&1 | tee vgscan.out
- $1 grep "Inconsistent metadata found for VG $vg" vgscan.out
+ "$@" grep "Inconsistent metadata found for VG $vg" vgscan.out
}
aux prepare_vg 3
6 years, 10 months
master - tests: improve test logic
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f11e74ae3d1f5bd5221...
Commit: f11e74ae3d1f5bd5221110fa08d502cc39365955
Parent: 2c3d9a07cbaa49275d24c40c6a4fa2480b1ac3d8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 11 11:16:24 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 11 16:26:12 2017 +0200
tests: improve test logic
Use existing vars.
Reduce extra lvchange -an and use directly activation with lvcreate.
---
test/shell/lvconvert-mirror-basic.sh | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/test/shell/lvconvert-mirror-basic.sh b/test/shell/lvconvert-mirror-basic.sh
index 0959af8..06b3450 100644
--- a/test/shell/lvconvert-mirror-basic.sh
+++ b/test/shell/lvconvert-mirror-basic.sh
@@ -49,23 +49,22 @@ test_lvconvert() {
local finish_count=$3
local finish_count_p1=$(( finish_count + 1 ))
local finish_log_type=$4
- local dev_array=( "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" )
local start_log_count
local finish_log_count
local max_log_count
local alloc=""
- local active=true
+ local active="-aey"
local i
- test "$5" = "active" && active=false
+ test "$5" = "active" && active="-an"
#test $finish_count -gt $start_count && up=true
# Do we have enough devices for the mirror images?
- test $start_count_p1 -gt ${#dev_array[@]} && \
+ test $start_count_p1 -gt ${#DEVICES[@]} && \
die "Action requires too many devices"
# Do we have enough devices for the mirror images?
- test $finish_count_p1 -gt ${#dev_array[@]} && \
+ test $finish_count_p1 -gt ${#DEVICES[@]} && \
die "Action requires too many devices"
start_log_count=$(log_name_to_count $start_log_type)
@@ -78,23 +77,22 @@ test_lvconvert() {
if [ $start_count -gt 0 ]; then
# Are there extra devices for the log or do we overlap
- if [ $(( start_count_p1 + start_log_count )) -gt ${#dev_array[@]} ]; then
+ if [ $(( start_count_p1 + start_log_count )) -gt ${#DEVICES[@]} ]; then
alloc="--alloc anywhere"
fi
- lvcreate -aey -l2 --type mirror -m $start_count --mirrorlog $start_log_type \
+ lvcreate "$active" -Zn -l2 --type mirror -m $start_count --mirrorlog $start_log_type \
-n $lv1 $vg $alloc
check mirror_legs $vg $lv1 $start_count_p1
# FIXME: check mirror log
else
- lvcreate -aey -l2 -n $lv1 $vg
+ lvcreate "$active" -Zn -l2 -n $lv1 $vg
fi
lvs -a -o name,copy_percent,devices $vg
- test $active || lvchange -an $vg/$lv1
# Are there extra devices for the log or do we overlap
- if [ $(( finish_count_p1 + finish_log_count )) -gt ${#dev_array[@]} ]; then
+ if [ $(( finish_count_p1 + finish_log_count )) -gt ${#DEVICES[@]} ]; then
alloc="--alloc anywhere"
fi
@@ -109,7 +107,7 @@ test_lvconvert() {
lvconvert --type mirror -m $finish_count $mirrorlog $finish_log_type \
$vg/$lv1 $alloc
- test $active || lvchange -aey $vg/$lv1
+ test "$active" = "-an" || lvchange "$active" $vg/$lv1
check mirror_no_temporaries $vg $lv1
if [ "$finish_count_p1" -eq 1 ]; then
@@ -125,6 +123,7 @@ test_lvconvert() {
}
aux prepare_vg 5 5
+get_devs
MIRRORED="mirrored"
# FIXME: Cluster is not supporting exlusive activation of mirrored log
6 years, 10 months
master - cleanup: whitespace
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2c3d9a07cbaa49275d2...
Commit: 2c3d9a07cbaa49275d24c40c6a4fa2480b1ac3d8
Parent: 3cd492cd599262872b212a4fc9eefc7050ce1517
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 11 11:21:18 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jul 11 16:26:12 2017 +0200
cleanup: whitespace
---
lib/misc/crc.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/misc/crc.c b/lib/misc/crc.c
index fc4d3f0..aacd82d 100644
--- a/lib/misc/crc.c
+++ b/lib/misc/crc.c
@@ -63,7 +63,7 @@ static uint32_t _calc_crc_new(uint32_t initial, const uint8_t *buf, uint32_t siz
const uint32_t *start = (const uint32_t *) buf;
const uint32_t *end = (const uint32_t *) (buf + (size & 0xfffffffc));
uint32_t crc = initial;
-
+
/* Process 4 bytes per iteration */
while (start < end) {
crc = crc ^ xlate32(*start++);
6 years, 10 months
master - commands: fix lvm shell segfaults
by Alasdair Kergon
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3cd492cd599262872b2...
Commit: 3cd492cd599262872b212a4fc9eefc7050ce1517
Parent: 56768ce36be4a63cda0fec1d06ca061d39288135
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Jul 11 01:42:06 2017 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Jul 11 01:42:06 2017 +0100
commands: fix lvm shell segfaults
Don't check for -h/--help if argc is 1.
---
WHATS_NEW | 1 +
tools/lvmcmdline.c | 24 +++++++++++++-----------
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 062a440..29678f4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.173 -
=================================
+ Accept 'lvm -h' and 'lvm --help' as well as 'lvm help' for help.
Suppress error message from accept() on clean lvmetad shutdown.
Tidy clvmd client list processing and fix segfaults.
Protect clvmd debug log messages with mutex and add client id.
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 70371d0..700593c 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -3430,17 +3430,19 @@ int lvm2_main(int argc, char **argv)
log_sys_error("unsetenv", "LVM_DID_EXEC");
}
- /* "version" command is simple enough so it doesn't need any complex init */
- if (!alias && argc > 1 && !strcmp(argv[1], "version"))
- return lvm_return_code(version(NULL, argc, argv));
-
- /* turn 'lvm -h' and 'lvm --help' into 'lvm help' */
- if (!alias && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))
- argv[1] = (char *)"help";
-
- if (!alias && (*argv[1] == '-')) {
- log_error("Specify options after a command: lvm [command] [options].");
- return -1;
+ if (!alias && argc > 1) {
+ /* "version" command is simple enough so it doesn't need any complex init */
+ if (!strcmp(argv[1], "version"))
+ return lvm_return_code(version(NULL, argc, argv));
+
+ /* turn 'lvm -h' and 'lvm --help' into 'lvm help' */
+ if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
+ argv[1] = (char *)"help";
+
+ if (*argv[1] == '-') {
+ log_error("Specify options after a command: lvm [command] [options].");
+ return -1;
+ }
}
if (!(cmd = init_lvm(0, 0)))
6 years, 10 months