From patchwork Mon Jul 11 14:02:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian King X-Patchwork-Id: 104213 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id B5ED7B70ED for ; Tue, 12 Jul 2011 00:03:02 +1000 (EST) Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "e36.co.us.ibm.com", Issuer "Equifax" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id B8F21B6F88 for ; Tue, 12 Jul 2011 00:03:00 +1000 (EST) Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e36.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p6BDuZq1019369 for ; Mon, 11 Jul 2011 07:56:35 -0600 Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p6BE2YuB040914 for ; Mon, 11 Jul 2011 08:02:36 -0600 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p6BE827B016891 for ; Mon, 11 Jul 2011 08:08:02 -0600 Received: from localhost.localdomain (sig-9-49-189-235.mts.ibm.com [9.49.189.235]) by d03av06.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p6BE81F0016467; Mon, 11 Jul 2011 08:08:01 -0600 Message-Id: <201107111408.p6BE81F0016467@d03av06.boulder.ibm.com> Subject: [PATCH 4/5] ofpath: Support systems with a large number of devices To: yaboot-devel@lists.ozlabs.org From: Brian King Date: Mon, 11 Jul 2011 09:02:32 -0500 X-BeenThere: yaboot-devel@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical and development discussion regarding yaboot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: yaboot-devel-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Improve the ofpath script to be able to display the OF path for more than just the first 16 devices on the system. Signed-off-by: Brian King --- ybin/ofpath | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff -puN ybin/ofpath~ofpath_more_devs ybin/ofpath --- yaboot/ybin/ofpath~ofpath_more_devs 2011-06-24 13:55:41.000000000 -0500 +++ yaboot-bjking1/ybin/ofpath 2011-06-24 13:56:17.000000000 -0500 @@ -116,15 +116,41 @@ linecount() ## small tr replacment which handles a specific need of this script. smalltr() { - case "$1" in - a) echo 1 ;; b) echo 2 ;; c) echo 3 ;; d) echo 4 ;; e) echo 5 ;; f) echo 6 ;; - g) echo 7 ;; h) echo 8 ;; i) echo 9 ;; j) echo 10 ;; k) echo 11 ;; l) echo 12 ;; - m) echo 13 ;; n) echo 14 ;; o) echo 15 ;; p) echo 16 ;; - 1) echo a ;; 2) echo b ;; 3) echo c ;; 4) echo d ;; 5) echo e ;; - 6) echo f ;; 7) echo g ;; 8) echo h ;; 9) echo i ;; 10) echo j ;; - 11) echo k ;; 12) echo l ;; 13) echo m ;; 14) echo n ;; 15) echo o ;; - 16) echo p ;; - esac + local i a d t val out mod cur + + val="$1" + out="0" + + d=$(printf "%d\n" \'${val:0:1}) + + if (( $d > 57 )) ; then # is a letter + for ((i=0; i < ${#val}; i++)) ; do + d=$(printf "%d\n" \'${val:$i:1}) + a=$(($d - 96)) + out=$(($out * 26)) + out=$(($out + $a)) + done + + else # is a number + t=$val + out="" + + while ((t != 0)) ; do + mod=$(($t % 26)) + t=$(($t / 26)) + if (($mod == 0)) ; then + cur="z" + t=$(($t - 1)) + else + mod=$(($mod + 96)) + cur=$(echo $mod | gawk '{printf "%c", $1}') + fi + out="$cur$out" + done + fi + + echo "$out" + return 0 }