[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-c9a8a6131fb68f6eabec34fd855e69b4855155e4@git.kernel.org>
Date: Thu, 23 Aug 2018 01:43:21 -0700
From: tip-bot for Jiri Olsa <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: dsahern@...il.com, namhyung@...nel.org, mingo@...nel.org,
tglx@...utronix.de, alexander.shishkin@...ux.intel.com,
hpa@...or.com, mpetlan@...hat.com, linux-kernel@...r.kernel.org,
jolsa@...nel.org, peterz@...radead.org, acme@...hat.com
Subject: [tip:perf/urgent] perf tools: Move the temp file processing into
decompress_kmodule
Commit-ID: c9a8a6131fb68f6eabec34fd855e69b4855155e4
Gitweb: https://git.kernel.org/tip/c9a8a6131fb68f6eabec34fd855e69b4855155e4
Author: Jiri Olsa <jolsa@...nel.org>
AuthorDate: Fri, 17 Aug 2018 11:48:09 +0200
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Mon, 20 Aug 2018 08:54:59 -0300
perf tools: Move the temp file processing into decompress_kmodule
We will add a compression check in the following patch and it makes it
easier if the file processing is done in a single place. It also makes
the current code simpler.
The decompress_kmodule function now returns the fd of the uncompressed
file and the file name in the pathname arg, if it's provided.
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Cc: David Ahern <dsahern@...il.com>
Cc: Michael Petlan <mpetlan@...hat.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Link: http://lkml.kernel.org/r/20180817094813.15086-10-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/dso.c | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 54bfe1f4762f..cbeecf683333 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -250,8 +250,10 @@ bool dso__needs_decompress(struct dso *dso)
dso->symtab_type == DSO_BINARY_TYPE__GUEST_KMODULE_COMP;
}
-static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf)
+static int decompress_kmodule(struct dso *dso, const char *name,
+ char *pathname, size_t len)
{
+ char tmpbuf[] = KMOD_DECOMP_NAME;
int fd = -1;
if (!dso__needs_decompress(dso))
@@ -272,34 +274,27 @@ static int decompress_kmodule(struct dso *dso, const char *name, char *tmpbuf)
fd = -1;
}
+ if (!pathname || (fd < 0))
+ unlink(tmpbuf);
+
+ if (pathname && (fd >= 0))
+ strncpy(pathname, tmpbuf, len);
+
return fd;
}
int dso__decompress_kmodule_fd(struct dso *dso, const char *name)
{
- char tmpbuf[] = KMOD_DECOMP_NAME;
- int fd;
-
- fd = decompress_kmodule(dso, name, tmpbuf);
- unlink(tmpbuf);
- return fd;
+ return decompress_kmodule(dso, name, NULL, 0);
}
int dso__decompress_kmodule_path(struct dso *dso, const char *name,
char *pathname, size_t len)
{
- char tmpbuf[] = KMOD_DECOMP_NAME;
- int fd;
-
- fd = decompress_kmodule(dso, name, tmpbuf);
- if (fd < 0) {
- unlink(tmpbuf);
- return -1;
- }
+ int fd = decompress_kmodule(dso, name, pathname, len);
- strncpy(pathname, tmpbuf, len);
close(fd);
- return 0;
+ return fd >= 0 ? 0 : -1;
}
/*
Powered by blists - more mailing lists