The bash completion script was using the generic  _available_interfaces
function to find all the network interfaces on the system.
_available_interfaces uses ifconfig which can truncate fcoe interface names of
the form "eth2.101-fcoe".  Instead of using ifconfig, find the network
interfaces by listing /sys/class/net/*

Signed-off-by: Ross Brattain <ross.b.bratt...@intel.com>
---
 contrib/bash_completion/fcoeadm |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/contrib/bash_completion/fcoeadm b/contrib/bash_completion/fcoeadm
index 60f902d..b3b23bb 100644
--- a/contrib/bash_completion/fcoeadm
+++ b/contrib/bash_completion/fcoeadm
@@ -19,6 +19,22 @@
 # Could not get numeric value to work for the --stats interval
 # Considered parsing output of --help to complete options
 
+have fcoeadm && _available_fcoe_interfaces()
+{
+    if [ "${1:-}" = -a ]; then
+        # list only devices that are up
+        COMPREPLY=( $( for f in /sys/class/net/* ; do if grep -q up 
$f/operstate ; then echo ${f##*/} ; fi ; done 2>/dev/null ))
+    else
+        # list all devices
+        COMPREPLY=( $( for f in /sys/class/net/* ; do  echo ${f##*/} ; done 
2>/dev/null ))
+    fi
+
+    COMPREPLY=( $( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" ) )
+}
+
+
+
+
 have fcoeadm && _fcoeadm_options()
 {
     local cur prev prev_prev opts
@@ -29,7 +45,8 @@ have fcoeadm && _fcoeadm_options()
 
     case "${prev}" in
         
-c|--create|-d|--destroy|-r|--reset|-s|--stats|-S|--Scan|-i|--interface|-t|--target|-l|--lun)
-           _available_interfaces
+           # only show interfaces that are up
+           _available_fcoe_interfaces -a
            return 0
            ;;
     esac

_______________________________________________
devel mailing list
devel@open-fcoe.org
https://lists.open-fcoe.org/mailman/listinfo/devel

Reply via email to