master - blkdeactivate: more readable if-then-else-fi
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b5fc0d73e551ed36c75...
Commit: b5fc0d73e551ed36c752e89b6f409935511f2ba4
Parent: dc50f2f4a03dd50c5e2411a258095484555421e9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 16:55:38 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
blkdeactivate: more readable if-then-else-fi
---
scripts/blkdeactivate.sh.in | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/scripts/blkdeactivate.sh.in b/scripts/blkdeactivate.sh.in
index b963a10..a3528e5 100644
--- a/scripts/blkdeactivate.sh.in
+++ b/scripts/blkdeactivate.sh.in
@@ -353,7 +353,11 @@ deactivate_all() {
# top-level device could not be deactivated anyway
test "$skip" -eq 1 && {
# reset 'skip' on top level device
- is_top_level_device && skip=0 || continue
+ if is_top_level_device ; then
+ skip=0
+ else
+ continue
+ fi
}
# check if the device is not on the skip list already
6 years, 10 months
master - blkdeactivate: split local declaration and assign
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=dc50f2f4a03dd50c5e2...
Commit: dc50f2f4a03dd50c5e2411a258095484555421e9
Parent: ce1383fe46d2b830a89acaa9fe00fb1239be4969
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 16:50:34 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
blkdeactivate: split local declaration and assign
---
scripts/blkdeactivate.sh.in | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/scripts/blkdeactivate.sh.in b/scripts/blkdeactivate.sh.in
index 69f02b0..b963a10 100644
--- a/scripts/blkdeactivate.sh.in
+++ b/scripts/blkdeactivate.sh.in
@@ -205,7 +205,9 @@ deactivate_holders () {
}
deactivate_dm () {
- local name=$(printf "%s" "$name")
+ local name
+
+ name=$(printf "%s" "$name")
test -b "$DEV_DIR/mapper/$name" || return 0
test -z "${SKIP_DEVICE_LIST["$kname"]}" || return 1
@@ -274,7 +276,9 @@ deactivate_lvm () {
}
deactivate_md () {
- local name=$(printf "%s" "$name")
+ local name
+
+ name=$(printf "%s" "$name")
test -b "$DEV_DIR/$name" || return 0
test -z "${SKIP_DEVICE_LIST["$kname"]}" || return 1
6 years, 10 months
master - blkdeactivate: drop unused var
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ce1383fe46d2b830a89...
Commit: ce1383fe46d2b830a89acaa9fe00fb1239be4969
Parent: 45861557b5b531f828f4d6ed3d0b104144d2d5f8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 19:36:49 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
blkdeactivate: drop unused var
---
scripts/blkdeactivate.sh.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/scripts/blkdeactivate.sh.in b/scripts/blkdeactivate.sh.in
index a497414..69f02b0 100644
--- a/scripts/blkdeactivate.sh.in
+++ b/scripts/blkdeactivate.sh.in
@@ -221,7 +221,7 @@ deactivate_dm () {
}
deactivate_lvm () {
- local DM_VG_NAME; local DM_LV_NAME; local DM_LV_LAYER
+ local DM_VG_NAME; local DM_LV_NAME
eval "$(eval "$DMSETUP" splitname --nameprefixes --noheadings --rows "$name" LVM "$ERR")"
test -b "$DEV_DIR/$DM_VG_NAME/$DM_LV_NAME" || return 0
6 years, 10 months
master - blkdeactivate: double quote
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=45861557b5b531f828f...
Commit: 45861557b5b531f828f4d6ed3d0b104144d2d5f8
Parent: bd359aec86756e2eaa62880855f0c0ff412b6df1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 16:33:00 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
blkdeactivate: double quote
Using double quote to prevent globbing and word splitting.
---
scripts/blkdeactivate.sh.in | 66 +++++++++++++++++++++---------------------
1 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/scripts/blkdeactivate.sh.in b/scripts/blkdeactivate.sh.in
index 5c1ab82..a497414 100644
--- a/scripts/blkdeactivate.sh.in
+++ b/scripts/blkdeactivate.sh.in
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (C) 2012-2015 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2012-2017 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
@@ -41,7 +41,7 @@ LVM="@sbindir@/lvm"
MDADM="@sbindir@/mdadm"
MPATHD="/sbin/multipathd"
-if $UMOUNT --help | grep -- "--all-targets" >$DEV_DIR/null; then
+if "$UMOUNT" --help | grep -- "--all-targets" >"$DEV_DIR/null"; then
UMOUNT_OPTS="--all-targets "
else
UMOUNT_OPTS=""
@@ -156,9 +156,9 @@ device_umount_one() {
if test -z "${SKIP_UMOUNT_LIST["$mnt"]}" -a "$DO_UMOUNT" -eq "1"; then
echo -n " [UMOUNT]: unmounting $name ($kname) mounted on $mnt... "
- if eval $UMOUNT $UMOUNT_OPTS "$(printf "%s" "$mnt")" $OUT $ERR; then
+ if eval "$UMOUNT" $UMOUNT_OPTS "$(printf "%s" "$mnt")" "$OUT" "$ERR"; then
echo "done"
- elif $MOUNTPOINT -q "$mnt"; then
+ elif "$MOUNTPOINT" -q "$mnt"; then
echo "skipping"
add_device_to_skip_list
else
@@ -182,7 +182,7 @@ device_umount() {
else
while $FINDMNT_READ; do
device_umount_one || return 1
- done <<< "$($FINDMNT $DEV_DIR/$kname)"
+ done <<< "$($FINDMNT "$DEV_DIR/$kname")"
fi
}
@@ -194,25 +194,25 @@ deactivate_holders () {
# First line on the lsblk output is the device itself - skip it for
# the deactivate call as this device is already being deactivated.
while $LSBLK_READ; do
- test -e $SYS_BLK_DIR/$kname || continue
+ test -e "$SYS_BLK_DIR/$kname" || continue
# check if the device not on the skip list already
- test -z ${SKIP_DEVICE_LIST["$kname"]} || return 1
+ test -z "${SKIP_DEVICE_LIST["$kname"]}" || return 1
# try to deactivate the holder
- test $skip -eq 1 && skip=0 && continue
+ test "$skip" -eq 1 && skip=0 && continue
deactivate || return 1
- done <<< "$($LSBLK $1)"
+ done <<< "$($LSBLK "$1")"
}
deactivate_dm () {
local name=$(printf "%s" "$name")
test -b "$DEV_DIR/mapper/$name" || return 0
- test -z ${SKIP_DEVICE_LIST["$kname"]} || return 1
+ test -z "${SKIP_DEVICE_LIST["$kname"]}" || return 1
deactivate_holders "$DEV_DIR/mapper/$name" || return 1
echo -n " [DM]: deactivating $devtype device $name ($kname)... "
- if eval $DMSETUP $DMSETUP_OPTS remove "$name" $OUT $ERR; then
+ if eval "$DMSETUP" $DMSETUP_OPTS remove "$name" "$OUT" "$ERR"; then
echo "done"
else
echo "skipping"
@@ -223,13 +223,13 @@ deactivate_dm () {
deactivate_lvm () {
local DM_VG_NAME; local DM_LV_NAME; local DM_LV_LAYER
- eval $(eval $DMSETUP splitname --nameprefixes --noheadings --rows "$name" LVM $ERR)
+ eval "$(eval "$DMSETUP" splitname --nameprefixes --noheadings --rows "$name" LVM "$ERR")"
test -b "$DEV_DIR/$DM_VG_NAME/$DM_LV_NAME" || return 0
- test -z ${SKIP_VG_LIST["$DM_VG_NAME"]} || return 1
+ test -z "${SKIP_VG_LIST["$DM_VG_NAME"]}" || return 1
- if test $LVM_DO_WHOLE_VG -eq 0; then
+ if test "$LVM_DO_WHOLE_VG" -eq 0; then
# Skip LVM device deactivation if LVM tools missing.
- test $LVM_AVAILABLE -eq 0 && {
+ test "$LVM_AVAILABLE" -eq 0 && {
add_device_to_skip_list
return 1
}
@@ -240,7 +240,7 @@ deactivate_lvm () {
}
echo -n " [LVM]: deactivating Logical Volume $DM_VG_NAME/$DM_LV_NAME... "
- if eval $LVM lvchange $LVM_OPTS --config \'log{prefix=\"\"} $LVM_CONFIG\' -aln $DM_VG_NAME/$DM_LV_NAME $OUT $ERR; then
+ if eval "$LVM" lvchange $LVM_OPTS --config \'log{prefix=\"\"} $LVM_CONFIG\' -aln "$DM_VG_NAME/$DM_LV_NAME" "$OUT" "$ERR"; then
echo "done"
else
echo "skipping"
@@ -249,12 +249,12 @@ deactivate_lvm () {
else
# Skip LVM VG deactivation if LVM tools missing.
- test $LVM_AVAILABLE -eq 0 && {
+ test "$LVM_AVAILABLE" -eq 0 && {
add_vg_to_skip_list
return 1
}
# Deactivating the whole VG the LV is part of
- lv_list=$(eval $LVM vgs --config "$LVM_CONFIG" --noheadings --rows -o lv_name $DM_VG_NAME $ERR)
+ lv_list=$(eval "$LVM" vgs --config "$LVM_CONFIG" --noheadings --rows -o lv_name "$DM_VG_NAME" "$ERR")
for lv in $lv_list; do
test -b "$DEV_DIR/$DM_VG_NAME/$lv" || continue
deactivate_holders "$DEV_DIR/$DM_VG_NAME/$lv" || {
@@ -264,7 +264,7 @@ deactivate_lvm () {
done
echo -n " [LVM]: deactivating Volume Group $DM_VG_NAME... "
- if eval $LVM vgchange $LVM_OPTS --config \'log{prefix=\" \"} $LVM_CONFIG\' -aln $DM_VG_NAME $OUT $ERR; then
+ if eval "$LVM" vgchange $LVM_OPTS --config \'log{prefix=\" \"} $LVM_CONFIG\' -aln "$DM_VG_NAME" "$OUT" "$ERR"; then
echo "done"
else
echo "skipping"
@@ -276,10 +276,10 @@ deactivate_lvm () {
deactivate_md () {
local name=$(printf "%s" "$name")
test -b "$DEV_DIR/$name" || return 0
- test -z ${SKIP_DEVICE_LIST["$kname"]} || return 1
+ test -z "${SKIP_DEVICE_LIST["$kname"]}" || return 1
# Skip MD device deactivation if MD tools missing.
- test $MDADM_AVAILABLE -eq 0 && {
+ test "$MDADM_AVAILABLE" -eq 0 && {
add_device_to_skip_list
return 1
}
@@ -287,7 +287,7 @@ deactivate_md () {
deactivate_holders "$DEV_DIR/$name" || return 1
echo -n " [MD]: deactivating $devtype device $kname... "
- if eval $MDADM $MDADM_OPTS -S "$name" $OUT $ERR; then
+ if eval "$MDADM" $MDADM_OPTS -S "$name" "$OUT" "$ERR"; then
echo "done"
else
echo "skipping"
@@ -324,9 +324,9 @@ deactivate_all() {
echo "Deactivating block devices:"
- test $MPATHD_RUNNING -eq 1 && {
+ test "$MPATHD_RUNNING" -eq 1 && {
echo -n " [DM]: disabling queueing on all multipath devices... "
- eval $MPATHD $MPATHD_OPTS disablequeueing maps $ERR | grep '^ok$' >$DEV_DIR/null && echo "done" || echo "failed"
+ eval "$MPATHD" $MPATHD_OPTS disablequeueing maps "$ERR" | grep '^ok$' >"$DEV_DIR/null" && echo "done" || echo "failed"
}
if test $# -eq 0; then
@@ -347,13 +347,13 @@ deactivate_all() {
# if deactivation of any device fails, skip processing
# any subsequent devices within its subtree as the
# top-level device could not be deactivated anyway
- test $skip -eq 1 && {
+ test "$skip" -eq 1 && {
# reset 'skip' on top level device
is_top_level_device && skip=0 || continue
}
# check if the device is not on the skip list already
- test -z ${SKIP_DEVICE_LIST["$kname"]} || continue
+ test -z "${SKIP_DEVICE_LIST["$kname"]}" || continue
# try to deactivate top-level device, set 'skip=1'
# if it fails to do so - this will cause all the
@@ -370,15 +370,15 @@ deactivate_all() {
# Unmount all relevant mountpoints first
while $LSBLK_READ; do
device_umount
- done <<< "$($LSBLK $1 | $SORT_MNT)"
+ done <<< "$($LSBLK "$1" | $SORT_MNT)"
# Do deactivate
# Single dm device tree deactivation.
if test -b "$1"; then
- $LSBLK_READ <<< "$($LSBLK --nodeps $1)"
+ $LSBLK_READ <<< "$($LSBLK --nodeps "$1")"
# check if the device is not on the skip list already
- test -z ${SKIP_DEVICE_LIST["$kname"]} || {
+ test -z "${SKIP_DEVICE_LIST["$kname"]}" || {
shift
continue
}
@@ -455,7 +455,7 @@ set_env() {
OUT="1>$DEV_DIR/null"
fi
- if test -f $LVM; then
+ if test -f "$LVM"; then
LVM_AVAILABLE=1
else
LVM_AVAILABLE=0
@@ -468,9 +468,9 @@ set_env() {
fi
MPATHD_RUNNING=0
- test $MPATHD_DO_DISABLEQUEUEING -eq 1 && {
- if test -f $MPATHD; then
- if eval $MPATHD show daemon $ERR | grep "running" >$DEV_DIR/null; then
+ test "$MPATHD_DO_DISABLEQUEUEING" -eq 1 && {
+ if test -f "$MPATHD"; then
+ if eval "$MPATHD" show daemon "$ERR" | grep "running" >"$DEV_DIR/null"; then
MPATHD_RUNNING=1
fi
fi
6 years, 10 months
master - blkdeactivate: replace obsoleted syntax
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bd359aec86756e2eaa6...
Commit: bd359aec86756e2eaa62880855f0c0ff412b6df1
Parent: 95ca7cfdffc5052e360d76c787a601e9aa626bd1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 16:15:36 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
blkdeactivate: replace obsoleted syntax
---
scripts/blkdeactivate.sh.in | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/scripts/blkdeactivate.sh.in b/scripts/blkdeactivate.sh.in
index 436c72e..5c1ab82 100644
--- a/scripts/blkdeactivate.sh.in
+++ b/scripts/blkdeactivate.sh.in
@@ -147,7 +147,7 @@ add_vg_to_skip_list() {
is_top_level_device() {
# top level devices do not have any holders, that is
# the SYS_BLK_DIR/<device_name>/holders dir is empty
- files="`echo $SYS_BLK_DIR/$kname/holders/*`"
+ files=$(echo "$SYS_BLK_DIR/$kname/holders/"*)
test -z "$files"
}
@@ -182,7 +182,7 @@ device_umount() {
else
while $FINDMNT_READ; do
device_umount_one || return 1
- done <<< "`$FINDMNT $DEV_DIR/$kname`"
+ done <<< "$($FINDMNT $DEV_DIR/$kname)"
fi
}
@@ -201,7 +201,7 @@ deactivate_holders () {
# try to deactivate the holder
test $skip -eq 1 && skip=0 && continue
deactivate || return 1
- done <<< "`$LSBLK $1`"
+ done <<< "$($LSBLK $1)"
}
deactivate_dm () {
@@ -337,7 +337,7 @@ deactivate_all() {
# Unmount all relevant mountpoints first
while $LSBLK_READ; do
device_umount
- done <<< "`$LSBLK | $SORT_MNT`"
+ done <<< "$($LSBLK | $SORT_MNT)"
# Do deactivate
while $LSBLK_READ; do
@@ -360,7 +360,7 @@ deactivate_all() {
# device's subtree to be skipped when processing
# devices further in this loop
deactivate || skip=1
- done <<< "`$LSBLK -s`"
+ done <<< "$($LSBLK -s)"
else
##################################
# Process only specified devices #
@@ -370,12 +370,12 @@ deactivate_all() {
# Unmount all relevant mountpoints first
while $LSBLK_READ; do
device_umount
- done <<< "`$LSBLK $1 | $SORT_MNT`"
+ done <<< "$($LSBLK $1 | $SORT_MNT)"
# Do deactivate
# Single dm device tree deactivation.
if test -b "$1"; then
- $LSBLK_READ <<< "`$LSBLK --nodeps $1`"
+ $LSBLK_READ <<< "$($LSBLK --nodeps $1)"
# check if the device is not on the skip list already
test -z ${SKIP_DEVICE_LIST["$kname"]} || {
6 years, 10 months
master - fsadm: make if statement more clear
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=95ca7cfdffc5052e360...
Commit: 95ca7cfdffc5052e360d76c787a601e9aa626bd1
Parent: c6a5964ce96e869028394fb31060d2e2c44c2ab1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 16:13:29 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
fsadm: make if statement more clear
---
scripts/fsadm.sh | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh
index 0db24ad..e08862a 100755
--- a/scripts/fsadm.sh
+++ b/scripts/fsadm.sh
@@ -111,7 +111,7 @@ tool_usage() {
}
verbose() {
- test -n "$VERB" && echo "$TOOL:" "$@" || true
+ test -z "$VERB" || echo "$TOOL:" "$@"
}
# Support multi-line error messages
@@ -423,7 +423,9 @@ try_umount() {
}
validate_parsing() {
- test -n "$BLOCKSIZE" && test -n "$BLOCKCOUNT" || error "Cannot parse $1 output."
+ if test -z "$BLOCKSIZE" || test -z "$BLOCKCOUNT" ; then
+ error "Cannot parse $1 output."
+ fi
}
####################################
# Resize ext2/ext3/ext4 filesystem
@@ -445,7 +447,7 @@ resize_ext() {
decode_size "$1" "$BLOCKSIZE"
FSFORCE=$FORCE
- if [ "$NEWBLOCKCOUNT" -lt "$BLOCKCOUNT" -o "$EXTOFF" -eq 1 ]; then
+ if test "$NEWBLOCKCOUNT" -lt "$BLOCKCOUNT" || test "$EXTOFF" -eq 1 ; then
test "$IS_MOUNTED" -eq 1 && verbose "$RESIZE_EXT needs unmounted filesystem" && try_umount
REMOUNT=$MOUNTED
if test -n "$MOUNTED" ; then
6 years, 10 months
master - fsadm: add -r to read
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c6a5964ce96e8690283...
Commit: c6a5964ce96e869028394fb31060d2e2c44c2ab1
Parent: afded3e532546744793f2f483b2c86dfb4f05f9a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 16:07:33 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
fsadm: add -r to read
read without -r will mangle backslashes
---
scripts/fsadm.sh | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh
index 0b248e1..0db24ad 100755
--- a/scripts/fsadm.sh
+++ b/scripts/fsadm.sh
@@ -204,8 +204,8 @@ detect_fs() {
case "$RVOLUME" in
# hardcoded /dev since udev does not create these entries elsewhere
/dev/dm-[0-9]*)
- read <"/sys/block/${RVOLUME#/dev/}/dm/name" SYSVOLUME 2>&1 && VOLUME="$DM_DEV_DIR/mapper/$SYSVOLUME"
- read <"/sys/block/${RVOLUME#/dev/}/dev" MAJORMINOR 2>&1 || error "Cannot get major:minor for \"$VOLUME\"."
+ read -r <"/sys/block/${RVOLUME#/dev/}/dm/name" SYSVOLUME 2>&1 && VOLUME="$DM_DEV_DIR/mapper/$SYSVOLUME"
+ read -r <"/sys/block/${RVOLUME#/dev/}/dev" MAJORMINOR 2>&1 || error "Cannot get major:minor for \"$VOLUME\"."
MAJOR=${MAJORMINOR%%:*}
MINOR=${MAJORMINOR##*:}
;;
@@ -262,7 +262,7 @@ check_valid_mounted_device() {
case "$VOL" in
# hardcoded /dev since udev does not create these entries elsewhere
/dev/dm-[0-9]*)
- read <"/sys/block/${VOL#/dev/}/dev" MOUNTEDMAJORMINOR 2>&1 || error "Cannot get major:minor for \"$VOLUME\"."
+ read -r <"/sys/block/${VOL#/dev/}/dev" MOUNTEDMAJORMINOR 2>&1 || error "Cannot get major:minor for \"$VOLUME\"."
;;
*)
STAT=$(stat --format "MOUNTEDMAJORMINOR=\$((0x%t)):\$((0x%T))" "$VOL")
6 years, 10 months
master - fsadm: no mixing string and array
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=afded3e532546744793...
Commit: afded3e532546744793f2f483b2c86dfb4f05f9a
Parent: 05a6d43476a4b2600329eae444c980107494b4ac
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 16:01:42 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
fsadm: no mixing string and array
Argument mixes string and array. Use * or separate argument.
---
scripts/fsadm.sh | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh
index b8744b1..0b248e1 100755
--- a/scripts/fsadm.sh
+++ b/scripts/fsadm.sh
@@ -111,7 +111,7 @@ tool_usage() {
}
verbose() {
- test -n "$VERB" && echo "$TOOL: $@" || true
+ test -n "$VERB" && echo "$TOOL:" "$@" || true
}
# Support multi-line error messages
@@ -124,10 +124,10 @@ error() {
dry() {
if [ "$DRY" -ne 0 ]; then
- verbose "Dry execution $@"
+ verbose "Dry execution" "$@"
return 0
fi
- verbose "Executing $@"
+ verbose "Executing" "$@"
"$@"
}
@@ -397,7 +397,7 @@ temp_umount() {
}
yes_no() {
- echo -n "$@? [Y|n] "
+ echo -n "$@" "? [Y|n] "
if [ -n "$YES" ]; then
echo y ; return 0
6 years, 10 months
master - fsadm: split local var dev
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=05a6d43476a4b260032...
Commit: 05a6d43476a4b2600329eae444c980107494b4ac
Parent: 439aaca3bc42c73ffe99bbf9b15c726b987ee2a6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 28 16:02:13 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
fsadm: split local var dev
Split defining of local variables from being them
assigned at the same time (lossing error code).
---
scripts/fsadm.sh | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh
index f3cc98b..b8744b1 100755
--- a/scripts/fsadm.sh
+++ b/scripts/fsadm.sh
@@ -229,8 +229,10 @@ detect_fs() {
# Check that passed mounted MAJOR:MINOR is not matching $MAJOR:MINOR of resized $VOLUME
validate_mounted_major_minor() {
test "$1" = "$MAJORMINOR" || {
- local REFNAME=$(dmsetup info -c -j "${1%%:*}" -m "${1##*:}" -o name --noheadings 2>/dev/null)
- local CURNAME=$(dmsetup info -c -j "$MAJOR" -m "$MINOR" -o name --noheadings 2>/dev/null)
+ local REFNAME
+ local CURNAME
+ REFNAME=$(dmsetup info -c -j "${1%%:*}" -m "${1##*:}" -o name --noheadings 2>/dev/null)
+ CURNAME=$(dmsetup info -c -j "$MAJOR" -m "$MINOR" -o name --noheadings 2>/dev/null)
error "Cannot ${CHECK+CHECK}${RESIZE+RESIZE} device \"$VOLUME\" without umounting filesystem $MOUNTED first." \
"Mounted filesystem is using device $CURNAME, but referenced device is $REFNAME." \
"Filesystem utilities currently do not support renamed devices."
@@ -243,10 +245,12 @@ validate_mounted_major_minor() {
# abort further command processing
check_valid_mounted_device() {
local MOUNTEDMAJORMINOR
- local VOL=$("$READLINK" $READLINK_E "$1")
- local CURNAME=$(dmsetup info -c -j "$MAJOR" -m "$MINOR" -o name --noheadings)
+ local VOL
+ local CURNAME
local SUGGEST="Possibly device \"$1\" has been renamed to \"$CURNAME\"?"
+ VOL=$("$READLINK" $READLINK_E "$1")
+ CURNAME=$(dmsetup info -c -j "$MAJOR" -m "$MINOR" -o name --noheadings)
# more confused, device is not DM....
test -n "$CURNAME" || SUGGEST="Mounted volume is not a device mapper device???"
6 years, 10 months
master - fsadm: remove surrounding $()
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=439aaca3bc42c73ffe9...
Commit: 439aaca3bc42c73ffe99bbf9b15c726b987ee2a6
Parent: b68235c51970dc3e159ebf7aa0ac5f4928414574
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 29 16:04:19 2017 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 29 22:23:16 2017 +0200
fsadm: remove surrounding $()
Remove surrounding $() to avoid executing output
---
scripts/fsadm.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh
index 996cd1f..f3cc98b 100755
--- a/scripts/fsadm.sh
+++ b/scripts/fsadm.sh
@@ -613,10 +613,10 @@ for i in "$TUNE_EXT" "$RESIZE_EXT" "$TUNE_REISER" "$RESIZE_REISER" \
done
"$LVM" version >"$NULL" 2>&1 || error "Could not run lvm binary \"$LVM\"."
-$("$READLINK" -e / >"$NULL" 2>&1) || READLINK_E="-f"
+"$READLINK" -e / >"$NULL" 2>&1 || READLINK_E="-f"
TEST64BIT=$(( 1000 * 1000000000000 ))
test "$TEST64BIT" -eq 1000000000000000 || error "Shell does not handle 64bit arithmetic."
-$(echo Y | "$GREP" Y >"$NULL") || error "Grep does not work properly."
+echo Y | "$GREP" Y >"$NULL" || error "Grep does not work properly."
test "$("$DATE" -u -d"Jan 01 00:00:01 1970" +%s)" -eq 1 || error "Date translation does not work."
6 years, 10 months