1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Fix string parsing

Fix propagation of -e option - pass it via internal shell variable.
Fix parsing of /proc/mounts files (don't check for substrings).
 as reported by O.Mangold with suggested patch:
 https://www.redhat.com/archives/linux-lvm/2012-February/msg00030.html
Properly pass arguments with spaces ("$@")
Add validation for YES and EXTOFF variable content.
This commit is contained in:
Zdenek Kabelac 2012-03-16 12:53:05 +00:00
parent 3f5b1f651a
commit de0e4e755a
2 changed files with 15 additions and 8 deletions

View File

@ -1,5 +1,8 @@
Version 2.02.96 - Version 2.02.96 -
================================ ================================
Fix fsadm propagation of -e option.
Fix fsadm parsing of /proc/mounts files (don't check for substrings).
Fix fsadm usage of arguments with space.
Fix a regression in handling of lvchange/lvcreate --major/--minor. Fix a regression in handling of lvchange/lvcreate --major/--minor.
Fix name conflicts that prevent down-converting RAID1 when specifying a device Fix name conflicts that prevent down-converting RAID1 when specifying a device
Improve thin_check option passing and use configured path. Improve thin_check option passing and use configured path.

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
# Copyright (C) 2007-2010 Red Hat, Inc. All rights reserved. # Copyright (C) 2007-2012 Red Hat, Inc. All rights reserved.
# #
# This file is part of LVM2. # This file is part of LVM2.
# #
@ -62,7 +62,7 @@ YES=${_FSADM_YES}
DRY=0 DRY=0
VERB= VERB=
FORCE= FORCE=
EXTOFF=0 EXTOFF=${_FSADM_EXTOFF:-0}
DO_LVRESIZE=0 DO_LVRESIZE=0
FSTYPE=unknown FSTYPE=unknown
VOLUME=unknown VOLUME=unknown
@ -121,7 +121,7 @@ dry() {
return 0 return 0
fi fi
verbose "Executing $@" verbose "Executing $@"
$@ "$@"
} }
cleanup() { cleanup() {
@ -141,7 +141,8 @@ cleanup() {
# start LVRESIZE with the filesystem modification flag # start LVRESIZE with the filesystem modification flag
# and allow recursive call of fsadm # and allow recursive call of fsadm
_FSADM_YES=$YES _FSADM_YES=$YES
export _FSADM_YES _FSADM_EXTOFF=$EXTOFF
export _FSADM_YES _FSADM_EXTOFF
unset FSADM_RUNNING unset FSADM_RUNNING
test -n "$LVM_BINARY" && PATH=$_SAVEPATH test -n "$LVM_BINARY" && PATH=$_SAVEPATH
dry exec "$LVM" lvresize $VERB $FORCE -r -L${NEWSIZE}b "$VOLUME_ORIG" dry exec "$LVM" lvresize $VERB $FORCE -r -L${NEWSIZE}b "$VOLUME_ORIG"
@ -200,10 +201,10 @@ detect_fs() {
detect_mounted() { detect_mounted() {
test -e "$PROCMOUNTS" || error "Cannot detect mounted device \"$VOLUME\"" test -e "$PROCMOUNTS" || error "Cannot detect mounted device \"$VOLUME\""
MOUNTED=$("$GREP" ^"$VOLUME" "$PROCMOUNTS") MOUNTED=$("$GREP" "^$VOLUME[ \t]" "$PROCMOUNTS")
# for empty string try again with real volume name # for empty string try again with real volume name
test -z "$MOUNTED" && MOUNTED=$("$GREP" ^"$RVOLUME" "$PROCMOUNTS") test -z "$MOUNTED" && MOUNTED=$("$GREP" "^$RVOLUME[ \t]" "$PROCMOUNTS")
# cut device name prefix and trim everything past mountpoint # cut device name prefix and trim everything past mountpoint
# echo translates \040 to spaces # echo translates \040 to spaces
@ -212,8 +213,8 @@ detect_mounted() {
# for systems with different device names - check also mount output # for systems with different device names - check also mount output
if test -z "$MOUNTED" ; then if test -z "$MOUNTED" ; then
MOUNTED=$(LANG=C "$MOUNT" | "$GREP" ^"$VOLUME") MOUNTED=$(LANG=C "$MOUNT" | "$GREP" "^$VOLUME[ \t]")
test -z "$MOUNTED" && MOUNTED=$(LANG=C "$MOUNT" | "$GREP" ^"$RVOLUME") test -z "$MOUNTED" && MOUNTED=$(LANG=C "$MOUNT" | "$GREP" "^$RVOLUME[ \t]")
MOUNTED=${MOUNTED##* on } MOUNTED=${MOUNTED##* on }
MOUNTED=${MOUNTED% type *} # allow type in the mount name MOUNTED=${MOUNTED% type *} # allow type in the mount name
fi fi
@ -484,6 +485,9 @@ do
shift shift
done done
test "$YES" = "-y" || YES=
test "$EXTOFF" -eq 1 || EXTOFF=0
if [ -n "$CHECK" ]; then if [ -n "$CHECK" ]; then
check "$CHECK" check "$CHECK"
elif [ -n "$RESIZE" ]; then elif [ -n "$RESIZE" ]; then