Commit 5631d100 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf daemon: Add base option

Add a base option allowing the user to specify a base directory.  It
will have precedence over config file base definition coming in the
following patches.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexei Budankov <abudankov@huawei.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: https://lore.kernel.org/r/20210208200908.1019149-4-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent fc1dcb1e
...@@ -31,6 +31,10 @@ OPTIONS ...@@ -31,6 +31,10 @@ OPTIONS
Config file path. If not provided, perf will check system and default Config file path. If not provided, perf will check system and default
locations (/etc/perfconfig, $HOME/.perfconfig). locations (/etc/perfconfig, $HOME/.perfconfig).
--base=<PATH>::
Base directory path. Each daemon instance is running on top
of base directory.
All generic options are available also under commands. All generic options are available also under commands.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <errno.h>
#include "builtin.h" #include "builtin.h"
#include "perf.h" #include "perf.h"
#include "debug.h" #include "debug.h"
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
struct daemon { struct daemon {
const char *config; const char *config;
char *config_real; char *config_real;
const char *base_user;
char *base; char *base;
FILE *out; FILE *out;
char perf[PATH_MAX]; char perf[PATH_MAX];
...@@ -38,10 +40,17 @@ static void sig_handler(int sig __maybe_unused) ...@@ -38,10 +40,17 @@ static void sig_handler(int sig __maybe_unused)
static void daemon__exit(struct daemon *daemon) static void daemon__exit(struct daemon *daemon)
{ {
free(daemon->config_real); free(daemon->config_real);
free(daemon->base);
} }
static int setup_config(struct daemon *daemon) static int setup_config(struct daemon *daemon)
{ {
if (daemon->base_user) {
daemon->base = strdup(daemon->base_user);
if (!daemon->base)
return -ENOMEM;
}
if (daemon->config) { if (daemon->config) {
char *real = realpath(daemon->config, NULL); char *real = realpath(daemon->config, NULL);
...@@ -104,6 +113,8 @@ int cmd_daemon(int argc, const char **argv) ...@@ -104,6 +113,8 @@ int cmd_daemon(int argc, const char **argv)
OPT_INCR('v', "verbose", &verbose, "be more verbose"), OPT_INCR('v', "verbose", &verbose, "be more verbose"),
OPT_STRING(0, "config", &__daemon.config, OPT_STRING(0, "config", &__daemon.config,
"config file", "config file path"), "config file", "config file path"),
OPT_STRING(0, "base", &__daemon.base_user,
"directory", "base directory"),
OPT_END() OPT_END()
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment