93 lines
2.7 KiB
Diff
93 lines
2.7 KiB
Diff
There are the following problems with lvm completions:
|
|
1)_lvm_physicalvolumes() only gets PVs that belong to a VG. In some
|
|
cases like pvremove we can use all PVs including those not included
|
|
in any VGs.
|
|
solution: Add _lvm_physicalvolumes_all to get all PVs and correct
|
|
all the commands.
|
|
|
|
2)pvcreate should be able to use all block devcices.
|
|
solution: Add _lvm_filedir() to use _filedir except set $cur to /dev
|
|
when $cur is empty.
|
|
|
|
3)when /etc/lvm/lvm.conf silent is 1 there is no output for vg/lv/pvscan,
|
|
bash-completion will not work.
|
|
solution: Check the value of silent option. If it is 1 then temporarily
|
|
set silent 0 and recover back to 1 after the command executed.
|
|
|
|
Signed-off-by: Liuhua Wang <lwang@suse.com>
|
|
Reviewed-by: Lidong Zhong <lzhong@suse.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Index: bash-completion-2.11/completions/lvm
|
|
===================================================================
|
|
--- bash-completion-2.11.orig/completions/lvm
|
|
+++ bash-completion-2.11/completions/lvm
|
|
@@ -6,27 +6,41 @@ _lvm_filedir()
|
|
_filedir
|
|
}
|
|
|
|
+_lvm_verbose()
|
|
+{
|
|
+ local silent=$(sed -n -e "s|^[ \t]*silent[ \t]*=[ \t]*\([01]\)|\1|p" /etc/lvm/lvm.conf)
|
|
+ test ${silent:-0} -eq 1
|
|
+}
|
|
+
|
|
_lvm_volumegroups()
|
|
{
|
|
- COMPREPLY=($(compgen -W "$(vgscan 2>/dev/null |
|
|
+ local verbose
|
|
+ _lvm_verbose && verbose=-v
|
|
+ COMPREPLY=( $(compgen -W "$( vgscan $verbose 2>/dev/null | \
|
|
command sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p')" -- "$cur"))
|
|
}
|
|
|
|
_lvm_physicalvolumes_all()
|
|
{
|
|
- COMPREPLY=($(compgen -W "$(pvscan 2>/dev/null |
|
|
+ local verbose
|
|
+ _lvm_verbose && verbose=-v
|
|
+ COMPREPLY=( $(compgen -W "$( pvscan $verbose 2>/dev/null | \
|
|
command sed -n -e 's|^.*PV \([^ ]*\) .*|\1|p')" -- "$cur"))
|
|
}
|
|
|
|
_lvm_physicalvolumes()
|
|
{
|
|
- COMPREPLY=($(compgen -W "$(pvscan 2>/dev/null |
|
|
+ local verbose
|
|
+ _lvm_verbose && verbose=-v
|
|
+ COMPREPLY=( $(compgen -W "$( pvscan $verbose 2>/dev/null | \
|
|
command sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p')" -- "$cur"))
|
|
}
|
|
|
|
_lvm_logicalvolumes()
|
|
{
|
|
- COMPREPLY=($(compgen -W "$(lvscan 2>/dev/null |
|
|
+ local verbose
|
|
+ _lvm_verbose && verbose=-v
|
|
+ COMPREPLY=( $(compgen -W "$( lvscan $verbose 2>/dev/null | \
|
|
command sed -n -e "s|^.*'\(.*\)'.*$|\1|p")" -- "$cur"))
|
|
if [[ $cur == /dev/mapper/* ]]; then
|
|
_filedir
|
|
@@ -387,7 +401,7 @@ _vgreduce()
|
|
if ((args == 0)); then
|
|
_lvm_volumegroups
|
|
else
|
|
- _lvm_physicalvolumes
|
|
+ _lvm_physicalvolumes_all
|
|
fi
|
|
fi
|
|
} &&
|
|
@@ -701,7 +715,7 @@ _lvcreate()
|
|
if ((args == 0)); then
|
|
_lvm_volumegroups
|
|
else
|
|
- _lvm_physicalvolumes
|
|
+ _lvm_physicalvolumes_all
|
|
fi
|
|
fi
|
|
} &&
|