Powertop2 uses debugfs. Currently it uses /bin/mount to mount
the debugfs. This doesnt work in Android. This patch enables
mounting of debugfs in Android
---
main.cpp | 31 ++++++++++++++++++++++++++++++-
1 files changed, 30 insertions(+), 1 deletions(-)
diff --git a/main.cpp b/main.cpp
index 9fc358c..cb7fcc5 100644
--- a/main.cpp
+++ b/main.cpp
@@ -192,6 +192,22 @@ void out_of_memory()
abort();
}
+bool fileexists(string strFilename)
+{
+ struct stat stFileInfo;
+ bool blnReturn;
+ int intStat;
+
+ // Attempt to get the file attributes
+ intStat = stat(strFilename.c_str(),&stFileInfo);
+ if(intStat == 0)
+ blnReturn = true;
+ else
+ blnReturn = false;
+
+ return(blnReturn);
+}
+
int main(int argc, char **argv)
{
int uid;
@@ -213,7 +229,20 @@ int main(int argc, char **argv)
}
system("/sbin/modprobe cpufreq_stats > /dev/null 2>&1");
system("/sbin/modprobe msr > /dev/null 2>&1");
- system("/bin/mount -t debugfs debugfs /sys/kernel/debug > /dev/null
2>&1");
+ if (!fileexists("/sys/kernel/debug/tracing")) {
+ if (fileexists("/bin/mount")) {
+ system("/bin/mount -t debugfs debugfs /sys/kernel/debug
> /dev/null 2>&1");
+ } else {
+ //system("/sbin/mount -t debugfs debugfs
/sys/kernel/debug"); //doesnt work
+ pid_t child_pid = fork();
+ if(child_pid == 0) {
+ char *args[] = {"mount", "-t", "debugfs",
"debugfs", "/sys/kernel/debug", NULL};
+ execvp(args[0],args);
+ printf("mount failed\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
srand(time(NULL));
--
1.7.0.4
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
_______________________________________________
Power mailing list
[email protected]
https://bughost.org/mailman/listinfo/power