0004-scripts-use-restool-full-path-option.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. From 09f840049d155fa4b681ece749feeff9a269ecde Mon Sep 17 00:00:00 2001
  2. From: Ioana Ciornei <[email protected]>
  3. Date: Tue, 24 Oct 2017 16:29:45 +0000
  4. Subject: [PATCH 04/12] scripts: use restool --full-path option
  5. Instead of constructing the the full path container list by
  6. hand use the restool option newly added.
  7. Signed-off-by: Ioana Ciornei <[email protected]>
  8. ---
  9. scripts/ls-main | 54 +++++++-----------------------------------------------
  10. 1 file changed, 7 insertions(+), 47 deletions(-)
  11. diff --git a/scripts/ls-main b/scripts/ls-main
  12. index ea0df92..72f6c77 100755
  13. --- a/scripts/ls-main
  14. +++ b/scripts/ls-main
  15. @@ -73,7 +73,6 @@
  16. ##
  17. shopt -s extglob
  18. -shopt -s lastpipe
  19. # Intercept the Ctrl+C command but do not interrupt execution
  20. trap ' ' INT
  21. @@ -87,11 +86,6 @@ root_c=
  22. # Type of endpoint object
  23. toe=
  24. -containers=()
  25. -# Full path containers
  26. -fpc=()
  27. -idx=0
  28. -
  29. SYS_DPRC="/sys/bus/fsl-mc/drivers/fsl_mc_dprc"
  30. set -e
  31. @@ -220,42 +214,6 @@ get_container() {
  32. echo $(echo "$i" | sed "s/\(dprc.[0-9]*\/\)*//g")
  33. }
  34. -build_fpc_list() {
  35. - $restool dprc list |
  36. - while IFS= read -r line
  37. - do
  38. - containers+=("$line")
  39. - done
  40. -
  41. - for i in "${containers[@]}"
  42. - do
  43. - cnt=$(count_spaces "$i")
  44. -
  45. - if [ "$cnt" -gt 0 ]; then
  46. - # Get index of the upper level container
  47. - idx2=$((idx-1))
  48. - crt_ct="$i"
  49. -
  50. - while [ "$idx2" -ge 0 ]
  51. - do
  52. - cntp=$(count_spaces "${containers[idx2]}")
  53. -
  54. - if [ "$cntp" -lt "$cnt" ]; then
  55. - upc=$(echo "${containers[idx2]}" | sed "s/ *$//")
  56. - crt_ct=$upc"/""$(echo $crt_ct | sed 's/ *$//')"
  57. - fi
  58. - idx2=$((idx2-1))
  59. - done
  60. -
  61. - fpc+=($crt_ct)
  62. - else
  63. - fpc+=("$i")
  64. - fi
  65. -
  66. - idx=$((idx+1))
  67. - done
  68. -}
  69. -
  70. get_label() {
  71. # Retrieve the type of the object
  72. too=$(echo "$1" | sed "s/\(\.[0-9]*\)\(\.[0-9]*\)*$//g")
  73. @@ -897,9 +855,9 @@ process_addni() {
  74. }
  75. process_listni() {
  76. - build_fpc_list
  77. -
  78. - for i in "${fpc[@]}"
  79. + dprc_list="$($restool dprc list --full-path)"
  80. + echo "${dprc_list}" |
  81. + while read -r i
  82. do
  83. crt_c=$(get_container "$i")
  84. $restool dprc show "$crt_c" | grep dpni |
  85. @@ -948,10 +906,12 @@ process_listni() {
  86. }
  87. process_listmac() {
  88. - build_fpc_list
  89. + dprc_list="$($restool dprc list --full-path)"
  90. - for i in "${fpc[@]}"
  91. + echo "${dprc_list}" |
  92. + while read -r i
  93. do
  94. +
  95. crt_c=$(get_container "$i")
  96. $restool dprc show "$crt_c" | grep dpmac |
  97. while IFS= read -r line
  98. --
  99. 2.14.1