lkml.org 
[lkml]   [2021]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 03/24] perf daemon: Add base option
Date
Adding base option allowing user to specify base directory.
It will have precedence over config file base definition
coming in following patches.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/Documentation/perf-daemon.txt | 4 ++++
tools/perf/builtin-daemon.c | 11 +++++++++++
2 files changed, 15 insertions(+)

diff --git a/tools/perf/Documentation/perf-daemon.txt b/tools/perf/Documentation/perf-daemon.txt
index ba3f88510aee..1a4158cd973e 100644
--- a/tools/perf/Documentation/perf-daemon.txt
+++ b/tools/perf/Documentation/perf-daemon.txt
@@ -31,6 +31,10 @@ OPTIONS
Config file path. If not provided, perf will check system and default
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.


diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c
index 90b5a8ea9dda..ce0373f453d6 100644
--- a/tools/perf/builtin-daemon.c
+++ b/tools/perf/builtin-daemon.c
@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
+#include <errno.h>
#include "builtin.h"
#include "perf.h"
#include "debug.h"
@@ -15,6 +16,7 @@
struct daemon {
const char *config;
char *config_real;
+ const char *base_user;
char *base;
FILE *out;
char perf[PATH_MAX];
@@ -38,10 +40,17 @@ static void sig_handler(int sig __maybe_unused)
static void daemon__exit(struct daemon *daemon)
{
free(daemon->config_real);
+ free(daemon->base);
}

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) {
char *real = realpath(daemon->config, NULL);

@@ -104,6 +113,8 @@ int cmd_daemon(int argc, const char **argv)
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
OPT_STRING(0, "config", &__daemon.config,
"config file", "config file path"),
+ OPT_STRING(0, "base", &__daemon.base_user,
+ "directory", "base directory"),
OPT_END()
};

--
2.29.2
\
 
 \ /
  Last update: 2021-02-08 22:14    [W:1.899 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site