oprofile: Determine the root home directory dynamically This commit detects the root home directory dynamically with changes to the opcontrol script and the oprofile gui app source. The commit replaces an earlier fix that detected and adjusted a 'non-standard' root home directory at build time. The advantage of this patch is that the oprofile tools are adjusted to the current run-time path to ~root, not the build time path. Upstream-Status: inappropriate [OE specific] Signed-off-by: Dave Lerner diff --git a/doc/opcontrol.1.in b/doc/opcontrol.1.in index c434704..f57eb76 100644 --- a/doc/opcontrol.1.in +++ b/doc/opcontrol.1.in @@ -171,7 +171,7 @@ No special environment variables are recognised by opcontrol. .SH FILES .TP -.I /root/.oprofile/daemonrc +.I ~root/.oprofile/daemonrc Configuration file for opcontrol .TP .I /var/lib/oprofile/samples/ diff --git a/doc/oprofile.1.in b/doc/oprofile.1.in index 3d0f0ed..5c623e1 100644 --- a/doc/oprofile.1.in +++ b/doc/oprofile.1.in @@ -150,7 +150,7 @@ No special environment variables are recognised by oprofile. .I $HOME/.oprofile/ Configuration files .TP -.I /root/.oprofile/daemonrc +.I ~root/.oprofile/daemonrc Configuration file for opcontrol .TP .I @prefix@/share/oprofile/ diff --git a/doc/oprofile.html b/doc/oprofile.html index 128d9f7..d7e4dea 100644 --- a/doc/oprofile.html +++ b/doc/oprofile.html @@ -1394,7 +1394,7 @@ The opcontrol script provides the

Followed by list arguments for profiling set up. List of arguments - saved in /root/.oprofile/daemonrc. + saved in ~root/.oprofile/daemonrc. Giving this option is not necessary; you can just directly pass one of the setup options, e.g. opcontrol --no-vmlinux.

@@ -1430,7 +1430,7 @@ The opcontrol script provides the

Start data collection with either arguments provided by --setup - or information saved in /root/.oprofile/daemonrc. Specifying + or information saved in ~root/.oprofile/daemonrc. Specifying the addition --verbose makes the daemon generate lots of debug data whilst it is running.

diff --git a/doc/oprofile.xml b/doc/oprofile.xml index 6a17c6d..0968d76 100644 --- a/doc/oprofile.xml +++ b/doc/oprofile.xml @@ -568,7 +568,7 @@ The opcontrol script provides the following actions : Followed by list arguments for profiling set up. List of arguments - saved in /root/.oprofile/daemonrc. + saved in ~root/.oprofile/daemonrc. Giving this option is not necessary; you can just directly pass one of the setup options, e.g. opcontrol --no-vmlinux. @@ -592,7 +592,7 @@ The opcontrol script provides the following actions : Start data collection with either arguments provided by - or information saved in /root/.oprofile/daemonrc. Specifying + or information saved in ~root/.oprofile/daemonrc. Specifying the addition makes the daemon generate lots of debug data whilst it is running. diff --git a/gui/oprof_start_util.cpp b/gui/oprof_start_util.cpp index d293431..d13fa8f 100644 --- a/gui/oprof_start_util.cpp +++ b/gui/oprof_start_util.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include @@ -39,7 +41,8 @@ namespace { // return the ~ expansion suffixed with a '/' string const get_config_dir() { - return "/root"; + struct *pw = getpwnam("root"); + return pw->pw_dir; } string daemon_pid; diff --git a/utils/opcontrol b/utils/opcontrol index 09fa5a7..a8acdae 100644 --- a/utils/opcontrol +++ b/utils/opcontrol @@ -385,7 +385,7 @@ do_init() OPROFILED="$OPDIR/oprofiled" # location for daemon setup information - SETUP_DIR="/root/.oprofile" + SETUP_DIR="`grep root /etc/passwd | cut -d: -f6`/.oprofile" SETUP_FILE="$SETUP_DIR/daemonrc" SEC_SETUP_FILE="$SETUP_DIR/daemonrc_new"