diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/ceph-clsinfo | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ceph-clsinfo')
-rwxr-xr-x | src/ceph-clsinfo | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/ceph-clsinfo b/src/ceph-clsinfo new file mode 100755 index 00000000..5615af48 --- /dev/null +++ b/src/ceph-clsinfo @@ -0,0 +1,85 @@ +#!/bin/sh + + +show_name=0 +show_ver=0 +show_arch=0 +show_default=1 +fname="" + +usage="usage: $0 [option]... <cls_filename>\n" +usage=$usage"options:\n" +usage=$usage"\t-n, --name\n" +usage=$usage"\t-v, --ver\n" +usage=$usage"\t-a, --arch\n" + +usage_exit() { + printf "$usage" + exit 1 +} + +err_exit() { + echo "Error: $*" + exit 1 +} + +while [ $# -ge 1 ]; do +case $1 in + -n | --name ) + show_name=1 + show_default=0 + ;; + -v | --ver ) + show_ver=1 + show_default=0 + ;; + -a | --arch ) + show_arch=1 + show_default=0 + ;; + * ) + [ -n "$fname" ] && usage_exit + fname=$1 + ;; + +esac +shift +done + +[ -z "$fname" ] && usage_exit + +if [ $show_default -eq 1 ]; then + show_name=1 + show_ver=1 + show_arch=1 +fi + +[ -e "$fname" ] || err_exit "File not found: ${fname}" + +if [ $show_name -eq 1 ]; then + raw_name=`nm $fname | grep __cls_name__` + name=`echo $raw_name | sed 's/.*cls_name__//g'` + [ -z "$name" ] && err_exit "Could not detect class name" + s=$name + c=" " +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'` + [ -z "$ver" ] && err_exit "Could not detect class version" + s=$s$c$ver + c=" " +fi + +if [ $show_arch -eq 1 ]; then + raw_arch=`readelf -h $fname | grep Machine` + arch="" + [ `echo $raw_arch | grep -c 386` -gt 0 ] && arch="i386" + [ `echo $raw_arch | grep -c 86-64` -gt 0 ] && arch="x86-64" + [ -z "$arch" ] && err_exit "unknown file architecture" + s=$s$c$arch + c=" " +fi + +echo $s |