You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openwrt/package/network/utils/layerscape/restool/patches/0004-scripts-use-restool-fu...

112 lines
2.3 KiB
Diff

From 09f840049d155fa4b681ece749feeff9a269ecde Mon Sep 17 00:00:00 2001
From: Ioana Ciornei <ioana.ciornei@nxp.com>
Date: Tue, 24 Oct 2017 16:29:45 +0000
Subject: [PATCH 04/12] scripts: use restool --full-path option
Instead of constructing the the full path container list by
hand use the restool option newly added.
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
scripts/ls-main | 54 +++++++-----------------------------------------------
1 file changed, 7 insertions(+), 47 deletions(-)
diff --git a/scripts/ls-main b/scripts/ls-main
index ea0df92..72f6c77 100755
--- a/scripts/ls-main
+++ b/scripts/ls-main
@@ -73,7 +73,6 @@
##
shopt -s extglob
-shopt -s lastpipe
# Intercept the Ctrl+C command but do not interrupt execution
trap ' ' INT
@@ -87,11 +86,6 @@ root_c=
# Type of endpoint object
toe=
-containers=()
-# Full path containers
-fpc=()
-idx=0
-
SYS_DPRC="/sys/bus/fsl-mc/drivers/fsl_mc_dprc"
set -e
@@ -220,42 +214,6 @@ get_container() {
echo $(echo "$i" | sed "s/\(dprc.[0-9]*\/\)*//g")
}
-build_fpc_list() {
- $restool dprc list |
- while IFS= read -r line
- do
- containers+=("$line")
- done
-
- for i in "${containers[@]}"
- do
- cnt=$(count_spaces "$i")
-
- if [ "$cnt" -gt 0 ]; then
- # Get index of the upper level container
- idx2=$((idx-1))
- crt_ct="$i"
-
- while [ "$idx2" -ge 0 ]
- do
- cntp=$(count_spaces "${containers[idx2]}")
-
- if [ "$cntp" -lt "$cnt" ]; then
- upc=$(echo "${containers[idx2]}" | sed "s/ *$//")
- crt_ct=$upc"/""$(echo $crt_ct | sed 's/ *$//')"
- fi
- idx2=$((idx2-1))
- done
-
- fpc+=($crt_ct)
- else
- fpc+=("$i")
- fi
-
- idx=$((idx+1))
- done
-}
-
get_label() {
# Retrieve the type of the object
too=$(echo "$1" | sed "s/\(\.[0-9]*\)\(\.[0-9]*\)*$//g")
@@ -897,9 +855,9 @@ process_addni() {
}
process_listni() {
- build_fpc_list
-
- for i in "${fpc[@]}"
+ dprc_list="$($restool dprc list --full-path)"
+ echo "${dprc_list}" |
+ while read -r i
do
crt_c=$(get_container "$i")
$restool dprc show "$crt_c" | grep dpni |
@@ -948,10 +906,12 @@ process_listni() {
}
process_listmac() {
- build_fpc_list
+ dprc_list="$($restool dprc list --full-path)"
- for i in "${fpc[@]}"
+ echo "${dprc_list}" |
+ while read -r i
do
+
crt_c=$(get_container "$i")
$restool dprc show "$crt_c" | grep dpmac |
while IFS= read -r line
--
2.14.1