On Fri, 2011-05-06 at 12:15 +0300, John Mathew wrote:
> 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 and also adds new file paths to store powertop
> data for android.
> ---
> main.cpp | 62
> +++++++++++++++++++++++++++++++++++++++++++++++++++-----------
> 1 files changed, 51 insertions(+), 11 deletions(-)
>
> diff --git a/main.cpp b/main.cpp
> index 9fc358c..464273a 100644
> --- a/main.cpp
> +++ b/main.cpp
> @@ -213,14 +213,33 @@ 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 (access("/sys/kernel/debug/tracing", R_OK) != 0) {
> + if (access("/bin/mount", X_OK) == 0) {
> + 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);
> + }
> + }
> + }
When I first saw this part my gut reaction was to ask why you don't just
use execvp in the first place?
Another variation should be
system("mount -t debugfs debugfs /sys/kernel/debug > /dev/null 2>&1");
/MF
_______________________________________________
Power mailing list
[email protected]
https://bughost.org/mailman/listinfo/power