[SCRIPT] device name to location code converter

linas at austin.ibm.com linas at austin.ibm.com
Wed May 5 10:12:54 EST 2004


I got tired of looking up/guesing location codes based on device names.
Appended is a trivial perl script to do the work for me.

Here's the obligatory screenshot:

# ./get-loc-code.pl net/eth0
U0.1-P2-I1/E1

--linas


#! /usr/bin/env perl
#
# Given a device class and name, such as "net/eth0", find
# the corresponding ibm location code.  Do this by looking
# up the device spec in the /sys tree followed by a lookup
# in the device-tree.

if ($#ARGV != 0) {
	print "Usage: $0 deviceclass/devicename\n";
	print "\tFor example:  $0 net/eth0\n";
	exit 1;
}

$syspath = "/sys/class/" . $ARGV[0] . "/device/devspec";

open (SPEC, $syspath) or die "Can't open $syspath: $!";

$specpath = <SPEC>;
$specpath = "/proc/device-tree/" . $specpath . "/ibm,loc-code";

open (LOC, $specpath) or die "Can't open $specpath: $!";

$loc_code = <LOC>;

print "$loc_code\n";


** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc64-dev mailing list