diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2021-04-30 10:03:01 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2021-05-12 18:43:10 +0300 |
commit | 2a525f6a5502bfd80568e6befb84053cf650ad25 (patch) | |
tree | 6b2bdf6fbde7501965a097302c91545deb421bf2 /tools/perf/util/data.c | |
parent | e9d64739635f8db204c9fc81f20ed70751b4e0dd (diff) | |
download | linux-2a525f6a5502bfd80568e6befb84053cf650ad25.tar.xz |
perf inject: Add facility to do in place update
When there is a need to modify only timestamps, it is much simpler and
quicker to do it to the existing file rather than re-write all the
contents.
In preparation for that, add the ability to modify the input file in place.
In practice that just means making the file descriptor and mmaps writable.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: https://lore.kernel.org/r/20210430070309.17624-5-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/data.c')
-rw-r--r-- | tools/perf/util/data.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 8fca4779ae6a..a9c102e8e3c0 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -240,11 +240,12 @@ static bool is_dir(struct perf_data *data) static int open_file_read(struct perf_data *data) { + int flags = data->in_place_update ? O_RDWR : O_RDONLY; struct stat st; int fd; char sbuf[STRERR_BUFSIZE]; - fd = open(data->file.path, O_RDONLY); + fd = open(data->file.path, flags); if (fd < 0) { int err = errno; |