]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cclsinfo.sh: better architecture detection
authorYehuda Sadeh <yehuda@hq.newdream.net>
Tue, 1 Jun 2010 19:57:54 +0000 (12:57 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 10 Jun 2010 21:45:40 +0000 (14:45 -0700)
src/cclsinfo.sh

index bf5937cd0bf61829f80099b218d415cb8c359f53..b5c2a968a3c552cb3af5d08ef4c39f8b45d8d9e3 100755 (executable)
@@ -19,7 +19,7 @@ usage_exit() {
 }
 
 err_exit() {
-       echo $*
+       echo "Error: $*"
        exit 1
 }
 
@@ -59,6 +59,7 @@ fi
 if [ $show_name -eq 1 ]; then
        raw_name=`nm $fname | grep __cls_name__`
        name=`echo $raw_name | sed 's/.*cls_name__//g'`
+       [ "$name" == "" ] && err_exit "Could not detect class name"
        s=$name
        c=" "
 fi
@@ -66,13 +67,17 @@ fi
 if [ $show_ver -eq 1 ]; then
        raw_ver=`nm $fname | grep __cls_ver__`
        ver=`echo $raw_ver | sed 's/.*cls_ver__//g; s/_/./g'`
+       [ "$name" == "" ] && err_exit "Could not detect class version"
        s=$s$c$ver
        c=" "
 fi
 
 if [ $show_arch -eq 1 ]; then
-       raw_arch=`file -L $fname | awk '{print $7}'`
-       arch=`echo $raw_arch | sed 's/,//g'`
+       raw_arch=`readelf -h $fname | grep Machine`
+       arch=""
+       [ `grep -c 386` -gt 0 ] && arch="i386"
+       [ `grep -c 86-64` -gt 0 ] && arch="x86-64"
+       [ "$name" == "" ] && err_exit "unknown file architecture"
        s=$s$c$arch
        c=" "
 fi