%make_install
%files
-%{_bindir}/opcontrol
-%{_bindir}/oprofile_command
-%{_bindir}/oprofiled
-%{_bindir}/ophelp
-%{_bindir}/op-check-perfevents
+%attr(755,root,root) %{_bindir}/opcontrol
+%attr(755,root,root) %{_bindir}/oprofile_command
+%attr(755,root,root) %{_bindir}/oprofiled
+%attr(755,root,root) %{_bindir}/ophelp
+%attr(755,root,root) %{_bindir}/op-check-perfevents
%ifarch %{arm}
%{_datadir}/oprofile/arm/armv7
#!/bin/bash
+KILL=/usr/bin/killall
OPCONTROL=/usr/bin/opcontrol
OPHELP=/usr/bin/ophelp
+is_app_executable()
+{
+ if [[ $1 =~ ^((/opt/apps)|(/opt/usr/apps))/[a-zA-Z0-9]{10}/bin/[a-zA-Z0-9_\\-]{1,}(\.exe)?$ ]] ; then
+ return 1
+ else
+ return 0
+ fi
+}
+
op_init()
{
$OPCONTROL --init
echo 0 > /proc/sys/kernel/nmi_watchdog
}
+ls_app()
+{
+ is_app_executable $APPPATH
+ if [[ "$?" -ne 1 ]] ; then
+ echo "Invalid application executable path!"
+ exit 1
+ fi
+ ls $APPPATH
+}
+kill_app()
+{
+ is_app_executable $APPPATH
+ if [[ "$?" -ne 1 ]] ; then
+ echo "Invalid application executable path!"
+ exit 1
+ fi
+ $KILL $APPPATH
+}
echo $@
#echo $@ >> /home/developer/oprofile_history
+if [[ `id -u` != "0" ]] ; then
+ echo "You must be root to run this script!"
+# echo "You are not root!" >> /home/developer/oprofile_history
+ exit 1
+fi
+
if [[ -n $1 ]]; then
case "$1" in
init)
list)
op_list
;;
+ status)
+ op_status
+ ;;
save)
if [[ -n $2 ]]; then
SAVENAME=$2
watchdogoff)
disable_watchdog
;;
+ lsapp)
+ if [[ -n $2 ]]; then
+ APPPATH=$2
+ else
+ echo "Application executable path is not given!"
+ exit 1
+ fi
+ ls_app
+ ;;
+ killapp)
+ if [[ -n $2 ]]; then
+ APPPATH=$2
+ else
+ echo "Application executable path is not given!"
+ exit 1
+ fi
+ kill_app
+ ;;
*)
echo "Unknown option!" >&2
exit 1